public function save() { $category = Category::findOrNew(Input::get('id')); $category->category = Input::get('category'); $category->is_home = Input::get('is_home'); $category->is_nav = Input::get('is_nav'); $category->sort_order = Input::get('sort_order'); $category->url_key = Input::get('url_key'); $category->short_desc = Input::get('short_desc'); $category->long_desc = Input::get('long_desc'); $category->meta_title = Input::get('meta_title'); $category->meta_keys = Input::get('meta_keys'); $category->meta_desc = Input::get('meta_desc'); // $catImgs = []; $catImgs = json_decode(empty(Input::get('imgs')) ? "[]" : Input::get('imgs'), true); $destinationPath = public_path() . '/admin/uploads/catalog/category/'; if (Input::hasFile('images')) { $i = 1; foreach (Input::file("images") as $file) { $fileName = date("YmdHis") . "-{$i}" . "." . $file->getClientOriginalExtension(); $upload_success = $file->move($destinationPath, $fileName); if ($upload_success) { array_push($catImgs, $fileName); $i++; } } } $category->images = json_encode($catImgs); $category->save(); if (!empty(Input::get("parent_id"))) { $category->makeChildOf(Input::get("parent_id")); } return redirect()->route('admin.category.view'); }
public function save() { $category = Category::findOrNew(Input::get('id')); $category->category = Input::get('category'); $category->folder = Input::get('folder'); $category->base_price = Input::get('base_price'); $category->sort_order = Input::get('sort_order'); $catImgs = json_decode(empty(Input::get('imgs')) ? "[]" : Input::get('imgs'), true); $destinationPath = public_path() . '/admin/uploads/catalog/category/'; if (Input::hasFile('images')) { $i = 1; foreach (Input::file("images") as $file) { $fileName = date("YmdHis") . "-{$i}" . "." . $file->getClientOriginalExtension(); $upload_success = $file->move($destinationPath, $fileName); if ($upload_success) { array_push($catImgs, $fileName); $i++; } } } $category->images = json_encode($catImgs); $category->save(); if (!empty(Input::get("parent_id"))) { $category->makeChildOf(Input::get("parent_id")); } //dd(Input::get("new_prod_cat")); if (!empty(Input::get("new_prod_cat"))) { return redirect()->route('admin.products.edit.category', ['id' => Input::get("new_prod_cat")]); } else { return redirect()->route('admin.category.view'); } }