123456789101112131415161718192021222324 |
- <?php
- namespace App\Repositories;
- use App\Models\Advertisement;
- use Carbon\Carbon;
- use Illuminate\Support\Facades\Log;
- class AdvertisementRepository extends BaseRepository
- {
- public function __construct(Advertisement $model)
- {
- $this->model = $model;
- }
- public function byPositionIdGetActive($position, $area_id)
- {
- $now = Carbon::now()->toDateTimeString();
- $area_ids = array_unique([0, $area_id]);
- return $this->model->whereIn('area_id', $area_ids)->whereIn('advertisement_position_slug', $position)->where('start_time', '<=', $now)->where('end_time', '>', $now)->where('is_display', Advertisement::DISPLAY_OK)->orderBy('sort', 'desc')->get();
- }
- }
|