v2board/app/Http/Controllers/User/NoticeController.php

27 lines
652 B
PHP
Raw Normal View History

2019-12-12 13:45:46 +08:00
<?php
2020-01-29 16:08:50 +08:00
namespace App\Http\Controllers\User;
2019-12-12 13:45:46 +08:00
use App\Http\Controllers\Controller;
2020-01-29 16:08:50 +08:00
use Illuminate\Http\Request;
2019-12-12 13:45:46 +08:00
use App\Models\Notice;
use App\Utils\Helper;
class NoticeController extends Controller
{
2020-01-11 13:36:52 +08:00
public function fetch(Request $request)
{
2020-01-30 20:02:12 +08:00
$current = $request->input('current') ? $request->input('current') : 1;
$pageSize = 5;
2022-01-22 02:30:05 +08:00
$model = Notice::orderBy('created_at', 'DESC')
->where('show', 1);
2020-01-30 20:02:12 +08:00
$total = $model->count();
$res = $model->forPage($current, $pageSize)
->get();
2019-12-12 13:45:46 +08:00
return response([
2020-01-30 20:02:12 +08:00
'data' => $res,
'total' => $total
2019-12-12 13:45:46 +08:00
]);
}
}