All checks were successful
Deploy preview (main_kin) / deploy (push) Successful in 12s
144 lines
5.4 KiB
PHP
144 lines
5.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Utils;
|
|
use App\Models\City;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class Park extends Model
|
|
{
|
|
const CREATED_AT = 'created_at';
|
|
const UPDATED_AT = 'updated_at';
|
|
|
|
protected $table = 'park';
|
|
protected $primaryKey = 'park_id';
|
|
|
|
protected $fillable = [
|
|
'park_id', // 駐輪場ID
|
|
'city_id', // 市区
|
|
'park_name', // 駐輪場名
|
|
'park_ruby', // 駐輪場ふりがな
|
|
'park_syllabary', // 駐輪場五十音
|
|
'park_adrs', // 住所
|
|
'park_close_flag', // 閉設フラグ
|
|
'park_day', // 閉設日
|
|
'price_memo', // 価格メモ
|
|
'alert_flag', // 残警告チェックフラグ
|
|
'print_number', // 印字数
|
|
'keep_alive', // 最新キープアライブ
|
|
'renew_start_date', // 更新期間開始日
|
|
'renew_start_time', // 更新期間開始時
|
|
'renew_end_date', // 更新期間終了日
|
|
'renew_end_time', // 更新期間終了時
|
|
'parking_start_period', // 駐輪開始期間
|
|
'reminder_type', // リマインダー種別
|
|
'reminder_time', // リマインダー時間
|
|
'immediate_use_after_contract', // 契約後即利用許可
|
|
'display_gender', // 項目表示設定:性別
|
|
'display_birthday', // 項目表示設定:生年月日
|
|
'display_security_registration_number', // 項目表示設定:防犯登録番号
|
|
'distance_between_two_points', // 二点間距離
|
|
'latitude', // 駐車場座標(緯度)
|
|
'longitude', // 駐車場座標(経度)
|
|
'phone_number', // 電話番号
|
|
'contract_type_regular', // 駐輪場契約形態(定期)
|
|
'contract_type_temporary', // 駐輪場契約形態(一時利用)
|
|
'vehicle_type_limit', // 車種制限
|
|
'procedure_method', // 手続方法
|
|
'payment_method', // 支払方法
|
|
'usage_time_limit_flag', // 利用可能時間制限フラグ
|
|
'usage_time_start', // 利用可能時間(開始)
|
|
'usage_time_end', // 利用可能時間(終了)
|
|
'resident_manager_flag', // 常駐管理人フラグ
|
|
'resident_time_start', // 常駐時間(開始)
|
|
'resident_time_end', // 常駐時間(終了)
|
|
'roof_flag', // 屋根フラグ
|
|
'seal_issuing_machine_flag', // シール発行機フラグ
|
|
'usage_method', // 駐輪場利用方法
|
|
'periodic_update_period', // 定期更新期間
|
|
'waiting_reservation', // 空き待ち予約
|
|
'special_notes', // 特記事項
|
|
'student_id_confirmation_type', // 学生証確認種別
|
|
'reduction_guide_display_flag', // 減免案内表示フラグ
|
|
'reduction_target_age', // 減免対象年齢
|
|
'reduction_guide_display_start_month', // 減免案内表示開始月数
|
|
'cross_year' // 年跨ぎ
|
|
// 如有 created_at/updated_at 可省略不填
|
|
];
|
|
|
|
public static function search($inputs)
|
|
{
|
|
$list = self::query();
|
|
if ($inputs['isMethodPost']) {
|
|
// 搜索条件可追加
|
|
}
|
|
// Sort
|
|
if ($inputs['sort']) {
|
|
$list->orderBy($inputs['sort'], $inputs['sort_type']);
|
|
}
|
|
if ($inputs['isExport']){
|
|
$list = $list->get();
|
|
}else{
|
|
$list = $list->paginate(Utils::item_per_page);
|
|
}
|
|
return $list;
|
|
}
|
|
|
|
public static function getByPk($pk)
|
|
{
|
|
return self::find($pk);
|
|
}
|
|
|
|
public static function deleteByPk($arr)
|
|
{
|
|
return self::whereIn('park_id', $arr)->delete();
|
|
}
|
|
|
|
public static function boot()
|
|
{
|
|
parent::boot();
|
|
self::creating(function (Park $model) {
|
|
$model->operator_id = Auth::user()->ope_id ?? null;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* GET 閉設フラグ
|
|
*/
|
|
public function getParkCloseFlagDisplay() {
|
|
if($this->park_close_flag == 1) {
|
|
return '閉設';
|
|
}
|
|
else if($this->park_close_flag == 0) {
|
|
return '開設';
|
|
}
|
|
return '';
|
|
}
|
|
|
|
public function getCity()
|
|
{
|
|
// city_id => city_id (City モデル要有 city_id PK)
|
|
return $this->belongsTo(City::class, 'city_id', 'city_id')->first();
|
|
}
|
|
|
|
public static function getList(){
|
|
return self::pluck('park_name','park_id');
|
|
}
|
|
|
|
public static function getIdByName($park_name){
|
|
return self::where('park_name',$park_name)->pluck('park_id')->first();
|
|
}
|
|
|
|
/**
|
|
* 料金設定との関連付け
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
*/
|
|
public function prices()
|
|
{
|
|
return $this->hasMany(PriceA::class, 'park_id', 'park_id');
|
|
}
|
|
|
|
}
|