Last active
February 13, 2020 07:57
-
-
Save mehdi-fathi/75b647d421aca420b9ed0c6ec781df6b to your computer and use it in GitHub Desktop.
UsersController
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 | |
namespace App\Http\Controllers; | |
use eloquentFilter\QueryFilter\ModelFilters\ModelFilters; | |
/** | |
* Class UsersController. | |
*/ | |
class UsersController | |
{ | |
/** | |
* @param \eloquentFilter\QueryFilter\ModelFilters\ModelFilters $modelFilters | |
*/ | |
public function list(ModelFilters $modelFilters) | |
{ | |
if (!empty($modelFilters->filters())) { | |
$perpage = Request::input('perpage'); | |
Request::offsetUnset('perpage'); | |
$users = User::filter($modelFilters)->with('posts')->orderByDesc('id')->paginate($perpage,['*'],'page'); | |
} else { | |
$users = User::with('posts')->orderByDesc('id')->paginate(10); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment