Skip to content

Instantly share code, notes, and snippets.

@cursosdesarrolloweb
Last active March 4, 2021 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cursosdesarrolloweb/b14de64c8ef060ec884915105a2596fe to your computer and use it in GitHub Desktop.
Save cursosdesarrolloweb/b14de64c8ef060ec884915105a2596fe to your computer and use it in GitHub Desktop.
<?php
Route::get('/without-arrow-function', function () {
$users = User::with(["posts" => function ($query) {
$query->where("points", ">", 4);
}])->get();
});
Route::get('/with-arrow-function', function () {
$users = User::with(["posts" => fn ($query) => $query->where("points", ">", 4)])->get();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment