99 lines
2.4 KiB
PHP
99 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace Modules\CourseFinder\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
use Modules\CCMS\Models\Institution;
|
|
use Modules\CCMS\Models\Test;
|
|
|
|
class Program extends Model
|
|
{
|
|
use HasFactory;
|
|
use \Staudenmeir\EloquentJsonRelations\HasJsonRelationships;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected $fillable = [
|
|
'title',
|
|
'slug',
|
|
'code',
|
|
'description',
|
|
'institution_id',
|
|
'programlevel_id',
|
|
'coop_id',
|
|
'year',
|
|
'psw',
|
|
'prospects',
|
|
'intakes',
|
|
'required_documents',
|
|
'application_open',
|
|
'application_deadline',
|
|
'fee',
|
|
'scholarship',
|
|
'level',
|
|
'program_url',
|
|
'fee_breakdown',
|
|
'course_module',
|
|
'quick_info',
|
|
'academic_module',
|
|
'additional_module',
|
|
'application_module',
|
|
'status',
|
|
'remarks',
|
|
'createdby',
|
|
'updatedby',
|
|
];
|
|
|
|
|
|
public const INTAKE = [
|
|
1 => 'January',
|
|
2 => 'February',
|
|
3 => 'March',
|
|
4 => 'April',
|
|
5 => 'May',
|
|
6 => 'June',
|
|
7 => 'July',
|
|
8 => 'August',
|
|
9 => 'September',
|
|
10 => 'October',
|
|
11 => 'November',
|
|
12 => 'December',
|
|
];
|
|
|
|
protected $casts = [
|
|
'intakes' => 'array',
|
|
'required_documents' => 'json',
|
|
'prof_test_accepted' => 'object',
|
|
'level' => 'object',
|
|
'fee_breakdown' => 'object',
|
|
'course_module' => 'object',
|
|
'quick_info' => 'object',
|
|
'academic_module' => 'object',
|
|
'additional_module' => 'object',
|
|
'application_module' => 'object',
|
|
];
|
|
|
|
public function institution()
|
|
{
|
|
return $this->belongsTo(Institution::class, 'institution_id');
|
|
}
|
|
|
|
public function programLevel()
|
|
{
|
|
return $this->belongsTo(ProgramLevel::class, 'programlevel_id');
|
|
}
|
|
|
|
public function tests(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Test::class, 'programs_tests', 'program_id', 'test_id')->withPivot('id', 'min_score', 'band_score')->withTimestamps();
|
|
}
|
|
|
|
public function requiredDocuments()
|
|
{
|
|
return $this->belongsToJson(RequiredDocument::class, 'required_documents');
|
|
}
|
|
}
|