WorkerAutoliftOption.php 827 Bytes
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * @property int $employer_id
 * @property bool $autolift_site
 * @property int $times_per_day
 * @property int $days_repeat
 * @property string $time_send_first
 * @property string $time_send_second
 * @property string $time_send_third
 * @property bool $is_enabled
*/
class WorkerAutoliftOption extends Model
{
    protected $guarded = [
        'created_at',
        'updated_at'
    ];

    public function isEnabled(): Attribute
    {
        return Attribute::make(
            get: fn ($value) => $value === null ? 0 : 1
        );
    }

    public function worker(): BelongsTo
    {
        return $this->belongsTo(Worker::class);
    }
}