repository = $media_request; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litepie\MediaRequest\Repositories\Criteria\MediaRequestResourceCriteria::class); } /** * Display a list of media_request. * * @return Response */ public function index(MediaRequestRequest $request) { return $this->repository ->setPresenter(\Litepie\MediaRequest\Repositories\Presenter\MediaRequestPresenter::class) ->paginate(); } /** * Display media_request. * * @param Request $request * @param Model $media_request * * @return Response */ public function show(MediaRequestRequest $request, MediaRequest $media_request) { return $media_request->setPresenter(\Litepie\MediaRequest\Repositories\Presenter\MediaRequestListPresenter::class); ; } /** * Create new media_request. * * @param Request $request * * @return Response */ public function store(MediaRequestRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('media_request::media_request.name')]); $code = 204; $status = 'success'; $url = guard_url('media_request/media_request/' . $media_request->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('media_request/media_request'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the media_request. * * @param Request $request * @param Model $media_request * * @return Response */ public function update(MediaRequestRequest $request, MediaRequest $media_request) { try { $data = $request->all(); $media_request->update($data); $message = trans('messages.success.updated', ['Module' => trans('media_request::media_request.name')]); $code = 204; $status = 'success'; $url = guard_url('media_request/media_request/' . $media_request->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('media_request/media_request/' . $media_request->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the media_request. * * @param Model $media_request * * @return Response */ public function destroy(MediaRequestRequest $request, MediaRequest $media_request) { try { $media_request->delete(); $message = trans('messages.success.deleted', ['Module' => trans('media_request::media_request.name')]); $code = 202; $status = 'success'; $url = guard_url('media_request/media_request/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('media_request/media_request/' . $media_request->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }