1

I used this query to update the status column.

$val="1";
vehicles::where('id' , '=' , $veh_status)->update(['status' => $val]);

But when I submitted the status value doesn't change.

2
  • $veh_status does not seem to be an ID. Commented Apr 27, 2019 at 18:17
  • Check if status is listed as $fillable in Vehicles model. It's a common mistake when utilizing mass assignment feature in Eloquent. Commented Apr 27, 2019 at 20:01

2 Answers 2

1

you can trace your query by using ->toSql() method ! try this to find whats happening in back

Sign up to request clarification or add additional context in comments.

Comments

1

Not sure what the problem is there because you haven't given much info to work with, but you can check these suggestions:

  • Check if the column is set to be mass assignable in the model class, that is, it is in the fillable[] array.
  • make sure the id you pass to the where() function is valid.
  • Try using another function, save() which will achieve the same results you seek, like this;

    // filter the vehicle $vehicle = vehicles::where('id', '=', $veh_id)->first(); or $vehicle = vehicles::find($veh_id); $vehicle->status = 1; $vehicle->save();

Lastly, I noticed your id variable you pass to the where the () function is called $veh_status "presumably - vehicle status" and not $veh_id, "presumably - vehicle id" so probably check that out.

Ref: Laravel Model Update documentation

2 Comments

The id passed in where function is ok. problem is in database the status value doesnt change
Did you try my suggestions? What happened? What else did you try...you must try to give as much information about your problem to get help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.