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