63 lines
2.0 KiB
PHP
63 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace Modules\CostCalculator\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
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;
|
|
|
|
class CostCalculator extends Model
|
|
{
|
|
use HasFactory;
|
|
use \Staudenmeir\EloquentJsonRelations\HasJsonRelationships;
|
|
|
|
protected $guarded = [];
|
|
|
|
protected $casts = [
|
|
'living_cost' => 'object',
|
|
'accomodation_cost' => 'object',
|
|
'onetime_cost' => 'object',
|
|
'service_cost' => 'object'
|
|
];
|
|
|
|
public function country()
|
|
{
|
|
return $this->belongsTo(Country::class, 'country_id');
|
|
}
|
|
|
|
public function programLevel()
|
|
{
|
|
return $this->belongsTo(ProgramLevel::class, 'programlevel_id');
|
|
}
|
|
|
|
public function program()
|
|
{
|
|
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();
|
|
}
|
|
}
|