feat: add article and production modules
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
<?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 ?? '');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user