40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace plugin\produce\app\model;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use plugin\produce\app\model\BaseModel;
|
|
use plugin\produce\app\model\MaterialCategory;
|
|
|
|
class HardwareFaultDescription extends BaseModel
|
|
{
|
|
protected $table = 'produce_hardware_fault_description';
|
|
|
|
protected $appends = ['created_date', 'updated_date', 'category_name'];
|
|
|
|
protected $fillable = [
|
|
'id', 'category_id', 'description', 'use_count', 'is_enabled', 'remark',
|
|
'created_by', 'updated_by', 'created_at', 'updated_at', 'deleted_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'use_count' => 'integer',
|
|
'is_enabled' => 'integer',
|
|
'created_at' => 'integer',
|
|
'updated_at' => 'integer',
|
|
'deleted_at' => 'integer',
|
|
];
|
|
|
|
public function category(): BelongsTo
|
|
{
|
|
return $this->belongsTo(MaterialCategory::class, 'category_id', 'id')->withTrashed();
|
|
}
|
|
|
|
public function getCategoryNameAttribute(): string
|
|
{
|
|
return (string) ($this->category?->category_name ?? '');
|
|
}
|
|
}
|