96 lines
2.9 KiB
PHP
96 lines
2.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Class UserPayCredit
|
|
*
|
|
* @property int $id
|
|
* @property int $user_id
|
|
* @property float|null $credit
|
|
* @property float|null $old_credit_total
|
|
* @property float|null $new_credit_total
|
|
* @property string|null $message
|
|
* @property int $status
|
|
* @property int|null $shopping_order_id
|
|
* @property Carbon|null $created_at
|
|
* @property Carbon|null $updated_at
|
|
* @property ShoppingOrder|null $shopping_order
|
|
* @property User $user
|
|
* @package App\Models
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereCredit($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereMessage($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereNewCreditTotal($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereOldCreditTotal($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereShoppingOrderId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereStatus($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereUpdatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|UserPayCredit whereUserId($value)
|
|
* @mixin \Eloquent
|
|
*/
|
|
class UserPayCredit extends Model
|
|
{
|
|
|
|
public $statusType = [
|
|
1 => 'add from payment',
|
|
2 => 'deduction from payment',
|
|
3 => 'manually added credit',
|
|
4 => 'return from order',
|
|
5 => 'deduction from promotion',
|
|
6 => 'return from promotion',
|
|
7 => 'add credits from charging',
|
|
8 => 'remove credits from charging',
|
|
];
|
|
|
|
protected $table = 'user_pay_credits';
|
|
|
|
protected $casts = [
|
|
'user_id' => 'int',
|
|
'credit' => 'float',
|
|
'old_credit_total' => 'float',
|
|
'new_credit_total' => 'float',
|
|
'status' => 'int',
|
|
'shopping_order_id' => 'int'
|
|
];
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'credit',
|
|
'old_credit_total',
|
|
'new_credit_total',
|
|
'message',
|
|
'status',
|
|
'shopping_order_id'
|
|
];
|
|
|
|
public function shopping_order()
|
|
{
|
|
return $this->belongsTo(ShoppingOrder::class);
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo('App\User','user_id');
|
|
}
|
|
|
|
public function deleteTime(){
|
|
$time = '+30 min';
|
|
if(Carbon::parse($this->created_at)->modify($time)->gt(Carbon::now())){
|
|
return Carbon::now()->diffInMinutes(Carbon::parse($this->created_at)->modify($time));
|
|
}
|
|
return false;
|
|
}
|
|
/*getFormattedPriceFrom */
|
|
}
|