repository = $matching_commission; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litecms\MatchingCommission\Repositories\Criteria\MatchingCommissionResourceCriteria::class); } /** * Display a list of matching_commission. * * @return Response */ public function index(MatchingCommissionRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\MatchingCommission\Repositories\Presenter\MatchingCommissionPresenter::class) ->$function(); } $matching_commissions = $this->repository->paginate(); return $this->response->title(trans('matching_commission::matching_commission.names')) ->view('matching_commission::matching_commission.index', true) ->data(compact('matching_commissions')) ->output(); } /** * Display matching_commission. * * @param Request $request * @param Model $matching_commission * * @return Response */ public function show(MatchingCommissionRequest $request, MatchingCommission $matching_commission) { if ($matching_commission->exists) { $view = 'matching_commission::matching_commission.show'; } else { $view = 'matching_commission::matching_commission.new'; } return $this->response->title(trans('app.view') . ' ' . trans('matching_commission::matching_commission.name')) ->data(compact('matching_commission')) ->view($view, true) ->output(); } /** * Show the form for creating a new matching_commission. * * @param Request $request * * @return Response */ public function create(MatchingCommissionRequest $request) { $matching_commission = $this->repository->newInstance([]); return $this->response->title(trans('app.new') . ' ' . trans('matching_commission::matching_commission.name')) ->view('matching_commission::matching_commission.create', true) ->data(compact('matching_commission')) ->output(); } /** * Create new matching_commission. * * @param Request $request * * @return Response */ public function store(MatchingCommissionRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $matching_commission = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('matching_commission::matching_commission.name')])) ->code(204) ->status('success') ->url(guard_url('matching_commission/matching_commission/' . $matching_commission->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/matching_commission/matching_commission')) ->redirect(); } } /** * Show matching_commission for editing. * * @param Request $request * @param Model $matching_commission * * @return Response */ public function edit(MatchingCommissionRequest $request, MatchingCommission $matching_commission) { return $this->response->title(trans('app.edit') . ' ' . trans('matching_commission::matching_commission.name')) ->view('matching_commission::matching_commission.edit', true) ->data(compact('matching_commission')) ->output(); } /** * Update the matching_commission. * * @param Request $request * @param Model $matching_commission * * @return Response */ public function update(MatchingCommissionRequest $request, MatchingCommission $matching_commission) { try { $attributes = $request->all(); $matching_commission->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('matching_commission::matching_commission.name')])) ->code(204) ->status('success') ->url(guard_url('matching_commission/matching_commission/' . $matching_commission->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('matching_commission/matching_commission/' . $matching_commission->getRouteKey())) ->redirect(); } } /** * Remove the matching_commission. * * @param Model $matching_commission * * @return Response */ public function destroy(MatchingCommissionRequest $request, MatchingCommission $matching_commission) { try { $matching_commission->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('matching_commission::matching_commission.name')])) ->code(202) ->status('success') ->url(guard_url('matching_commission/matching_commission/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('matching_commission/matching_commission/' . $matching_commission->getRouteKey())) ->redirect(); } } /** * Remove multiple matching_commission. * * @param Model $matching_commission * * @return Response */ public function delete(MatchingCommissionRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('matching_commission::matching_commission.name')])) ->status("success") ->code(202) ->url(guard_url('matching_commission/matching_commission')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/matching_commission/matching_commission')) ->redirect(); } } /** * Restore deleted matching_commissions. * * @param Model $matching_commission * * @return Response */ public function restore(MatchingCommissionRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('matching_commission::matching_commission.name')])) ->status("success") ->code(202) ->url(guard_url('/matching_commission/matching_commission')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/matching_commission/matching_commission/')) ->redirect(); } } }