app/Http/Controllers/ProdukController.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)
    {
        $validatedData = $request->validate([
            'nama' => 'required|max:25',
            'stok' => 'required',
        ]);
        Produk::create($validatedData);
        $request->session()->flash('success', 'Berhasil menambah data!');
        return redirect('/produk');
    }
public function store ( Request $ request ) { $ validatedData = $ request -> validate ( [ 'nama' => 'required|max:25' , 'stok' => 'required' , ] ) ; Produk :: create ( $ validatedData ) ; $ request -> session ( ) -> flash ( 'success' , 'Berhasil menambah data!' ) ; return redirect ( '/produk' ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .