I use Eloquent ORM in Laravel apps. I am torn between raw SQL (where you have a lot of power) and using an ORM, but a lot of times you can kinda walk a tightrope between the two. This gist is a way of collecting cool, more unusual Eloquent query techniques and tips and tricks.
insert a new row or update an existing one in one statement. updateOrCreate
takes two params, an array of attributes to search table on, and then an array of values to set if an existing record is found
Model::updateOrCreate([ 'user_id' => $user->user_id ], [ 'name' => 'bob' ]);