/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $lists = Brand::find($id)->category; $category = Category::lists('cate_name', 'id'); $cate = Category::all('id', 'cate_name'); $brands = Brand::find($id)->toArray(); return view('admin.brand.edit', compact('brands', 'cate', 'lists', 'category')); }
public function getBrandLogo(Request $request, $brandId) { $brand = Brand::find($brandId); if ($brand === null || $brand->logo === '') { return Response::make('', 200); } return Image::make(Storage::disk('s3')->get($brand->logo))->response(); }
public function update($id, BrandFormRequest $request) { $brand = Brand::find($id); $brand_name = $request->input('brand_name'); $brand_type = $request->input('brand_type'); $brand->update(['brand_name' => $brand_name, 'brand_type' => $brand_type]); return redirect()->route('admin.brandManagement'); }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { switch ($this->method()) { case 'POST': return ['name' => 'required|max:255|unique:brands,name']; case 'PATCH': $brand = Brand::find($this->brands); return ['name' => 'required|max:255|unique:brands,name,' . $brand->id]; } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { if (\Input::get('id')) { $brand = Brand::find(\Input::get('id')); } else { $brand = new Brand(); } $brand->title = \Input::get('title'); if ($brand->save()) { return $this->index(); } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, Requests\BrandRequest $request) { $brand = Brand::find($id); $brand->city_id = $request->city_id; $brand->brand_type_id = $request->brand_type_id; $brand->brand_name = $request->brand_name; $brand->description = $request->description; $brand->logo = $request->logo; $brand->video = $request->video; $brand->update(); return redirect('admin/brands'); }
public function update(UpdateBrand $request, $id) { $brand = Brand::find($id); $oldLogo = $brand->logo; $brand->update($request->all()); if ($request->hasFile('logo')) { if ($request->file('logo')->isValid()) { $logo = $request->file('logo'); $moveLogo = $logo->move(public_path() . '/uploads', $filename = time() . '-' . $logo->getClientOriginalName()); $brand->update(['logo' => $filename]); File::delete(public_path() . '/uploads/' . $oldLogo); } else { return redirect()->back()->withInput(); } } $brand->save(); return redirect()->route('home.brands.show', [$brand->id]); }
public function update($id) { $input = Input::all(); $rules = array('image' => 'image'); $niceNames = array('image' => 'brand image'); $validator = Validator::make($input, $rules); $validator->setAttributeNames($niceNames); if ($validator->fails()) { return Response::json(['success' => false, 'errors' => $validator->getMessageBag()->toArray()]); } else { $Brand = Brand::find($id); if (Input::has('show')) { $Brand->show = Input::get('show'); } if (Input::has('ordering')) { $Brand->ordering = Input::get('ordering'); } if (Input::has('status')) { $Brand->status = Input::get('status'); } if (Input::has('title')) { $Brand->title = Input::get('title'); } if (Input::hasfile('image')) { $file = Input::file('image'); $destinationPath = 'uploads/brands/'; $filename = $file->getClientOriginalName(); Input::file('image')->move($destinationPath, $filename); $ext = substr($filename, strrpos($filename, ".")); $newFileName = basename($filename, $ext) . "_" . $Brand->id . "_" . date("Ymdhis") . $ext; rename($destinationPath . $filename, $destinationPath . $newFileName); Brand::where('id', $Brand->id)->update(['image_path' => $destinationPath . $newFileName]); } $Brand->save(); if (Input::hasfile('image')) { return Response::json(['success' => true, 'message' => 'Brand has been updated!', 'file' => asset($destinationPath . $newFileName)]); } else { return Response::json(['success' => true, 'message' => 'Brand has been updated!']); } } }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $object = Model::find($id); if ($object) { $object->delete(); } return redirect()->back(); }
public function del_brand(Request $request) { $id = $request->input('id'); $brand = Brand::find($id); $brand->delete(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $brand = Brand::find($id); $brand->delete($id); return redirect()->route('brand.index'); }
public function __construct() { $this->data = ['brand' => Brand::find(1)]; }
public function update(Request $request, $id) { $brand = Brand::find($id); if (empty($brand)) { return $this->failure_noexists(); } $keys = 'name,fid,logo_aid'; $data = $this->autoValidate($request, 'brand.store', $keys, $brand); $brand->update($data); return $this->success(); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { Brand::find($id)->delete(); \Flash::success('Brand Berhasil Dihapus'); return redirect('admin/brand'); }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $id) { if ($request->hasFile('picture')) { $validator = Validator::make($request->all(), ['picture' => 'mimes:jpeg,png']); if ($validator->fails()) { return redirect('brands/' . $id . '/edit')->withErrors($validator)->withInput(); } $image = Input::file('picture'); $filename = date('YmdHis') . "-" . $image->getClientOriginalName(); $brand = Brand::find($id); $brand->name = $request->get('name'); $brand->picture = $filename; $brand->description = $request->get('description'); $brand->update(); $request->file('picture')->move(base_path() . '/public/admin/brandlogo/', $filename); return redirect('brands'); } else { $brand = Brand::find($id); $brand->name = $request->get('name'); $brand->description = $request->get('description'); $brand->update(); return redirect('brands'); } }
/** * Update the specified Brands in storage. * @param int $id * @param UpdateBrandsRequest $request * @return Response */ public function update($id, UpdateBrandsRequest $request) { $brands = $this->brandsRepository->find($id); if (empty($brands)) { Flash::error('Brands not found'); return redirect(route('brands.index')); } $logo = $brands->logo; $logoNovo = $request->logo; $brands = $this->brandsRepository->updateRich($request->all(), $id); $brand = \App\Brand::find($id); if ($logoNovo) { if ($logo) { if (\File::exists(base_path() . '/public/images/' . $logo)) { \File::Delete(base_path() . '/public/images/' . $logo); } } $extlogo = pathinfo(Input::file('logo')->getClientOriginalName()); $nomelogo = BrandsController::getRandomHex(16) . '.' . trim(strtolower($extlogo['extension'])); Image::make(Input::file('logo'))->save(base_path() . '/public/images/brand' . $id . '-' . $nomelogo); $brand->logo = 'brand' . $id . '-' . $nomelogo; } $brand->save(); Flash::success('Brands updated successfully.'); return redirect(route('brands.index')); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // $this->validate($request, ['brand_name' => 'required']); $brand = Brand::find($id); $brand->brand_name = $request->brand_name; $brand->save(); return redirect()->route('admin.brand.index'); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(Request $request, $id) { $brand = Brand::find($id); if ($brand && ($brand->user_id == $request->user()->id || $request->user()->is_admin())) { $brand->delete(); $data['message'] = 'Brand deleted Successfully'; } else { $data['errors'] = 'Invalid Operation. You have not sufficient permissions'; } return redirect('/brand/index')->with($data); }
public function destroy(Request $request, $id) { empty($id) && !empty($request->input('id')) && ($id = $request->input('id')); $id = (array) $id; foreach ($id as $v) { $brand = Brand::find($v); if ($brand->fid == $this->factory->getKey()) { Brand::destroy($v); } } return $this->success('', count($id) > 5, compact('id')); }