catchAdmin/modules/User/Models/LogLogin.php

41 lines
1.0 KiB
PHP
Raw Normal View History

2022-12-05 23:01:12 +08:00
<?php
namespace Modules\User\Models;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Model;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class LogLogin extends Model
{
protected $table = 'log_login';
public $timestamps = false;
protected $fillable = [
'id', 'account', 'login_ip', 'browser', 'platform', 'login_at', 'status',
];
protected $casts = [
'login_at' => 'datetime:Y-m-d H:i'
];
/**
*
2022-12-23 19:47:13 +08:00
* @param ?string $email
2022-12-05 23:01:12 +08:00
* @return LengthAwarePaginator
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
2022-12-23 19:47:13 +08:00
public function getUserLogBy(?string $email): LengthAwarePaginator
2022-12-05 23:01:12 +08:00
{
2022-12-23 19:47:13 +08:00
return static::when($email, function ($query) use ($email){
$query->where('account', $email);
2023-01-02 18:36:22 +08:00
})
->orderByDesc('id')
->paginate(request()->get('limit', 10));
2022-12-05 23:01:12 +08:00
}
}