repository = $fbuids; parent::__construct(); } /** * Display a list of fbuids. * * @return Response */ public function index(FbuidsAdminWebRequest $request) { if ($request->wantsJson()) { $fbuids = $this->repository->setPresenter('\\Blackwhite29\\Fbuid\\Repositories\\Presenter\\FbuidsListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->all(); return response()->json($fbuids, 200); } $this ->theme->prependTitle(trans('fbuid::fbuids.names').' :: '); return $this->theme->of('fbuid::admin.fbuids.index')->render(); } /** * Display fbuids. * * @param Request $request * @param Model $fbuids * * @return Response */ public function show(FbuidsAdminWebRequest $request, Fbuids $fbuids) { if (!$fbuids->exists) { return response()->view('fbuid::admin.fbuids.new', compact('fbuids')); } Form::populate($fbuids); return response()->view('fbuid::admin.fbuids.show', compact('fbuids')); } /** * Show the form for creating a new fbuids. * * @param Request $request * * @return Response */ public function create(FbuidsAdminWebRequest $request) { $fbuids = $this->repository->newInstance([]); Form::populate($fbuids); return response()->view('fbuid::admin.fbuids.create', compact('fbuids')); } /** * Create new fbuids. * * @param Request $request * * @return Response */ public function store(FbuidsAdminWebRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id('admin.web'); $fbuids = $this->repository->create($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('fbuid::fbuids.name')]), 'code' => 204, 'redirect' => trans_url('/admin/fbuid/fbuids/'.$fbuids->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, ], 400); } } /** * Show fbuids for editing. * * @param Request $request * @param Model $fbuids * * @return Response */ public function edit(FbuidsAdminWebRequest $request, Fbuids $fbuids) { Form::populate($fbuids); return response()->view('fbuid::admin.fbuids.edit', compact('fbuids')); } /** * Update the fbuids. * * @param Request $request * @param Model $fbuids * * @return Response */ public function update(FbuidsAdminWebRequest $request, Fbuids $fbuids) { try { $attributes = $request->all(); $fbuids->update($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('fbuid::fbuids.name')]), 'code' => 204, 'redirect' => trans_url('/admin/fbuid/fbuids/'.$fbuids->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/fbuid/fbuids/'.$fbuids->getRouteKey()), ], 400); } } /** * Remove the fbuids. * * @param Model $fbuids * * @return Response */ public function destroy(FbuidsAdminWebRequest $request, Fbuids $fbuids) { try { $t = $fbuids->delete(); return response()->json([ 'message' => trans('messages.success.deleted', ['Module' => trans('fbuid::fbuids.name')]), 'code' => 202, 'redirect' => trans_url('/admin/fbuid/fbuids/0'), ], 202); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/fbuid/fbuids/'.$fbuids->getRouteKey()), ], 400); } } }