|
- <?php
-
- namespace App\Logics\QRService;
-
- use App\Exceptions\ParamException;
- use App\Models\HtpmsCustomer\Existing\Parking;
- use App\Models\HtpmsCustomer\QRService\ServiceParkingGroup;
- use App\Models\HtpmsCustomer\QRService\ServiceParkingGroupRelation;
-
- class QRServiceParkingGroupLogic
- {
-
- public static function register(ServiceParkingGroup $group)
- {
-
- // 重複チェック
- if (ServiceParkingGroup::whereName($group->name)->exists()) {
- ParamException::throw(ServiceParkingGroup::COL_NAME_NAME, trans('validate.exists'));
- }
-
- $group->save();
- }
-
- public static function add(ServiceParkingGroup $group, Parking $parking)
- {
-
- // 重複チェック
- if (ServiceParkingGroupRelation::whereQrServiceParkingGroupId($group->id)
- ->whereParkingManagementCode($parking->park_code)
- ->exists()
- ) {
- ParamException::throw(ServiceParkingGroupRelation::COL_NAME_PARKING_MANAGEMENT_CODE, trans('validate.exists'));
- }
-
- $relation = new ServiceParkingGroupRelation();
- $relation->qr_service_parking_group_id = $group->id;
- $relation->parking_management_code = $parking->park_code;
- $relation->save();
-
- return $relation;
- }
- public static function remove(ServiceParkingGroup $group, Parking $parking)
- {
- $relation = ServiceParkingGroupRelation::whereQrServiceParkingGroupId($group->id)
- ->whereParkingManagementCode($parking->park_code)
- ->firstOrFail();
-
- $relation->delete();
- }
- }
|