Migrate backend to Porto architecture and fix minor bugs
- Fully transitioned the backend to the Porto architectural pattern - Improved code organization and maintainability - Fixed minor bugs and inconsistencies
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Containers\Education\Models;
|
||||
|
||||
use App\Ship\Models\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
|
||||
class AdmissionCampaign extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = false;
|
||||
|
||||
protected $casts = [
|
||||
'info' => 'array'
|
||||
];
|
||||
|
||||
public function admission_plans(): HasMany
|
||||
{
|
||||
return $this->hasMany(AdmissionPlan::class, 'admission_campaigns_id', 'id');
|
||||
}
|
||||
|
||||
public function educationalPrograms(): HasManyThrough
|
||||
{
|
||||
return $this->hasManyThrough(
|
||||
EducationalProgram::class,
|
||||
AdmissionPlan::class,
|
||||
'admission_campaigns_id', // внешний ключ в AdmissionPlan
|
||||
'id', // внешний ключ в EducationalPrograms
|
||||
'id', // локальный ключ в AdmissionCampaign
|
||||
'educational_programs_id' // локальный ключ в AdmissionPlan
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user