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
+49 -10
View File
@@ -2,11 +2,15 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\BaseModel;
class GradingLock extends Model
class GradingLock extends BaseModel
{
protected $table = 'grading_locks';
// ✅ CI: useTimestamps = true
public $timestamps = true;
protected $fillable = [
'class_section_id',
'semester',
@@ -17,13 +21,48 @@ class GradingLock extends Model
'created_at',
'updated_at',
];
public $timestamps = true;
/**
* TODO: Manual port review required for custom CI query methods from GradingLock.
* - getLock()
* - isLocked()
*
* This automated conversion preserves schema metadata only.
*/
protected $casts = [
'class_section_id' => 'integer',
'is_locked' => 'boolean',
'locked_by' => 'integer',
'locked_at' => 'datetime',
];
/* Optional relationships */
public function classSection()
{
return $this->belongsTo(ClassSection::class, 'class_section_id');
}
public function lockedByUser()
{
return $this->belongsTo(User::class, 'locked_by');
}
/**
* Equivalent of CI getLock()
*/
public static function getLock(int $classSectionId, string $semester, string $schoolYear): ?self
{
if ($classSectionId <= 0 || $semester === '' || $schoolYear === '') {
return null;
}
return static::query()
->where('class_section_id', $classSectionId)
->where('semester', $semester)
->where('school_year', $schoolYear)
->orderByDesc('id')
->first();
}
/**
* Equivalent of CI isLocked()
*/
public static function isLocked(int $classSectionId, string $semester, string $schoolYear): bool
{
$row = static::getLock($classSectionId, $semester, $schoolYear);
return (bool) ($row?->is_locked ?? false);
}
}