/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // Validation // $validation = Validator::make($request->all(), ['userfile' => 'required|image|mimes:jpeg,png|min:1|max:8000']); // Check if it fails // if ($validation->fails()) { return redirect()->back()->withInput()->with('errors', $validation->errors()); } $url = $request->input('url_get'); $nm = $request->input('nm'); $id = $request->input('id'); if ($url == 'category') { $url = 'categories'; } $pict = new Pict(); // upload the product // $image = $request->file('userfile'); $filename = time() . '.' . $image->getClientOriginalExtension(); $path = public_path('assets/' . $url . '/' . $filename); $img = Image::make($image->getRealPath()); // resize the image to a width of 300 and constrain aspect ratio (auto height) $img->resize(300, null, function ($constraint) { $constraint->aspectRatio(); }); $img->save($path); $iddes = 'id_' . $url; $seo = $request->input('caption'); $seotitle = SeoHelper::seotitle($seo); // save pict data into database // $pict->pict = $filename; $pict->{$iddes} = $id; $pict->save(); Alert::success('Success Create!' . $url)->persistent("Close"); return redirect('dropmin/product/list')->with('message', 'You just uploaded an image!'); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $category = Category::find($id); $pict = Pict::where('id_categories', $id)->get(); $check = $category->publish; if ($check == 0) { $checks = ''; } else { $checks = 'checked'; } return view('dropmin/category/edit')->with(array('category' => $category, 'check' => $checks, 'pict' => $pict)); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $sub_cat = CategorySub::find($id); $pict = Pict::where('id_category_subs', $id)->get(); $check = $sub_cat->publish; if ($check == 0) { $checks = ''; } else { $checks = 'checked'; } $categories = Category::all(); return view('dropmin/category_sub/edit')->with(array('sub_cat' => $sub_cat, 'check' => $checks, 'categories' => $categories, 'pict' => $pict)); }
public function trash($get, $seo, $id, $par) { $real_get = $get; if ($get == "category") { $get = 'categories'; } $pict = Pict::find($id); $path = '/assets/' . $get . '/'; $old_img = $pict->pict; Storage::delete(public_path() . $path . $old_img); $pict->delete(); Alert::success('Success Delete!' . $seo)->persistent("Close"); return redirect('dropmin/' . $real_get . '/edit/' . $par . '')->with('message', 'You just deleted an image!'); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $product = Product::find($id); $sub_cat = CategorySub::all(); $variant = ProductVariant::where('id_products', $id)->get(); $pict = Pict::where('id_products', $id)->get(); $check = $product->publish; if ($check == 0) { $checks = ''; } else { $checks = 'checked'; } $categories = Category::all(); return view('dropmin/product/edit')->with(array('product' => $product, 'sub_cat' => $sub_cat, 'variant' => $variant, 'check' => $checks, 'categories' => $categories, 'pict' => $pict)); }