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 | |
/* | |
* Escreva toda a sua lógica antes de enviar qualquer coisa para saída do script | |
* (output). Se não você pode receber erros como o clássico: | |
* | |
* "Cannot modify header information - headers already sent" | |
* | |
* Então deixe para colocar o que você tiver de HTML, etc para depois. | |
*/ |
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
// Build your query as usual, but don't use the paginate() method at the chain | |
// end. | |
$query = User::select([ 'users.*', DB::raw('count(roles.id) as roles_count') ]) | |
->join('user_roles', 'users.id', '=', 'roles.user_id') | |
->groupBy('users.id') | |
->having('roles_count', '>', 0); | |
// Due a bug in Eloquent, we need to build the paginator manually. | |
// | |
// For more details refer to: |