mirror of
https://github.com/NyaaStudios/nyaabooru.git
synced 2025-12-10 05:42:58 +00:00
45 lines
764 B
PHP
45 lines
764 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 placeholder()
|
|
{
|
|
return <<<HTML
|
|
<div class="wa-stack" style="max-height: 80vh;">
|
|
<div class="wa-frame wa-border-radius-l">
|
|
<wa-spinner style="font-size: 3rem; --track-width: 10px;"></wa-spinner>
|
|
</div>
|
|
</div>
|
|
HTML;
|
|
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
if ($this->post == null)
|
|
{
|
|
return <<<'HTML'
|
|
<div></div>
|
|
HTML;
|
|
}
|
|
return view('livewire.post-feature');
|
|
}
|
|
}
|