reconstruction of the project
This commit is contained in:
@@ -2,13 +2,19 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\BaseModel;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Competition extends Model
|
||||
class Competition extends BaseModel
|
||||
{
|
||||
use SoftDeletes;
|
||||
protected $table = 'competitions';
|
||||
|
||||
// ✅ CI: useSoftDeletes = true
|
||||
use SoftDeletes;
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at) + deleted_at for soft deletes
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'semester',
|
||||
@@ -28,5 +34,43 @@ class Competition extends Model
|
||||
'locked_at',
|
||||
'locked_by',
|
||||
];
|
||||
public $timestamps = true;
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user