<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{

    protected $table = 'products';

    public $timestamps = false;
    
    protected $fillable = [
        'category_id','group_master_id','sub_group_id','name','code','base_unit_id','alias','is_active','country_id','remarks','secondry_name','tax','hsn_code_id'
    ];

    public function productUnits()
    {
        return $this->hasMany('App\ProductUnit','product_id');
    }

    public function productGrades()
    {
        return $this->hasMany('App\ProductGrade', 'product_id');
    }
    public function productTags()
    {
    	return $this->hasMany('App\ProductTag', 'product_id');
    }

    public function productSuppliers()
    {
        return $this->hasMany('App\SupplierProduct', 'product_id');
    }

    public function productCustomers()
    {
        return $this->hasMany('App\CustomerProduct','product_id');
    }

    public function productCategory()
    {
        return $this->belongsTo('App\CategoryMaster','category_id');
    }

    public function mrProducts()
    {
        return $this->hasMany('App\MRproduct');
    }

    public function mrApproval()
    {
        return $this->hasMany('App\MRapprovalproduct');
    }

    public function productNotification()
    {
        return $this->hasMany('App\ProductNotification');
    }

    public function prProduct()
    {
        return $this->hasMany('App\PRproduct');
    }

    public function rate()
    {
        return $this->hasMany('App\SupplierRateEntry');
    }

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

    public function productStd()
    {
        return $this->hasMany('App\ProductStandard','product_id');
    }

    public function pdtGroup()
    {
       return $this->belongsTo('App\GroupMaster','group_master_id'); 
    }
    public function pdtsubGroup()
    {
       return $this->belongsTo('App\SubGroup','sub_group_id'); 
    }

    public function productLocation()
    {
        return $this->hasMany('App\LocationProduct','product_id');
    }
}
