app/Http/Controllers/ProductController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\ProductModel  $productModel
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, ProductModel $productModel)
    {
          $request->validate([
            'nama' => 'required|min:5',
            'price' => 'required'
        ],
        [
            'nama.required' => 'jangan kosongkan nama anda',
            'nama.min' => 'minimal karakter 5',
            'price.required' => 'harga tidak boleh kosong',
        ]
    );
        ProductModel::where('id',$productModel->id)->update([
            'name' => $request->nama,
            'price' => $request->price
        ]);
        return redirect('/product')->with('status', 'data berhasil ditambahkan');
    }
public function update ( Request $ request , ProductModel $ productModel ) { $ request -> validate ( [ 'nama' => 'required|min:5' , 'price' => 'required' ] , [ 'nama.required' => 'jangan kosongkan nama anda' , 'nama.min' => 'minimal karakter 5' , 'price.required' => 'harga tidak boleh kosong' , ] ) ; ProductModel :: where ( 'id' , $ productModel -> id ) -> update ( [ 'name' => $ request -> nama , 'price' => $ request -> price ] ) ; return redirect ( '/product' ) -> with ( 'status' , 'data berhasil ditambahkan' ) ; }
Update the specified resource in storage.
Update the specified resource in storage .
//validasi //return $request;