70 lines
1.7 KiB
PHP
70 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Model;
|
|
|
|
use App\Constants\Admin\UserCode;
|
|
use Hyperf\Database\Model\Builder;
|
|
use Hyperf\DbConnection\Model\Model;
|
|
use Hyperf\Tappable\HigherOrderTapProxy;
|
|
|
|
/**
|
|
* @property int $id
|
|
* @property int $user_id
|
|
* @property string $profile
|
|
* @property string $specialties
|
|
* @property int $is_del
|
|
* @property string $create_time
|
|
* @property string $update_time
|
|
*/
|
|
class Chef extends Model
|
|
{
|
|
/**
|
|
* The table associated with the model.
|
|
*/
|
|
protected ?string $table = 'chef';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*/
|
|
protected array $fillable = [];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*/
|
|
protected array $casts = ['id' => 'integer', 'user_id' => 'integer', 'is_del' => 'integer'];
|
|
|
|
const string CREATED_AT = 'create_time';
|
|
|
|
const string UPDATED_AT = 'update_time';
|
|
|
|
/**
|
|
* @param int $id
|
|
* @return Builder|\Hyperf\Database\Model\Model|null
|
|
*/
|
|
public function getInfoById(int $id): \Hyperf\Database\Model\Model|Builder|null
|
|
{
|
|
return $this->where('id', $id)->first();
|
|
}
|
|
|
|
/**
|
|
* @param int $userId
|
|
* @return Builder|\Hyperf\Database\Model\Model|null
|
|
*/
|
|
public function getInfoByUserId(int $userId): \Hyperf\Database\Model\Model|Builder|null
|
|
{
|
|
return $this->where('is_del',UserCode::IS_NO_DEL)->where('user_id', $userId)->first();
|
|
}
|
|
|
|
/**
|
|
* @param int $id
|
|
* @return HigherOrderTapProxy|mixed|null
|
|
*/
|
|
public function getChineseNameById(int $id): mixed
|
|
{
|
|
return $this->leftJoin('admin_user', 'admin_user.id', '=', 'chef.user_id')->where('admin_user.id', $id)->value('admin.chinese_name');
|
|
}
|
|
|
|
}
|