64 lines
1.3 KiB
PHP
64 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Model;
|
|
|
|
use Hyperf\Database\Model\Builder;
|
|
use Hyperf\DbConnection\Model\Model;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property string $dates
|
|
* @property string $create_time
|
|
*/
|
|
class Cycle extends Model
|
|
{
|
|
/**
|
|
* The table associated with the model.
|
|
*/
|
|
protected ?string $table = 'cycle';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected array $fillable = [];
|
|
|
|
protected array $guarded = [];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*/
|
|
protected array $casts = ['id' => 'integer'];
|
|
|
|
const string CREATED_AT = 'create_time';
|
|
const null UPDATED_AT = null;
|
|
|
|
/**
|
|
* @param string $date
|
|
* @return Builder|\Hyperf\Database\Model\Model|null
|
|
*/
|
|
public function getInfoByDate(string $date): \Hyperf\Database\Model\Model|Builder|null
|
|
{
|
|
return $this->where('dates',$date)->first();
|
|
}
|
|
|
|
/**
|
|
* @param int $id
|
|
* @return \Hyperf\Database\Model\Model|Builder|null
|
|
*/
|
|
public function getInfoById(int $id): \Hyperf\Database\Model\Model|Builder|null
|
|
{
|
|
return $this->where('id',$id)->first();
|
|
}
|
|
|
|
/**
|
|
* @param string $date
|
|
* @return int
|
|
*/
|
|
public function getIdByDate(string $date): int
|
|
{
|
|
return $this->where('dates',$date)->value('id') ?? 0;
|
|
}
|
|
}
|