ispt4.0_laravel/app/Models/CompanyProject.php

35 lines
1016 B
PHP
Executable File

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class CompanyProject extends Model
{
use HasFactory;
protected $table = 'company_projects';
protected $primaryKey = 'company_projects_id';
protected $fillable = ['company_projects_id', 'plant_id', 'project_company_name','project_ispt_number','company_project_description','project_ispt_responsible','project_company_responsible','date_started','end_date','order_project'];
public $timestamps = false;
public function plant(){
// return $this->hasMany(Plant::class,'plant_id', 'plant_id');
return $this->belongsTo(Plant::class,'plant_id', 'plant_id');
}
public function company(){
return $this->hasOneThrough(Company::class, Plant::class, 'plant_id', 'user_id');
}
public function EquipmentWorkHistory(){
return $this->hasMany(EquipmentWorkHistory::class, 'company_projects_id','company_projects_id');
}
}