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