68 lines
1.5 KiB
PHP
68 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Modules\Task\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class TaskOrderModel extends Model
|
|
{
|
|
protected $table = 'task_orders';
|
|
|
|
protected $fillable = [
|
|
'order_no',
|
|
'user_id',
|
|
'runner_id',
|
|
'category_id',
|
|
'title',
|
|
'description',
|
|
'images',
|
|
'extra',
|
|
'price',
|
|
'address',
|
|
'contact_name',
|
|
'contact_mobile',
|
|
'deadline',
|
|
'pay_type',
|
|
'pay_status',
|
|
'paid_at',
|
|
'status',
|
|
'cancel_reason',
|
|
'remark',
|
|
'accepted_at',
|
|
'completed_at',
|
|
'cancelled_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'images' => 'array',
|
|
'extra' => 'array',
|
|
'price' => 'decimal:2',
|
|
'pay_type' => 'integer',
|
|
'pay_status' => 'integer',
|
|
'status' => 'integer',
|
|
'user_id' => 'integer',
|
|
'runner_id' => 'integer',
|
|
'category_id' => 'integer',
|
|
'deadline' => 'datetime',
|
|
'paid_at' => 'datetime',
|
|
'accepted_at' => 'datetime',
|
|
'completed_at' => 'datetime',
|
|
'cancelled_at' => 'datetime',
|
|
];
|
|
|
|
protected $with = ['category'];
|
|
|
|
protected $appends = ['category_slug'];
|
|
|
|
public function category(): BelongsTo
|
|
{
|
|
return $this->belongsTo(TaskCategoryModel::class, 'category_id');
|
|
}
|
|
|
|
public function getCategorySlugAttribute(): ?string
|
|
{
|
|
return $this->category?->slug;
|
|
}
|
|
}
|