app/Http/Controllers/ProductCategoriesController.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)
    {
        if(ProductCategories::where('category_name',$request->nama_kategori)->exists()){
            return redirect('/product-category')->with('gagal','Data kategori sudah terdaftar!');
        }
        $productCategories = new ProductCategories;
        $productCategories->category_name = $request->nama_kategori;
        $productCategories->save();
        return redirect('/product-category')->with('berhasil','Data kategori berhasil ditambahkan!');
    }
public function store ( Request $ request ) { if ( ProductCategories :: where ( 'category_name' , $ request -> nama_kategori ) -> exists ( ) ) { return redirect ( '/product-category' ) -> with ( 'gagal' , 'Data kategori sudah terdaftar!' ) ; } $ productCategories = new ProductCategories ; $ productCategories -> category_name = $ request -> nama_kategori ; $ productCategories -> save ( ) ; return redirect ( '/product-category' ) -> with ( 'berhasil' , 'Data kategori berhasil ditambahkan!' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .
//menyimpan data kategori