<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class MRseaapprovalproduct extends Model
{
    protected $table = 'mr_sea_approval_products';
    
    protected $fillable = [
        'material_requisition_sea_id','product_id','qty','unit_id','grade_id','requested_month','schedule_id','mr_sea_product_id','deleted_at'
    ];
    public $timestamps = false;
    public function materialRequest()
    {
    	return $this->belongsTo('App\MaterialRequisitionSea','material_requisition_sea_id');
    }

    public function product()
    {
    	return $this->belongsTo('App\Product','product_id');
    }

    public function unit()
    {
    	return $this->belongsTo('App\UnitMeasurement','unit_id');
    }

    public function grade()
    {
    	return $this->belongsTo('App\GradeMaster','grade_id');
    }

    public function mrProduct()
    {
        return $this->belongsTo('App\MRseaproduct','mr_product_id');
    }

    public function palletData($product_id,$grd_id = NULL)
    {
        return Pallet::where('product_id','=',$product_id)->where('grade_id','=',$grd_id)->first();
    }
}
