Files
alrahma_sunday_school_api/app/Models/Competition.php
T
root e13df69885
API CI/CD / Validate (composer + pint) (push) Successful in 3m6s
API CI/CD / Test (PHPUnit) (push) Failing after 4m53s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 59s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
fix unittests issues
2026-07-07 20:56:32 -04:00

58 lines
1.6 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\SoftDeletes;
class Competition extends BaseModel
{
protected $table = 'competitions';
// ✅ legacy: useSoftDeletes = true
use SoftDeletes;
// ✅ legacy: useTimestamps = true (created_at/updated_at) + deleted_at for soft deletes
public $timestamps = true;
protected $fillable = ['title', 'semester', 'school_year', 'class_section_id', 'start_date', 'end_date', 'winners_count', 'prize_per_point', 'is_published', 'published_at', 'created_by', 'created_at', 'updated_at', 'deleted_at', 'is_locked', 'locked_at', 'locked_by'];
protected $casts = [
'class_section_id' => 'integer',
'winners_count' => 'integer',
'prize_per_point' => 'decimal:2', // adjust precision if needed
'is_published' => 'boolean',
'is_locked' => 'boolean',
// change to 'date' if your columns are DATE (not DATETIME)
'start_date' => 'date',
'end_date' => 'date',
'published_at' => 'datetime',
'locked_at' => 'datetime',
'locked_by' => 'integer',
'created_by' => 'integer',
];
/* Optional relationships */
public function classSection()
{
return $this->belongsTo(ClassSection::class, 'class_section_id');
}
public function lockedByUser()
{
return $this->belongsTo(User::class, 'locked_by');
}
public function createdByUser()
{
return $this->belongsTo(User::class, 'created_by');
}
public function classWinners()
{
return $this->hasMany(CompetitionClassWinner::class, 'competition_id');
}
}