reconstruction of the project
This commit is contained in:
@@ -7,8 +7,10 @@ use App\Models\BaseModel;
|
||||
class AttendanceCommentTemplate extends BaseModel
|
||||
{
|
||||
protected $table = 'attendance_comment_template';
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
// CI: useTimestamps = false
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
'min_score',
|
||||
'max_score',
|
||||
@@ -18,10 +20,27 @@ class AttendanceCommentTemplate extends BaseModel
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
public function getActiveTemplates(): array
|
||||
protected $casts = [
|
||||
'min_score' => 'integer',
|
||||
'max_score' => 'integer',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
/**
|
||||
* Equivalent of CI getActiveTemplates():
|
||||
* is_active=1, order by min_score DESC
|
||||
*/
|
||||
public static function getActiveTemplates()
|
||||
{
|
||||
return $this->where('is_active', 1)
|
||||
->orderBy('min_score', 'DESC')
|
||||
->findAll();
|
||||
return static::query()
|
||||
->where('is_active', 1)
|
||||
->orderByDesc('min_score')
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
||||
// Optional: nice query scope version
|
||||
public function scopeActive($q)
|
||||
{
|
||||
return $q->where('is_active', 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user