50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Models\Finance;
|
||
|
|
|
||
|
|
use App\Traits\BelongsToTenant;
|
||
|
|
use App\Traits\ModelTrait;
|
||
|
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||
|
|
|
||
|
|
class DailyWorkLog extends Model
|
||
|
|
{
|
||
|
|
use BelongsToTenant, ModelTrait, SoftDeletes;
|
||
|
|
|
||
|
|
protected $table = 'daily_work_logs';
|
||
|
|
|
||
|
|
protected $fillable = [
|
||
|
|
'tenant_id',
|
||
|
|
'log_date',
|
||
|
|
'memo',
|
||
|
|
'reflection',
|
||
|
|
'created_by',
|
||
|
|
'options',
|
||
|
|
];
|
||
|
|
|
||
|
|
protected $casts = [
|
||
|
|
'log_date' => 'date',
|
||
|
|
'options' => 'array',
|
||
|
|
];
|
||
|
|
|
||
|
|
public function items(): HasMany
|
||
|
|
{
|
||
|
|
return $this->hasMany(DailyWorkLogItem::class)->orderBy('sort_order');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getOption(string $key, mixed $default = null): mixed
|
||
|
|
{
|
||
|
|
return data_get($this->options, $key, $default);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function setOption(string $key, mixed $value): static
|
||
|
|
{
|
||
|
|
$options = $this->options ?? [];
|
||
|
|
data_set($options, $key, $value);
|
||
|
|
$this->options = $options;
|
||
|
|
|
||
|
|
return $this;
|
||
|
|
}
|
||
|
|
}
|