repository = $media_detail; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litepie\Medium\Repositories\Criteria\MediaDetailResourceCriteria::class); } /** * Display a list of media_detail. * * @return Response */ public function index(MediaDetailRequest $request) { return $this->repository ->setPresenter(\Litepie\Medium\Repositories\Presenter\MediaDetailPresenter::class) ->paginate(); } /** * Display media_detail. * * @param Request $request * @param Model $media_detail * * @return Response */ public function show(MediaDetailRequest $request, MediaDetail $media_detail) { return $media_detail->setPresenter(\Litepie\Medium\Repositories\Presenter\MediaDetailListPresenter::class); ; } /** * Create new media_detail. * * @param Request $request * * @return Response */ public function store(MediaDetailRequest $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('medium::media_detail.name')]); $code = 204; $status = 'success'; $url = guard_url('medium/media_detail/' . $media_detail->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('medium/media_detail'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the media_detail. * * @param Request $request * @param Model $media_detail * * @return Response */ public function update(MediaDetailRequest $request, MediaDetail $media_detail) { try { $data = $request->all(); $media_detail->update($data); $message = trans('messages.success.updated', ['Module' => trans('medium::media_detail.name')]); $code = 204; $status = 'success'; $url = guard_url('medium/media_detail/' . $media_detail->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('medium/media_detail/' . $media_detail->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the media_detail. * * @param Model $media_detail * * @return Response */ public function destroy(MediaDetailRequest $request, MediaDetail $media_detail) { try { $media_detail->delete(); $message = trans('messages.success.deleted', ['Module' => trans('medium::media_detail.name')]); $code = 202; $status = 'success'; $url = guard_url('medium/media_detail/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('medium/media_detail/' . $media_detail->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); } }