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