Last active
November 23, 2020 17:31
-
-
Save emjayess/3c1e14826b7a182a58ea752faa25e8e7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// short syntax available in php 7.4 and up | |
Project::with('user') | |
// regular anonymous php function expression | |
->whereHas('user', function($query) { | |
$query->where('role', 'admin'); | |
}) | |
// short anonymous php function expression ("fat arrow" fn) | |
->whereHas('user', fn($query) => $query->where('role', 'admin')) | |
->get() | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment