Muqsith Arsyad
Muqsith Arsyad

Reputation: 45

How to update data in laravel 5.8

i have tried to update data of my database, but there is no error this my method

public function update_pj_si(request $request)
{
    $id = $request->id;
    DB::table('tbl_profil_penyedia')
        ->where('id_profil_penyedia', $id)
        ->update(array('status' => 1));
    return redirect('/verif/pj_si');
}

if i run this method, it run correctly and no error but the database is not updated. how can i fix this?

Upvotes: 1

Views: 952

Answers (1)

lagbox
lagbox

Reputation: 50481

The $id variable doesn't contain a value that exists in your table, tbl_profil_penyedia, for the field id_profil_penyedia. It is as simple as that.

You are trying to update a profil_penyedia that doesn't exist.

The update call returning 0, means it didn't update any rows, which means your where condition didn't yield any results to be updated.

Upvotes: 4

Related Questions