12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace App\Repositories;
- use App\Models\Announcement;
- use Carbon\Carbon;
- class AnnouncementRepository extends BaseRepository
- {
- public function __construct(Announcement $model)
- {
- $this->model = $model;
- }
- public function byAreaIdGetAns($area_id)
- {
- $area_ids = array_unique([0, $area_id]);
- return $this->model
- ->whereIn('area_id', $area_ids)
- ->where('status', Announcement::STATUS_OK)
- ->orderByDesc('id')
- ->paginate();
- }
- /**
- * 获取最后一条公告
- * */
- public function byAreaIdGetLastAn($area_id)
- {
- $area_ids = array_unique([0, $area_id]);
- return $this->model
- ->whereIn('area_id', $area_ids)
- ->where('status', Announcement::STATUS_OK)
- ->whereDate('expiration_time', '>', Carbon::now())
- ->orderByDesc('id')
- ->first();
- }
- }
|