Reputation: 12005
I use this function ORM to update row in table:
$client = Client::where("unique_code", $this->unique_code)->whereHas('types', function ($query) {
$query->where("type", $this->type);
})->update(["status" => 1]);
How to return id
of updated row?
Upvotes: 3
Views: 12824
Reputation: 740
First what your using is not the ORM but the QueryBuilder.
You should assign the query result in a variable, process the update and then access the id.
$client = Client::where("unique_code", $this->unique_code)
->whereHas('types', function ($query) {
$query->where("type", $this->type);
})->first();
$client->update(["status" => 1]);
$client->id; // to get the id
Upvotes: 5