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