Lae/app/Http/Controllers/Api/IndexController.php

29 lines
733 B
PHP
Raw Normal View History

2022-09-08 16:52:39 +00:00
<?php
2022-11-06 11:28:22 +00:00
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
2022-12-28 13:51:16 +00:00
use App\Models\User;
2022-11-06 11:28:22 +00:00
use Illuminate\Http\JsonResponse;
2022-09-08 16:52:39 +00:00
class IndexController extends Controller
{
//
2022-12-28 13:51:16 +00:00
public function index(): JsonResponse
2022-09-08 16:52:39 +00:00
{
return $this->success([
2022-12-28 13:51:16 +00:00
'message' => 'Welcome to LaeCloud API Server.',
2022-09-08 16:52:39 +00:00
]);
}
2022-12-28 13:51:16 +00:00
public function birthdays(): JsonResponse
{
// 获取今天过生日的用户,每页显示 20 个,使用 carbon
2022-12-28 14:30:05 +00:00
$users = User::select(['id', 'name', 'birthday_at', 'email', 'created_at'])->whereMonth('birthday_at', now()->month)
2022-12-28 13:51:16 +00:00
->whereDay('birthday_at', now()->day)
->simplePaginate(20);
return $this->success($users);
}
2022-09-08 16:52:39 +00:00
}