66 lines
1.4 KiB
PHP
66 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Plant extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'code',
|
|
'company_id',
|
|
'name',
|
|
'address',
|
|
];
|
|
|
|
public function company(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Company::class);
|
|
}
|
|
|
|
public function blocks(): HasMany
|
|
{
|
|
return $this->hasMany(Block::class);
|
|
}
|
|
|
|
public function lines(): HasMany
|
|
{
|
|
return $this->hasMany(Line::class);
|
|
}
|
|
|
|
public function getLineNames()
|
|
{
|
|
return $this->hasMany(Line::class, 'plant_id', 'id'); // Ensure 'plant_id' is the foreign key in 'lines' table
|
|
}
|
|
|
|
public function items(): HasMany
|
|
{
|
|
return $this->hasMany(Item::class);
|
|
}
|
|
|
|
public function stickersMasters(): HasMany
|
|
{
|
|
return $this->hasMany(StickerMaster::class);
|
|
}
|
|
|
|
public function invoiceValidations()
|
|
{
|
|
return $this->hasMany(InvoiceValidation::class, 'sticker_master_id');
|
|
}
|
|
|
|
public function qualityValidations()
|
|
{
|
|
return $this->hasMany(QualityValidation::class, 'sticker_master_id');
|
|
}
|
|
|
|
public function testingPanelReadings()
|
|
{
|
|
return $this->hasMany(TestingPanelReading::class);
|
|
}
|
|
}
|