Example #1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create($get, $seo, $id)
 {
     if ($get == "category") {
         $slctdb = Category::find($id);
     } elseif ($get == "sub_category") {
         $slctdb = CategorySub::find($id);
     } elseif ($get == "product") {
         $slctdb = Product::find($id);
     } elseif ($get == "productvariant") {
         $slctdb = ProductVariant::find($id);
     } else {
         Alert::Error($get . ', Not Found!')->persistent("Close");
         return view('dropmin/dashboard/index');
     }
     if ($slctdb->name_seo !== $seo) {
         Alert::Error($get . ', Not Found!')->persistent("Close");
         return view('dropmin/dashboard/index')->with('message', $get . 'Not Found!');
     }
     $url_get = $get;
     $seos = SeoHelper::seoclean($seo);
     $data = array('id' => $id, 'name' => $get, 'get' => $get, 'seo' => $seos);
     return view('dropmin/image/add')->with('data', $data);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $validation = Validator::make($request->all(), CategorySub::rules($id), ['categories' => 'required', 'description' => 'required']);
     // Check if it fails //
     if ($validation->fails()) {
         return redirect()->back()->withInput()->with('errors', $validation->errors());
     }
     if (!$request->input('publish')) {
         $publish = 0;
     } else {
         $publish = 1;
     }
     // Process valid data & go to success page //
     $subcat = CategorySub::find($id);
     // replace old data with new data from the submitted form //
     $author = Auth::user()->id;
     $seo = $request->input('name');
     $seotitle = SeoHelper::seotitle($seo);
     // save subcat data into database //
     $subcat->name = $request->input('name');
     $subcat->name_seo = $seotitle;
     $subcat->id_categories = $request->input('categories');
     $subcat->id_user = $author;
     $subcat->description = $request->input('description');
     $subcat->publish = $publish;
     $subcat->save();
     Alert::success($request->input('name') . ' Saved!')->persistent("Close");
     return redirect('dropmin/sub_category/list')->with('message', 'You just updated an sub category!');
 }
Example #3
0
 /**
  * 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));
 }