model = $uni_message; parent::__construct(); } /** * Display a listing of the resource. * * @return Response */ public function index(UniMessageAdminRequest $request) { if ($request->wantsJson()) { $array = $this->model->json(); foreach ($array as $key => $row) { $array[$key] = array_only($row, config('uni_message.uni_message.listfields')); } return ['data' => $array]; } $this->theme->prependTitle(trans('uni_message::uni_message.names').' :: '); return $this->theme->of('uni_message::admin.uni_message.index')->render(); } /** * Display the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function show(UniMessageAdminRequest $request, $id) { $uni_message = $this->model->find($id); if (empty($uni_message)) { if ($request->wantsJson()) { return []; } return view('uni_message::admin.uni_message.new'); } if ($request->wantsJson()) { return $uni_message; } Former::populate($uni_message); return view('uni_message::admin.uni_message.show', compact('uni_message')); } /** * Show the form for creating a new resource. * * @param Request $request * * @return Response */ public function create(UniMessageAdminRequest $request) { $uni_message = $this->model->findOrNew(0); Former::populate($uni_message); return view('uni_message::admin.uni_message.create', compact('uni_message')); } /** * Display the specified resource. * * @param Request $request * * @return Response */ public function store(UniMessageAdminRequest $request) { try { $attributes = $request->all(); $uni_message = $this->model->create($attributes); return $this->success(trans('messages.success.created', ['Module' => trans('uni_message::uni_message.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(UniMessageAdminRequest $request, $id) { $uni_message = $this->model->find($id); Former::populate($uni_message); return view('uni_message::admin.uni_message.edit', compact('uni_message')); } /** * Update the specified resource. * * @param Request $request * @param int $id * * @return Response */ public function update(UniMessageAdminRequest $request, $id) { try { $attributes = $request->all(); $uni_message = $this->model->update($attributes, $id); return $this->success(trans('messages.success.updated', ['Module' => trans('uni_message::uni_message.name')])); } catch (Exception $e) { return $this->error($e->getMessage()); } } /** * Remove the specified resource. * * @param int $id * * @return Response */ public function destroy(UniMessageAdminRequest $request, $id) { try { $this->model->delete($id); return $this->success(trans('message.success.deleted', ['Module' => trans('uni_message::uni_message.name')]), 200); } catch (Exception $e) { return $this->error($e->getMessage()); } } }