48 lines
968 B
PHP
48 lines
968 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Model;
|
|
|
|
use Hyperf\DbConnection\Model\Model;
|
|
use Hyperf\Tappable\HigherOrderTapProxy;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property string $name
|
|
* @property int $image_id
|
|
* @property string $create_time
|
|
* @property string $update_time
|
|
*/
|
|
class Category extends Model
|
|
{
|
|
/**
|
|
* The table associated with the model.
|
|
*/
|
|
protected ?string $table = 'category';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected array $fillable = [];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*/
|
|
protected array $casts = ['id' => 'integer', 'image_id' => 'integer'];
|
|
|
|
const string CREATED_AT = 'create_time';
|
|
|
|
const string UPDATED_AT = 'update_time';
|
|
|
|
/**
|
|
* @param int $id
|
|
* @return HigherOrderTapProxy|mixed|null
|
|
*/
|
|
public function getNameById(int $id): mixed
|
|
{
|
|
return $this->where('id', $id)->value('name');
|
|
}
|
|
|
|
}
|