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