/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Auth::user()->level == 1) { $blog = Blog::withTrashed()->findOrFail($request->route('blog')); } else { $blog = Blog::findOrFail($request->route('blog')); } if (Auth::user()->level == 1 || Auth::id() == $blog->user_id) { return $next($request); } else { return view('errors.401'); } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $blog = Blog::withTrashed()->find($id); if ($blog) { $blog->forceDelete(); return redirect()->back()->with('success', trans('blog.deleted')); } }
/** * Test * * @return void */ public function testUninstall() { $this->assertTrue($this->object->install()); $this->assertTrue($this->object->uninstall()); }