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