feat: Enhance Cost Calculator with StayType integration and cost management features
This commit is contained in:
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Modules\CCMS\Models\Country;
|
||||
use Modules\CourseFinder\Models\Program;
|
||||
use Modules\CourseFinder\Models\ProgramLevel;
|
||||
use Modules\CostCalculator\Models\StayType;
|
||||
|
||||
// use Modules\CostCalculator\Database\Factories\CostCalculatorFactory;
|
||||
|
||||
@@ -15,19 +16,16 @@ class CostCalculator extends Model
|
||||
use HasFactory;
|
||||
use \Staudenmeir\EloquentJsonRelations\HasJsonRelationships;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected $guarded = [];
|
||||
|
||||
protected $casts = [
|
||||
'living_cost' => 'object',
|
||||
'accomodation_cost' => 'object',
|
||||
'onetime_cost' => 'object',
|
||||
'other_services' => 'object',
|
||||
'service_cost' => 'object'
|
||||
];
|
||||
|
||||
public function institution()
|
||||
public function country()
|
||||
{
|
||||
return $this->belongsTo(Country::class, 'country_id');
|
||||
}
|
||||
@@ -41,4 +39,24 @@ class CostCalculator extends Model
|
||||
{
|
||||
return $this->belongsTo(Program::class, 'program_id');
|
||||
}
|
||||
|
||||
public function stayTypeLiving(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(StayType::class, 'living_costs', 'cost_calculator_id', 'stay_type_id')->withPivot('id', 'monthly', 'yearly')->withTimestamps();
|
||||
}
|
||||
|
||||
public function stayTypeAccomodation(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(StayType::class, 'accomodation_costs', 'cost_calculator_id', 'stay_type_id')->withPivot('id', 'monthly', 'yearly')->withTimestamps();
|
||||
}
|
||||
|
||||
public function stayTypeOnetime(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(StayType::class, 'onetime_costs', 'cost_calculator_id', 'stay_type_id')->withPivot('id', 'visa', 'biometrics', 'sevis', 'application')->withTimestamps();
|
||||
}
|
||||
|
||||
public function stayTypeService(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(StayType::class, 'service_costs', 'cost_calculator_id', 'stay_type_id')->withPivot('id', 'flight_ticket', 'insurance', 'extra')->withTimestamps();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user