repository = $messenger_user; parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(MessengerUserUserWebRequest $request) { $this->repository->pushCriteria(new \Lavalite\MessengerUser\Repositories\Criteria\MessengerUserUserCriteria()); $messenger_users = $this->repository->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate(); $this->theme->prependTitle(trans('messenger_user::messenger_user.names').' :: '); return $this->theme->of('messenger_user::user.messenger_user.index', compact('messenger_users'))->render(); } /** * Display the specified resource. * * @param Request $request * @param MessengerUser $messenger_user * * @return Response */ public function show(MessengerUserUserWebRequest $request, MessengerUser $messenger_user) { Form::populate($messenger_user); return $this->theme->of('messenger_user::user.messenger_user.show', compact('messenger_user'))->render(); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(MessengerUserUserWebRequest $request) { $messenger_user = $this->repository->newInstance([]); Form::populate($messenger_user); return $this->theme->of('messenger_user::user.messenger_user.create', compact('messenger_user'))->render(); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(MessengerUserUserWebRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $messenger_user = $this->repository->create($attributes); return redirect(trans_url('/user/messenger_user/messenger_user')) -> with('message', trans('messages.success.created', ['Module' => trans('messenger_user::messenger_user.name')])) -> with('code', 201); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } /** * Show the form for editing the specified resource. * * @param Request $request * @param MessengerUser $messenger_user * * @return Response */ public function edit(MessengerUserUserWebRequest $request, MessengerUser $messenger_user) { Form::populate($messenger_user); return $this->theme->of('messenger_user::user.messenger_user.edit', compact('messenger_user'))->render(); } /** * Update the specified resource. * * @param Request $request * @param MessengerUser $messenger_user * * @return Response */ public function update(MessengerUserUserWebRequest $request, MessengerUser $messenger_user) { try { $this->repository->update($request->all(), $messenger_user->getRouteKey()); return redirect(trans_url('/user/messenger_user/messenger_user')) ->with('message', trans('messages.success.updated', ['Module' => trans('messenger_user::messenger_user.name')])) ->with('code', 204); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } /** * Remove the specified resource. * * @param int $id * * @return Response */ public function destroy(MessengerUserUserWebRequest $request, MessengerUser $messenger_user) { try { $this->repository->delete($messenger_user->getRouteKey()); return redirect(trans_url('/user/messenger_user/messenger_user')) ->with('message', trans('messages.success.deleted', ['Module' => trans('messenger_user::messenger_user.name')])) ->with('code', 204); } catch (Exception $e) { redirect()->back()->withInput()->with('message', $e->getMessage())->with('code', 400); } } }