<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Customer extends Model
{

    protected $table = 'customers';
    
    protected $fillable = [
        'name', 'shop_no', 'address','location','mobileno','email_id','contact_person','office_no','industry_type','credit_limit','credit_period','customer_type_id','status','delivery_type_id','customercode','mode_detail_id','parent_master_id','product_last_update','product_link'
    ];

    public function user()
    {
        return $this->hasOne('App\User');
    }

    public function type()
    {
    	return $this->belongsTo('App\CustomerType','customer_type_id');
    }

    public function common()
    {
    	return $this->belongsTo('App\Common','status');
    }

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

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

    public function delivery()
    {
        return $this->belongsTo('App\Common','delivery_type_id');
    }
}
