48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Modules\AdvancedPlanning\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class CapacityResource extends Model
|
|
{
|
|
use BelongsToBusiness;
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'ap_capacity_resources';
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected $casts = [
|
|
'daily_capacity_hours' => 'decimal:2',
|
|
'efficiency_pct' => 'decimal:2',
|
|
'is_active' => 'boolean',
|
|
];
|
|
|
|
public function lineTemplate()
|
|
{
|
|
return $this->belongsTo(\Modules\IndustrialEngineering\Models\LineTemplate::class, 'ie_line_template_id');
|
|
}
|
|
|
|
public function workCenter()
|
|
{
|
|
return $this->belongsTo(\Modules\IndustrialEngineering\Models\WorkCenter::class, 'ie_work_center_id');
|
|
}
|
|
|
|
public function maintenanceEquipment()
|
|
{
|
|
return $this->belongsTo(\Modules\Maintenance\Models\Equipment::class, 'maintenance_equipment_id');
|
|
}
|
|
|
|
public function scheduledOperations()
|
|
{
|
|
return $this->hasMany(ScheduledOperation::class, 'resource_id');
|
|
}
|
|
|
|
public function effectiveDailyHours(): float
|
|
{
|
|
return (float) $this->daily_capacity_hours * ((float) $this->efficiency_pct / 100);
|
|
}
|
|
}
|