public function createCategories(Request $request) { if (Auth::user()->email == '*****@*****.**') { $validator = Validator::make($request->all(), ['name' => 'required', 'position' => 'required|integer']); if ($validator->fails()) { return redirect('/admin/categories')->withErrors($validator)->withInput(); } $category = new ProductCategories(); $category->name = $request->input('name'); $category->position = $request->input('position'); $category->save(); return redirect()->back()->with($request->session()->flash('admin-success', 'Успешно създадохте категория.')); } return redirect('/'); }