app/Http/Controllers/Api/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)
    {
        $request->validate([
            'name'      => 'required|max:255',
            'slug'      => 'required|max:255|unique:categories'
        ]);
        $category = Category::create($request->all());
        return $category;
    }
public function store ( Request $ request ) { $ request -> validate ( [ 'name' => 'required|max:255' , 'slug' => 'required|max:255|unique:categories' ] ) ; $ category = Category :: create ( $ request -> all ( ) ) ; return $ category ; }
Store a newly created resource in storage.
Store a newly created resource in storage .