server/app/Model/Crontab.php

63 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Model;
/**
* @property int $crontab_id
* @property string $crontab_name
* @property string $rule
* @property string $callback
* @property string $memo
* @property string $params
* @property int $enable
* @property int $singleton
* @property int $skip_log
* @property string $create_time
* @property string $update_time
* @property string $deleted_at
*/
class Crontab extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'crontab';
protected string $primaryKey = 'crontab_id';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = [];
/**
* The attributes that should be cast to native types.
*/
protected array $casts = ['crontab_id' => 'integer', 'enable' => 'integer', 'singleton' => 'integer', 'skip_log' => 'integer'];
public static function list(array $param)
{
return self::query()
->when(isset($param['enable']), function ($query) use ($param) {
$query->where('enable', $param['enable']);
})
->when(isset($param['crontab_name']), function ($query) use ($param) {
$query->where('crontab_name', 'like', '%' . $param['crontab_name'] . '%');
})
->select(['crontab_id', 'crontab_name', 'enable', 'singleton', 'skip_log', 'rule', 'callback', 'params', 'memo', 'create_time'])
->orderByDesc('crontab_id')
->paginate((int)$param['limit']);
}
public static function options()
{
return self::query()
->orderByDesc('crontab_id')
->orderByDesc('crontab_id')
->select(['crontab_id', 'crontab_name'])
->get();
}
}