public function destroy($id, FlashNotifier $notifier) { $trip = Trip::findOrFail($id); if ($trip->passengers()->count() > 0) { $notifier->error('That trip already has passengers. No way we can delete it...'); return back(); } $trip->delete(); $notifier->success('Trip successfully deleted!'); return back(); }
public function destroy(Request $request, FlashNotifier $flash) { $trip = Trip::findOrFail($request->get('trip_id')); try { $this->bookingService->cancel(Auth::user(), $trip); $flash->success("Your reservation from {$trip->origin} to {$trip->destination} was canceled."); } catch (\Exception $e) { $flash->error("There was an error processing your request"); } return redirect()->back(); }
public function toggleDriver($id, FlashNotifier $flash) { $user = User::find($id); if ($user->isDriver() && $user->drives()->future()->count() > 0) { $flash->error("{$user->name} has Trips he needs to drive so he must stay a driver."); return back(); } $user->is_driver = !$user->is_driver; $user->save(); return back(); }
public function destroy($id, FlashNotifier $flash) { $shuttle = Shuttle::findOrFail($id); if ($shuttle->trips()->future()->count() > 0) { $flash->error("Shuttle {$shuttle->name} has trips booked so it can't be deleted."); return back(); } $shuttle->delete(); $flash->success('Shuttle successfully deleted!'); return redirect(route('shuttle.index')); }
/** * Flash an error message. * * @param string $message * @return $this * @static */ public static function error($message) { return \Laracasts\Flash\FlashNotifier::error($message); }
/** * @param string $message */ public function errorMessage(string $message) { $this->flashNotifier->error($message); }