/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $object = new Model(); $params = $request->only('active', 'order', 'img', 'desc_img', 'brand_id', 'url', 'ru_title', 'ru_description', 'ru_tech_description', 'ru_seo_title', 'ru_seo_keywords', 'ru_seo_description', 'en_title', 'en_description', 'en_tech_description', 'en_seo_title', 'en_seo_keywords', 'en_seo_description', 'ua_title', 'ua_description', 'ua_tech_description', 'ua_seo_title', 'ua_seo_keywords', 'ua_seo_description'); $params['active'] = $params['active'] ? true : false; $filter = $object->validator($params); if ($filter->fails()) { $error = $filter->errors()->toArray(); $brands = Brand::all(); return view('admin.product-category.create', ['input' => $params, 'brands' => $brands, 'error' => $error]); } if ($request->hasFile('img')) { $params['img'] = $this->upload('img'); } if ($request->hasFile('desc_img')) { $params['desc_img'] = $this->upload('desc_img'); } $params['alias'] = $this->makeAlias($params['ru_title']); $object->fill($params); $object->save(); return redirect('admin/product-category/' . $object->id . '/edit'); // return redirect('admin/product-category/'.$object->id); }