Individual model methods vs bulk query update: Best approach?

Much of it will come down to personal preference, and Eloquent is fairly good at not executing needless queries. Personally, I set the $fillable attributes on the model then set them all by passing all of the request input to the fill method.

$user = new User;
$user->fill($request->getParsedBody());
$user->save();

Setting the $fillable fields helps ensure only the input you care about is saved to the model.

There are a couple of different techniques to see the query log. One is to turn it on at the database level. That is often the quickest and easiest. Otherwise have a look in this thread about using the Tracy debugbar with Slim which also gives some info on displaying queries from Eloquent.

2 Likes