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