app/Http/Controllers/ProdukController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\produk  $produk
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, Produk $produk)
    {
        $rules = [
            'nama' => 'required|max:25',
            'stok' => 'required',
        ];
        $validatedData = $request->validate($rules);
        Produk::where('id', $produk->id)
                ->update($validatedData);        
        return redirect('/produk')->with('success', 'Berhasil mengubah data!');
    }
public function update ( Request $ request , Produk $ produk ) { $ rules = [ 'nama' => 'required|max:25' , 'stok' => 'required' , ] ; $ validatedData = $ request -> validate ( $ rules ) ; Produk :: where ( 'id' , $ produk -> id ) -> update ( $ validatedData ) ; return redirect ( '/produk' ) -> with ( 'success' , 'Berhasil mengubah data!' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .