|
|
|
@ -105,18 +105,28 @@ class EventCalendarService extends BaseService |
|
|
|
{ |
|
|
|
try { |
|
|
|
DB::beginTransaction(); |
|
|
|
$existsWhere = [ |
|
|
|
['pattern_id', '=', $data['pattern_id']], |
|
|
|
['id', '<>', $id] |
|
|
|
]; |
|
|
|
if (EventCalendar::query()->where($existsWhere)->whereIn( |
|
|
|
'status', |
|
|
|
[0, 1] |
|
|
|
)->exists() |
|
|
|
if (isset($data['status']) && $data['status'] == 0 |
|
|
|
&& isset($data['start_time']) |
|
|
|
) { |
|
|
|
throw new Exception( |
|
|
|
__('service.event_calendar.pattern_exists') |
|
|
|
); |
|
|
|
$start_time = $data['start_time']; |
|
|
|
$existsWhere = [ |
|
|
|
['pattern_id', '=', $data['pattern_id']], |
|
|
|
['id', '<>', $id] |
|
|
|
]; |
|
|
|
if (EventCalendar::query()->where($existsWhere)->whereIn( |
|
|
|
'status', |
|
|
|
[0, 1] |
|
|
|
) |
|
|
|
->where(function ($query) use ($start_time) { |
|
|
|
$query->whereRaw( |
|
|
|
"'{$start_time}' BETWEEN start_time AND end_time" |
|
|
|
); |
|
|
|
})->exists() |
|
|
|
) { |
|
|
|
throw new Exception( |
|
|
|
__('service.event_calendar.pattern_exists') |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
$model = EventCalendar::query()->findOrFail($id); |
|
|
|
$oldValues = $model->toArray(); |
|
|
|
|