57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Model;
|
|
|
|
/**
|
|
* @property int $log_id
|
|
* @property int $crontab_id
|
|
* @property string $crontab_name
|
|
* @property string $callback
|
|
* @property string $duration
|
|
* @property int $status
|
|
* @property string $result
|
|
* @property string $create_time
|
|
* @property string $deleted_at
|
|
*/
|
|
class CrontabLog extends Model
|
|
{
|
|
/**
|
|
* The table associated with the model.
|
|
*/
|
|
protected ?string $table = 'crontab_log';
|
|
|
|
protected string $primaryKey = 'log_id';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected array $fillable = [];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*/
|
|
protected array $casts = ['log_id' => 'integer', 'crontab_id' => 'integer', 'status' => 'integer'];
|
|
|
|
public static function list(array $param)
|
|
{
|
|
return self::query()
|
|
->when(isset($param['crontab_id']), function ($query) use ($param) {
|
|
$query->where('crontab_id', $param['crontab_id']);
|
|
})
|
|
->select(['crontab_id', 'crontab_name', 'log_id', 'callback', 'duration', 'status', 'result', 'create_time'])
|
|
->orderByDesc('log_id')
|
|
->paginate((int)$param['limit']);
|
|
}
|
|
|
|
public static function removeAll($param)
|
|
{
|
|
return self::query()
|
|
->when(isset($param['crontab_id']), function ($query) use ($param) {
|
|
$query->where('crontab_id', $param['crontab_id']);
|
|
})
|
|
->delete();
|
|
}
|
|
}
|