e13df69885
API CI/CD / Validate (composer + pint) (push) Successful in 3m6s
API CI/CD / Test (PHPUnit) (push) Failing after 4m53s
API CI/CD / Build frontend assets (push) Successful in 1m2s
API CI/CD / Security audit (push) Failing after 59s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
37 lines
903 B
PHP
37 lines
903 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
class LoginActivity extends BaseModel
|
|
{
|
|
protected $table = 'login_activity';
|
|
|
|
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
|
public $timestamps = true;
|
|
|
|
protected $fillable = ['user_id', 'email', 'login_time', 'logout_time', 'ip_address', 'user_agent', 'created_at', 'updated_at', 'semester', 'school_year'];
|
|
|
|
protected $casts = [
|
|
'user_id' => 'integer',
|
|
'login_time' => 'datetime',
|
|
'logout_time' => 'datetime',
|
|
];
|
|
|
|
/* Optional relationship */
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class, 'user_id');
|
|
}
|
|
|
|
/**
|
|
* Equivalent of legacy getLastActivities()
|
|
*/
|
|
public static function getLastActivities(int $limit = 4)
|
|
{
|
|
return static::query()
|
|
->orderByDesc('login_time')
|
|
->limit(max(1, $limit))
|
|
->get();
|
|
}
|
|
}
|