77 lines
1.5 KiB
PHP
77 lines
1.5 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
|
|
*/
|
|
class UserPayCredit extends Model
|
|
{
|
|
|
|
public $statusType = [
|
|
1 => 'add from payment',
|
|
2 => 'deduction from payment',
|
|
];
|
|
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 */
|
|
}
|