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