<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

use App\Traits\ModelLogChanging;

class StationTaskMaterialBox extends Model
{
    use ModelLogChanging;

    protected $fillable=['station_id','material_box_id','status'];

    function materialBox(): HasOne
    {
        return $this->hasOne(MaterialBox::class,"id","material_box_id");
    }
    function station(): BelongsTo
    {
        return $this->belongsTo(Station::class);
    }
    function stationTaskBatch(): BelongsTo
    {
        return $this->belongsTo(StationTaskBatch::class);
    }
    function stationTask(): BelongsTo
    {
        return $this->belongsTo(StationTask::class);
    }
    function stationTaskCommodities(): HasMany
    {
        return $this->hasMany(StationTaskCommodity::class,'station_task_batch_id','station_task_batch_id')
            ->where('material_box_id',$this['material_box_id']);
    }
}
