39 lines
772 B
PHP
39 lines
772 B
PHP
<?php
|
|||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace plugin\produce\app\model;
|
||
|
|
|
||
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||
|
|
|
||
|
|
class MaterialCategory extends BaseModel
|
||
|
|
{
|
||
|
|
protected $table = 'produce_material_category';
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'id',
|
||
|
|
'category_name',
|
||
|
|
'created_by',
|
||
|
|
'updated_by',
|
||
|
|
'created_at',
|
||
|
|
'updated_at',
|
||
|
|
'deleted_at',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'created_at' => 'integer',
|
||
|
|
'updated_at' => 'integer',
|
||
|
|
'deleted_at' => 'integer',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function getNameAttribute(): string
|
||
|
|
{
|
||
|
|
return (string) $this->category_name;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function materials(): HasMany
|
||
|
|
{
|
||
|
|
return $this->hasMany(Material::class, 'category_id', 'id');
|
||
|
|
}
|
||
|
|
}
|