Files
hyperf_service/app/Model/Spu.php
2025-01-07 17:55:58 +08:00

67 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Model;
use App\Constants\Common\GoodCode;
use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Model\Model;
/**
* @property int $id
* @property int $cycle_id
* @property int $city_id
* @property int $kitchen_id
* @property int $chef_id
* @property string $title
* @property string $sub_title
* @property int $category_id
* @property int $saleable
* @property int $is_del
* @property string $create_time
* @property string $update_time
*/
class Spu extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'spu';
/**
* 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', 'cycle_id' => 'integer', 'city_id' => 'integer', 'kitchen_id' => 'integer','chef_id' => 'integer', 'category_id' => 'integer', 'saleable' => 'integer'];
const string CREATED_AT = 'create_time';
const string UPDATED_AT = 'update_time';
/**
* @param int $cityId
* @param int $cycleId
* @param string $title
* @return Builder|\Hyperf\Database\Model\Model|null
*/
public function getInfoByCityIdAndCycleId(int $cityId, int $cycleId,string $title): \Hyperf\Database\Model\Model|Builder|null
{
return $this->where('city_id', $cityId)->where('cycle_id', $cycleId)->where('title',$title)->where('is_del',GoodCode::SPU_IS_NO_DEL)->first();
}
/**
* @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)->where('is_del',GoodCode::SPU_IS_NO_DEL)->first();
}
}