model = $merchant; $this->model->setUserFilter(); parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(MerchantUserRequest $request) { $merchants = $this->model->all(); $this->theme->prependTitle(trans('merchant::merchant.names').' :: '); return $this->theme->of('merchant::user.merchant.index', compact('merchants'))->render(); } /** * Display the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function show(MerchantUserRequest $request, $role, $id) { $merchant = $this->model->find($id); return $this->theme->of('merchant::user.merchant.show', compact('merchant'))->render(); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(MerchantUserRequest $request) { $merchant = $this->model->findOrNew(0); Former::populate($merchant); return $this->theme->of('merchant::user.merchant.create', compact('merchant'))->render(); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(MerchantUserRequest $request) { try { $attributes = $request->all(); $merchant = $this->model->create($attributes); return $this->success(trans('messages.success.created', ['Module' => trans('merchant::merchant.name')])); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * Show the form for editing the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function edit(MerchantUserRequest $request, $role, $id) { $merchant = $this->model->find($id); Former::populate($merchant); return $this->theme->of('merchant::user.merchant.edit', compact('merchant'))->render(); } /** * Update the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function update(MerchantUserRequest $request, $role, $id) { try { $attributes = $request->all(); $merchant = $this->model->update($attributes, $id); return $this->success(trans('messages.success.updated', ['Module' => trans('merchant::merchant.name')])); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * Remove the specified resource. * * @param int $id * * @return Response */ public function destroy(MerchantUserRequest $request, $role, $id) { try { $this->model->delete($id); return $this->success(trans('message.success.deleted', ['Module' => trans('merchant::merchant.name')]), 200); } catch (Exception $e) { return $this->error($e->getMessage()); } } }