You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.2 KiB
54 lines
1.2 KiB
|
1 week ago
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||
|
|
|
||
|
|
class Demand extends Model
|
||
|
|
{
|
||
|
|
use SoftDeletes;
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'teacher_id',
|
||
|
|
'type_dict_item_id',
|
||
|
|
'status_dict_item_id',
|
||
|
|
'title',
|
||
|
|
'content',
|
||
|
|
'contact_name',
|
||
|
|
'company',
|
||
|
|
'submitted_at',
|
||
|
|
'miniapp_user_id',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'teacher_id' => 'integer',
|
||
|
|
'type_dict_item_id' => 'integer',
|
||
|
|
'status_dict_item_id' => 'integer',
|
||
|
|
'submitted_at' => 'datetime',
|
||
|
|
'miniapp_user_id' => 'integer',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function teacher(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(Teacher::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function typeItem(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(DictItem::class, 'type_dict_item_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function statusItem(): BelongsTo
|
||
|
|
{
|
||
|
|
return $this->belongsTo(DictItem::class, 'status_dict_item_id');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function handleLogs(): HasMany
|
||
|
|
{
|
||
|
|
return $this->hasMany(DemandHandleLog::class)->orderByDesc('handled_at')->orderByDesc('id');
|
||
|
|
}
|
||
|
|
}
|