app/Http/Controllers/Admin/CategoryController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $rule=[
            'name'=>'required|string|min:2|max:255|unique:categories',
            'description'=>'required|string|min:2|max:999',
            'color'=>'required'
        ];
        $this->validate($request, $rule);
        $category=Category::create([
            'name'=>$request->input('name'),
            'slug'=>str_slug($request->get('name')),
            'description'=>$request->input('description'),
            'color'=>$request->input('color'),
        ]);
        return redirect()->route('home-cate'); 
    }
public function store ( Request $ request ) { $ rule = [ 'name' => 'required|string|min:2|max:255|unique:categories' , 'description' => 'required|string|min:2|max:999' , 'color' => 'required' ] ; $ this -> validate ( $ request , $ rule ) ; $ category = Category :: create ( [ 'name' => $ request -> input ( 'name' ) , 'slug' => str_slug ( $ request -> get ( 'name' ) ) , 'description' => $ request -> input ( 'description' ) , 'color' => $ request -> input ( 'color' ) , ] ) ; return redirect ( ) -> route ( 'home-cate' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .