e9c10ae376
API CI/CD / Validate (composer + pint) (push) Failing after 1m11s
API CI/CD / Test (PHPUnit) (push) Failing after 2m30s
API CI/CD / Build frontend assets (push) Successful in 1m14s
API CI/CD / Security audit (push) Failing after 48s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
39 lines
765 B
PHP
39 lines
765 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
class LoginActivity extends BaseModel
|
|
{
|
|
protected $table = 'login_activity';
|
|
|
|
public $timestamps = true;
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'email',
|
|
'login_time',
|
|
'logout_time',
|
|
'ip_address',
|
|
'user_agent',
|
|
'school_year',
|
|
];
|
|
|
|
protected $casts = [
|
|
'user_id' => 'integer',
|
|
'login_time' => 'datetime',
|
|
'logout_time' => 'datetime',
|
|
];
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class, 'user_id');
|
|
}
|
|
|
|
public static function getLastActivities(int $limit = 4)
|
|
{
|
|
return static::query()
|
|
->orderByDesc('login_time')
|
|
->limit(max(1, $limit))
|
|
->get();
|
|
}
|
|
} |