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