nyaabooru/app/Livewire/PostFeature.php
Jaiden f60ae41bf6
Some checks failed
Docker / build (push) Has been cancelled
better image uploading & user roles
2025-08-09 23:01:27 -04:00

45 lines
848 B
PHP

<?php
namespace App\Livewire;
use App\Models\Post;
use Livewire\Component;
class PostFeature extends Component
{
public ?Post $post = null;
public $tags = null;
public function mount()
{
$this->post = Post::raw(function($collection)
{
return $collection->aggregate([
['$match' => ['featured' => 'on']],
['$sample' => ['size' => 1]]
]);
})->first();
$this->tags = $this->post->tags()->take(5)->get();
}
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 view('livewire.post-feature-empty');
}
return view('livewire.post-feature');
}
}