69 lines
2.0 KiB
PHP
69 lines
2.0 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models;
|
||
|
|
|
||
|
|
use App\Models\Commons\File;
|
||
|
|
use App\Traits\Auditable;
|
||
|
|
use App\Traits\BelongsToTenant;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||
|
|
|
||
|
|
class BendingModel extends Model
|
||
|
|
{
|
||
|
|
use Auditable, BelongsToTenant, SoftDeletes;
|
||
|
|
|
||
|
|
protected $table = 'bending_models';
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'tenant_id', 'model_type', 'code', 'name', 'legacy_code', 'legacy_num',
|
||
|
|
'model_name', 'model_UA', 'item_sep', 'finishing_type', 'author', 'remark',
|
||
|
|
'check_type', 'rail_width', 'rail_length',
|
||
|
|
'exit_direction', 'front_bottom_width', 'box_width', 'box_height',
|
||
|
|
'bar_width', 'bar_height',
|
||
|
|
'components', 'material_summary',
|
||
|
|
'search_keyword', 'registration_date', 'options',
|
||
|
|
'is_active', 'created_by', 'updated_by',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'components' => 'array',
|
||
|
|
'material_summary' => 'array',
|
||
|
|
'options' => 'array',
|
||
|
|
'is_active' => 'boolean',
|
||
|
|
'registration_date' => 'date',
|
||
|
|
'rail_width' => 'decimal:2',
|
||
|
|
'rail_length' => 'decimal:2',
|
||
|
|
'front_bottom_width' => 'decimal:2',
|
||
|
|
'box_width' => 'decimal:2',
|
||
|
|
'box_height' => 'decimal:2',
|
||
|
|
'bar_width' => 'decimal:2',
|
||
|
|
'bar_height' => 'decimal:2',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $hidden = ['deleted_at'];
|
||
|
|
|
||
|
|
public function files(): HasMany
|
||
|
|
{
|
||
|
|
return $this->hasMany(File::class, 'document_id')
|
||
|
|
->where('document_type', 'bending_model');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getOption(string $key, mixed $default = null): mixed
|
||
|
|
{
|
||
|
|
return data_get($this->options, $key, $default);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function setOption(string $key, mixed $value): self
|
||
|
|
{
|
||
|
|
$options = $this->options ?? [];
|
||
|
|
data_set($options, $key, $value);
|
||
|
|
$this->options = $options;
|
||
|
|
return $this;
|
||
|
|
}
|
||
|
|
|
||
|
|
public const TYPE_GUIDERAIL = 'GUIDERAIL_MODEL';
|
||
|
|
public const TYPE_SHUTTERBOX = 'SHUTTERBOX_MODEL';
|
||
|
|
public const TYPE_BOTTOMBAR = 'BOTTOMBAR_MODEL';
|
||
|
|
}
|