reconstruction of the project

This commit is contained in:
root
2026-03-08 16:33:24 -04:00
parent 23b7db1107
commit c8de5f7edc
9157 changed files with 77877 additions and 1073823 deletions
+60 -3
View File
@@ -2,11 +2,15 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
class ExamDraft extends Model
class ExamDraft extends BaseModel
{
protected $table = 'exam_drafts';
// ✅ CI: useTimestamps = true (created_at/updated_at)
public $timestamps = true;
protected $fillable = [
'teacher_id',
'class_section_id',
@@ -29,5 +33,58 @@ class ExamDraft extends Model
'created_at',
'updated_at',
];
public $timestamps = true;
protected $casts = [
'teacher_id' => 'integer',
'class_section_id' => 'integer',
'admin_id' => 'integer',
'is_legacy' => 'boolean',
'version' => 'integer',
'previous_draft_id' => 'integer',
'reviewed_at' => 'datetime',
];
/**
* CI had updateOnlyChanged=false (force updates even if nothing changed).
* In Laravel, you can force a save by calling:
* $model->touch(); // updates updated_at only
* or
* $model->save(['timestamps' => true]); // normal save
*
* If you want a helper:
*/
public function forceSave(array $attributes = []): bool
{
if (!empty($attributes)) {
$this->fill($attributes);
}
// Force updated_at refresh even if no attributes changed
$this->updated_at = now();
return $this->save();
}
/* Optional relationships */
public function teacher()
{
return $this->belongsTo(User::class, 'teacher_id');
}
public function admin()
{
return $this->belongsTo(User::class, 'admin_id');
}
public function classSection()
{
return $this->belongsTo(ClassSection::class, 'class_section_id');
}
public function previousDraft()
{
return $this->belongsTo(self::class, 'previous_draft_id');
}
}