/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // parent::boot($router); $router->bind('vehicles', function ($value) { return Vehicle::whereId($value)->allowed()->firstOrFail(); }); $router->model('logs', 'Fuellog\\Log'); }
/** * Remove the specified resource from storage. * * @param Vehicle $vehicle * @return Response */ public function destroy(Vehicle $vehicle) { $message = "Your vehicle \"{$vehicle->name}\" was successfully deleted."; foreach ($vehicle->logs as $log) { $log->delete(); } $vehicle->delete(); return redirect()->route('home')->withMessage($message); }
protected function showDashboard() { $vehicles = Vehicle::allowed()->get(); return view('dashboard', compact('vehicles')); }
/** * Display a listing of the resource. * * @return Response */ public function index(Vehicle $vehicle) { $logs = $vehicle->logs()->latest()->get(); return view('vehicles.logs.index', compact('logs')); }