Fixes #2463 - Redirect back instead of erroring
This commit is contained in:
@@ -11,11 +11,14 @@
|
|||||||
|
|
||||||
namespace CachetHQ\Cachet\Bus\Handlers\Commands\Schedule;
|
namespace CachetHQ\Cachet\Bus\Handlers\Commands\Schedule;
|
||||||
|
|
||||||
|
use AltThree\Validator\ValidationException;
|
||||||
use CachetHQ\Cachet\Bus\Commands\Schedule\CreateScheduleCommand;
|
use CachetHQ\Cachet\Bus\Commands\Schedule\CreateScheduleCommand;
|
||||||
use CachetHQ\Cachet\Bus\Events\Schedule\ScheduleWasCreatedEvent;
|
use CachetHQ\Cachet\Bus\Events\Schedule\ScheduleWasCreatedEvent;
|
||||||
use CachetHQ\Cachet\Models\Schedule;
|
use CachetHQ\Cachet\Models\Schedule;
|
||||||
use CachetHQ\Cachet\Services\Dates\DateFactory;
|
use CachetHQ\Cachet\Services\Dates\DateFactory;
|
||||||
use Illuminate\Contracts\Auth\Guard;
|
use Illuminate\Contracts\Auth\Guard;
|
||||||
|
use Illuminate\Support\MessageBag;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the create schedule command handler.
|
* This is the create schedule command handler.
|
||||||
@@ -61,9 +64,13 @@ class CreateScheduleCommandHandler
|
|||||||
*/
|
*/
|
||||||
public function handle(CreateScheduleCommand $command)
|
public function handle(CreateScheduleCommand $command)
|
||||||
{
|
{
|
||||||
$schedule = Schedule::create($this->filter($command));
|
try {
|
||||||
|
$schedule = Schedule::create($this->filter($command));
|
||||||
|
|
||||||
event(new ScheduleWasCreatedEvent($this->auth->user(), $schedule));
|
event(new ScheduleWasCreatedEvent($this->auth->user(), $schedule));
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
throw new ValidationException(new MessageBag([$e->getMessage()]));
|
||||||
|
}
|
||||||
|
|
||||||
return $schedule;
|
return $schedule;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class ScheduleController extends Controller
|
|||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
return cachet_redirect('dashboard.schedule.create')
|
return cachet_redirect('dashboard.schedule.create')
|
||||||
->withInput(Binput::all())
|
->withInput(Binput::all())
|
||||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.add.failure')))
|
->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.schedule.edit.failure')))
|
||||||
->withErrors($e->getMessageBag());
|
->withErrors($e->getMessageBag());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user