1// If there's a flight from Oakland to San Diego, set the price to $99.
2// If no matching model exists, create one.
3$flight = App\Models\Flight::updateOrCreate(
4 ['departure' => 'Oakland', 'destination' => 'San Diego'],
5 ['price' => 99, 'discounted' => 1]
6);
1$post = Post::where('id', $id);
2
3$users = DB::table('users')->whereIn('id', array(1, 2, 3))->get();
4
1// Eloquent's Model::query() returns the query builder
2
3Model::where()->get();
4// Is the same as
5Model::query()->where()->get();
6
7Model::query();
8// Can be useful to add query conditions based on certain requirements
9
10// See https://stackoverflow.com/questions/51517203/what-is-the-meaning-of-eloquents-modelquery