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,name'
        ]);
        $data = $request->only('name');
        $data['slug'] = Str::slug($request->name);
        Category::create($data);
        return redirect()->route('category.index')
            ->with([
                'message' => 'Kategori berhasil ditambahkan',
                'success' => true,
            ]);
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'name' => 'required|unique:categories,name' ] ) ; $ data = $ request -> only ( 'name' ) ; $ data [ 'slug' ] = Str :: slug ( $ request -> name ) ; Category :: create ( $ data ) ; return redirect ( ) -> route ( 'category.index' ) -> with ( [ 'message' => 'Kategori berhasil ditambahkan' , 'success' => true , ] ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .