app/Http/Controllers/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)
    {
        $this->validate($request,[
            'name' => 'required|unique:categories|max:255',
            'user_id' => 'required'
        ]);
        Category::create([
            'name' => $request->name,
            'slug' => str_slug($request->name),
            'user_id' => $request->user_id
        ]);
        Session::flash('success','You have created Category succesfully');
        return redirect()->back();
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'name' => 'required|unique:categories|max:255' , 'user_id' => 'required' ] ) ; Category :: create ( [ 'name' => $ request -> name , 'slug' => str_slug ( $ request -> name ) , 'user_id' => $ request -> user_id ] ) ; Session :: flash ( 'success' , 'You have created Category succesfully' ) ; return redirect ( ) -> back ( ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .