mirror of
https://github.com/NyaaStudios/nyaabooru.git
synced 2025-12-10 05:42:58 +00:00
33 lines
521 B
PHP
33 lines
521 B
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use App\Models\Post;
|
|
use Livewire\Component;
|
|
|
|
class PostFeature extends Component
|
|
{
|
|
public ?Post $post = null;
|
|
|
|
public function mount()
|
|
{
|
|
$this->post = Post::raw(function($collection)
|
|
{
|
|
return $collection->aggregate([
|
|
['$match' => ['featured' => 'on']],
|
|
['$sample' => ['size' => 1]]
|
|
]);
|
|
})->first();
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
if ($this->post == null)
|
|
{
|
|
return <<<'HTML'
|
|
<div></div>
|
|
HTML;
|
|
}
|
|
return view('livewire.post-feature');
|
|
}
|
|
}
|