add models, setup livewire, setup mongodb

This commit is contained in:
yuriko 🦊 2025-05-21 15:14:50 -04:00
parent c0590a3412
commit be4c848eee
Signed by: jaiden
SSH key fingerprint: SHA256:f8tvveBoXBrKZIQDWLLcpQrKbATUCGg98x2N4YzkDM8
27 changed files with 2508 additions and 0 deletions

View file

@ -0,0 +1,33 @@
<?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');
}
}