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