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
+24 -12
View File
@@ -7,7 +7,10 @@ use App\Models\BaseModel;
class LoginActivity extends BaseModel
{
protected $table = 'login_activity';
protected $primaryKey = 'id';
// ✅ CI: useTimestamps = true (created_at/updated_at)
public $timestamps = true;
protected $fillable = [
'user_id',
'email',
@@ -20,18 +23,27 @@ class LoginActivity extends BaseModel
'semester',
'school_year',
];
public $timestamps = true;
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
public function getLastActivities($limit = 4)
protected $casts = [
'user_id' => 'integer',
'login_time' => 'datetime',
'logout_time' => 'datetime',
];
/* Optional relationship */
public function user()
{
return $this->orderBy('login_time', 'DESC')->findAll($limit);
return $this->belongsTo(User::class, 'user_id');
}
}
?>
/**
* Equivalent of CI getLastActivities()
*/
public static function getLastActivities(int $limit = 4)
{
return static::query()
->orderByDesc('login_time')
->limit(max(1, $limit))
->get();
}
}