repository = $fbmanager; parent::__construct(); } /** * Display a list of fbmanager. * * @return Response */ public function index(FbmanagerRequest $request) { if ($request->wantsJson()) { return $this->getJson($request); } $this ->theme->prependTitle(trans('trungpro::fbmanager.names').' :: '); return $this->theme->of('trungpro::admin.fbmanager.index')->render(); } /** * Display a list of fbmanager. * * @return Response */ public function getJson(FbmanagerRequest $request) { $pageLimit = $request->input('pageLimit'); $fbmanagers = $this->repository ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria')) ->setPresenter('\\Trungpro\\Trungpro\\Repositories\\Presenter\\FbmanagerListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate($pageLimit); $fbmanagers['recordsTotal'] = $fbmanagers['meta']['pagination']['total']; $fbmanagers['recordsFiltered'] = $fbmanagers['meta']['pagination']['total']; $fbmanagers['request'] = $request->all(); return response()->json($fbmanagers, 200); } /** * Display fbmanager. * * @param Request $request * @param Model $fbmanager * * @return Response */ public function show(FbmanagerRequest $request, Fbmanager $fbmanager) { if (!$fbmanager->exists) { return response()->view('trungpro::admin.fbmanager.new', compact('fbmanager')); } Form::populate($fbmanager); return response()->view('trungpro::admin.fbmanager.show', compact('fbmanager')); } /** * Show the form for creating a new fbmanager. * * @param Request $request * * @return Response */ public function create(FbmanagerRequest $request) { $fbmanager = $this->repository->newInstance([]); Form::populate($fbmanager); return response()->view('trungpro::admin.fbmanager.create', compact('fbmanager')); } /** * Create new fbmanager. * * @param Request $request * * @return Response */ public function store(FbmanagerRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id('admin.web'); $fbmanager = $this->repository->create($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('trungpro::fbmanager.name')]), 'code' => 204, 'redirect' => trans_url('/admin/trungpro/fbmanager/'.$fbmanager->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, ], 400); } } /** * Show fbmanager for editing. * * @param Request $request * @param Model $fbmanager * * @return Response */ public function edit(FbmanagerRequest $request, Fbmanager $fbmanager) { Form::populate($fbmanager); return response()->view('trungpro::admin.fbmanager.edit', compact('fbmanager')); } /** * Update the fbmanager. * * @param Request $request * @param Model $fbmanager * * @return Response */ public function update(FbmanagerRequest $request, Fbmanager $fbmanager) { try { $attributes = $request->all(); $fbmanager->update($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('trungpro::fbmanager.name')]), 'code' => 204, 'redirect' => trans_url('/admin/trungpro/fbmanager/'.$fbmanager->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/trungpro/fbmanager/'.$fbmanager->getRouteKey()), ], 400); } } /** * Remove the fbmanager. * * @param Model $fbmanager * * @return Response */ public function destroy(FbmanagerRequest $request, Fbmanager $fbmanager) { try { $t = $fbmanager->delete(); return response()->json([ 'message' => trans('messages.success.deleted', ['Module' => trans('trungpro::fbmanager.name')]), 'code' => 202, 'redirect' => trans_url('/admin/trungpro/fbmanager/0'), ], 202); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/trungpro/fbmanager/'.$fbmanager->getRouteKey()), ], 400); } } }