You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.1 KiB
48 lines
1.1 KiB
<?php |
|
|
|
namespace App\Models; |
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory; |
|
use Illuminate\Database\Eloquent\Model; |
|
use Illuminate\Support\Facades\Cache; |
|
|
|
class UserLog extends Model |
|
{ |
|
use HasFactory; |
|
|
|
protected $table = 'user_log'; |
|
|
|
protected $fillable = [ |
|
'user_id', |
|
'user_name', |
|
'action', |
|
'action_detail', |
|
'ip', |
|
'mac', |
|
'remark', |
|
'carnumber', |
|
'location', |
|
]; |
|
|
|
// protected $casts = [ |
|
// 'created_at' => 'datetime:Y-m-d H:i:s', |
|
// ]; |
|
public static function cachedDistinctActionDetail() |
|
{ |
|
return Cache::remember('user_log_distinct_action_detail', 3600, function () { |
|
return self::select('action_detail')->distinct()->get(); |
|
}); |
|
} |
|
//cachedDistinctUser |
|
public static function cachedDistinctUser() |
|
{ |
|
return Cache::remember('user_log_distinct_user', 3600, function () { |
|
return self::select('user_name')->distinct()->get(); |
|
}); |
|
} |
|
public function user() |
|
{ |
|
return $this->belongsTo(User::class); |
|
} |
|
|
|
}
|
|
|