<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class MaterialRequests extends Model
{
    protected $table = 'material_requests';

    protected $fillable = ['project_site_id','quotation_id','user_id','assigned_to','on_behalf_of','serial_no','format_id'];

    public function projectSite(){
        return $this->belongsTo('App\ProjectSite','project_site_id');
    }

    public function materialRequestComponents(){
        return $this->hasMany('App\MaterialRequestComponents','material_request_id');
    }

    public function onBehalfOf(){
        return $this->belongsTo('App\User','on_behalf_of');
    }

    public function assignedToUser(){
        return $this->belongsTo('App\User','assigned_to');
    }

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

    public function quotation(){
        return $this->belongsTo('App\Quotation','quotation_id');
    }
}

{'avg_line_length': 25.10810810810811, 'max_line_length': 124, 'alphanum_fraction': 0.6727664155005382, 'licenses': ['MIT'], 'repository_name': 'woxiprogrammers/mco', 'path': 'app/MaterialRequests.php', 'size': 929, 'lang': 'PHP'}