app\models\LivestreamCollection::featured PHP Метод

    public function featured()
    {
        $featuredStreamId = presence((string) Cache::get(static::FEATURED_CACHE_KEY));
        if ($featuredStreamId !== null) {
            foreach ($this->all() as $stream) {
                if ((string) $stream->_id !== $featuredStreamId) {
                    continue;
                }
                $featuredStream = $stream;
                break;
            }
        }
        return $featuredStream ?? null;
    }

Usage Example

Пример #1
0
 public function index()
 {
     view()->share('current_action', 'getLive');
     $livestream = new LivestreamCollection();
     $streams = $livestream->all();
     $featuredStream = $livestream->featured();
     return view('livestreams.index', compact('streams', 'featuredStream'));
 }