v2board/app/Http/Controllers/Admin/UserController.php
2019-10-24 19:30:16 +08:00

27 lines
791 B
PHP

<?php
namespace App\Http\Controllers\Admin;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Order;
use App\Models\User;
class UserController extends Controller
{
public function index (Request $request) {
$current = $request->input('current') ? $request->input('current') : 1;
$pageSize = $request->input('pageSize') >= 10 ? $request->input('pageSize') : 10;
$userModel = User::orderBy('created_at', 'DESC');
if ($request->input('email')) {
$userModel->where('email', $request->input('email'));
}
$total = $userModel->count();
return response([
'data' => $userModel->forPage($current, $pageSize)
->get(),
'total' => $total
]);
}
}