<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

use App\Traits\ModelLogChanging;

class StationTask extends Model
{
    use ModelLogChanging;

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

    public function tasks()
    {
        return $this->morphTo();
    }

    public function stationTaskCommodities()
    {   //任务商品列表
        return $this->morphToMany(
            StationTaskCommodity::class,
            'station_taskable',
            'station_task_children',
            'station_task_id',
            'station_taskable_id',
            'id',
            'id',
            true);
    }
    public function stationTaskBatches()
    {   //任务波次 目前为单个，取值时应取第一个即可
        return $this->morphToMany(
            StationTaskBatch::class,
            'station_taskable',
            'station_task_children',
            'station_task_id',
            'station_taskable_id',
            'id',
            'id',
            true);
    }
    public function stationTaskMaterialBoxes()
    {   //任务料箱
        return $this->morphToMany(
            StationTaskMaterialBox::class,
            'station_taskable',
            'station_task_children',
            'station_task_id',
            'station_taskable_id',
            'id',
            'id',
        true);
    }
}
