Created
March 5, 2016 05:03
-
-
Save vinicius73/76c1f69851d624bb5d74 to your computer and use it in GitHub Desktop.
Modos de uso do eloquent
This file contains hidden or 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 | |
// chain | |
// https://github.com/laravel/framework/blob/5.1/src/Illuminate/Database/Eloquent/Model.php#L3447 | |
// https://github.com/laravel/framework/blob/5.1/src/Illuminate/Database/Eloquent/Model.php#L3429 | |
$user = User::where('email', '[email protected]')->where('is_dead', false)->first(); | |
$bastards = User::where('country', 'westeros')->whereNull('father')->get(); | |
// https://github.com/laravel/framework/blob/5.1/src/Illuminate/Database/Eloquent/Model.php#L574 | |
$query = User::query(); | |
$query->where('email', '[email protected]'); | |
$query->where('is_dead', false); | |
$user = $query->first(); | |
// https://github.com/laravel/framework/blob/5.1/src/Illuminate/Database/Eloquent/Model.php#L1785 | |
$query = (new User())->newQuery(); | |
$query->where('country', 'westeros'); | |
$query->whereNull('father'); | |
$bastards = $query->get(); | |
// https://github.com/laravel/framework/blob/5.1/src/Illuminate/Database/Eloquent/Builder.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment