41 lines
862 B
PHP
41 lines
862 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Store\Store;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class OfflineOrderPreview extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $casts = [
|
|
'payload' => 'json',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'store_id', 'staff_id', 'payload', 'qrcode', 'remark', 'user_id', 'coupon_id'
|
|
];
|
|
|
|
public function store()
|
|
{
|
|
return $this->belongsTo(Store::class);
|
|
}
|
|
|
|
public function coupon()
|
|
{
|
|
return $this->belongsTo(UserCoupon::class);
|
|
}
|
|
|
|
public function order()
|
|
{
|
|
return $this->morphOne(OfflineOrder::class, 'orderable')->orderBy('created_at', 'desc');
|
|
}
|
|
|
|
public function orders()
|
|
{
|
|
return $this->morphMany(OfflineOrder::class, 'orderable')->orderBy('created_at', 'desc');
|
|
}
|
|
}
|