This commit is contained in:
parent
de52eefadc
commit
5b0d8b1ee5
@ -7,9 +7,9 @@ use Illuminate\Database\Eloquent\Model;
|
|||||||
class City extends Model
|
class City extends Model
|
||||||
{
|
{
|
||||||
protected $table = 'city';
|
protected $table = 'city';
|
||||||
public $timestamps = true;
|
protected $primaryKey = 'city_id';
|
||||||
|
protected $keyType = 'int';
|
||||||
protected $primaryKey = 'city_id';
|
public $incrementing = true;
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'city_id',
|
'city_id',
|
||||||
'city_name',
|
'city_name',
|
||||||
@ -23,12 +23,14 @@ class City extends Model
|
|||||||
/**
|
/**
|
||||||
* 都市のリストを取得
|
* 都市のリストを取得
|
||||||
*/
|
*/
|
||||||
public static function getList()
|
public static function getList(?int $operatorId = null): array
|
||||||
{
|
{
|
||||||
return self::all();
|
return static::query()
|
||||||
|
->when($operatorId, fn ($q) => $q->where('operator_id', $operatorId))
|
||||||
|
->orderBy('city_name')
|
||||||
|
->pluck('city_name', 'city_id')
|
||||||
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user