repository = $phone3; parent::__construct(); } /** * Display a list of phone3. * * @return Response */ public function index(Phone3Request $request) { if ($request->wantsJson()) { return $this->getJson($request); } $this ->theme->prependTitle(trans('u_sphone::phone3.names').' :: '); return $this->theme->of('u_sphone::admin.phone3.index')->render(); } /** * Display a list of phone3. * * @return Response */ public function getJson(Phone3Request $request) { $pageLimit = $request->input('pageLimit'); $phone3s = $this->repository ->pushCriteria(app('Litepie\Repository\Criteria\RequestCriteria')) ->setPresenter('\\Muku\\USphone\\Repositories\\Presenter\\Phone3ListPresenter') ->scopeQuery(function($query){ return $query->orderBy('id','DESC'); })->paginate($pageLimit); $phone3s['recordsTotal'] = $phone3s['meta']['pagination']['total']; $phone3s['recordsFiltered'] = $phone3s['meta']['pagination']['total']; $phone3s['request'] = $request->all(); return response()->json($phone3s, 200); } /** * Display phone3. * * @param Request $request * @param Model $phone3 * * @return Response */ public function show(Phone3Request $request, Phone3 $phone3) { if (!$phone3->exists) { return response()->view('u_sphone::admin.phone3.new', compact('phone3')); } Form::populate($phone3); return response()->view('u_sphone::admin.phone3.show', compact('phone3')); } /** * Show the form for creating a new phone3. * * @param Request $request * * @return Response */ public function create(Phone3Request $request) { $phone3 = $this->repository->newInstance([]); Form::populate($phone3); return response()->view('u_sphone::admin.phone3.create', compact('phone3')); } /** * Create new phone3. * * @param Request $request * * @return Response */ public function store(Phone3Request $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id('admin.web'); $phone3 = $this->repository->create($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('u_sphone::phone3.name')]), 'code' => 204, 'redirect' => trans_url('/admin/u_sphone/phone3/'.$phone3->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, ], 400); } } /** * Show phone3 for editing. * * @param Request $request * @param Model $phone3 * * @return Response */ public function edit(Phone3Request $request, Phone3 $phone3) { Form::populate($phone3); return response()->view('u_sphone::admin.phone3.edit', compact('phone3')); } /** * Update the phone3. * * @param Request $request * @param Model $phone3 * * @return Response */ public function update(Phone3Request $request, Phone3 $phone3) { try { $attributes = $request->all(); $phone3->update($attributes); return response()->json([ 'message' => trans('messages.success.updated', ['Module' => trans('u_sphone::phone3.name')]), 'code' => 204, 'redirect' => trans_url('/admin/u_sphone/phone3/'.$phone3->getRouteKey()) ], 201); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/u_sphone/phone3/'.$phone3->getRouteKey()), ], 400); } } /** * Remove the phone3. * * @param Model $phone3 * * @return Response */ public function destroy(Phone3Request $request, Phone3 $phone3) { try { $t = $phone3->delete(); return response()->json([ 'message' => trans('messages.success.deleted', ['Module' => trans('u_sphone::phone3.name')]), 'code' => 202, 'redirect' => trans_url('/admin/u_sphone/phone3/0'), ], 202); } catch (Exception $e) { return response()->json([ 'message' => $e->getMessage(), 'code' => 400, 'redirect' => trans_url('/admin/u_sphone/phone3/'.$phone3->getRouteKey()), ], 400); } } }