feat : city

This commit is contained in:
2024-10-31 16:30:29 +08:00
parent 39b5df9f0a
commit ceeeea7c34
9 changed files with 534 additions and 0 deletions

61
app/Model/SystemCity.php Normal file
View File

@@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
namespace App\Model;
use App\Constants\Common\CityCode;
use Hyperf\Database\Model\Builder;
use Hyperf\DbConnection\Model\Model;
/**
* @property int $id
* @property string $title
* @property int $status
* @property int $city_id
* @property int $province_id
* @property string $create_time
* @property string $update_time
* @property int $is_del
*/
class SystemCity extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'system_city';
/**
* 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', 'status' => 'integer', 'city_id' => 'integer', 'province_id' => 'integer', 'is_del' => 'integer'];
const CREATED_AT = 'create_time';
const UPDATED_AT = 'update_time';
/**
* @param int $cityId
* @return Builder|\Hyperf\Database\Model\Model|null
*/
public function getInfoByCityId(int $cityId): \Hyperf\Database\Model\Model|Builder|null
{
return $this->where('city_id', $cityId)->where('is_del',CityCode::IS_NOT_DELETE)->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',CityCode::IS_NOT_DELETE)->first();
}
}