mirror of
https://github.com/NyaaStudios/nyaabooru.git
synced 2025-12-10 05:42:58 +00:00
add models, setup livewire, setup mongodb
This commit is contained in:
parent
c0590a3412
commit
be4c848eee
27 changed files with 2508 additions and 0 deletions
33
app/Livewire/PostFeature.php
Normal file
33
app/Livewire/PostFeature.php
Normal 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');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue