Refactor navigation icon declarations in various resources for consistency; enhance Group model with new relationships and fillable properties; update Hotel and Pilgrim models with fillable attributes; improve table configurations across resources.
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
/**
|
||||
* @property date $start_date
|
||||
@@ -20,7 +21,12 @@ class Group extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'leader_teacher_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
@@ -28,23 +34,17 @@ class Group extends Model
|
||||
'end_date' => 'date',
|
||||
];
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the name of the group
|
||||
*
|
||||
* @return Attribute
|
||||
* */
|
||||
*
|
||||
* */
|
||||
public function name(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => $this->start_date->format('d M') . ' - ' . $this->end_date->format('d M'),
|
||||
get: fn ($value) => $this->start_date->format('d M').' - '.$this->end_date->format('d M'),
|
||||
);
|
||||
}
|
||||
|
||||
public function pilgrims(): HasMany
|
||||
{
|
||||
return $this->hasMany(Pilgrim::class);
|
||||
}
|
||||
|
||||
public function leaderTeacher(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Teacher::class, 'leader_teacher_id');
|
||||
@@ -54,4 +54,19 @@ class Group extends Model
|
||||
{
|
||||
return $this->belongsToMany(Teacher::class, 'group_teacher');
|
||||
}
|
||||
|
||||
public function teachers(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Teacher::class, 'group_teacher');
|
||||
}
|
||||
|
||||
public function pilgrims(): HasMany
|
||||
{
|
||||
return $this->hasMany(Pilgrim::class, 'group_id');
|
||||
}
|
||||
|
||||
public function program(): HasOne
|
||||
{
|
||||
return $this->hasOne(Program::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user