Browse Source

活动行事历优化3

master
wanghongjun 3 weeks ago
parent
commit
75dd72bc33
  1. 32
      app/Services/EventCalendarService.php

32
app/Services/EventCalendarService.php

@ -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();

Loading…
Cancel
Save