Add post deletion w/ confirmation, search (broken), profile page

This commit is contained in:
yuriko 🦊 2025-05-24 19:30:44 -04:00
parent bfb497c367
commit 827d125639
21 changed files with 374 additions and 27 deletions

View file

@ -0,0 +1,23 @@
<?php
namespace App\Livewire\Pages;
use App\Models\Comment;
use App\Models\Post;
use App\Models\User;
use Livewire\Component;
class Profile extends Component
{
public User $user;
public function render()
{
$favorite_posts = $this->user->favorites()->withType(Post::class)->count();
$favorite_comments = $this->user->favorites()->withType(Comment::class)->count();
return view('livewire.pages.profile', [
'favorite_posts' => $favorite_posts, 'favorite_comments' => $favorite_comments
])->title($this->user->name);
}
}

View file

@ -15,7 +15,7 @@ class Upload extends Component
{
use WithFileUploads;
#[Validate('extensions:jpg,jpeg,bmp,gif,png,webp,apng,mp4,wmv,mkv|mimes:jpg,jpeg,bmp,gif,png,webp,apng,mp4,wmv,mkv|max:81920')]
#[Validate('file')]
public $file;
#[Validate('required|in:safe,suggestive,explicit')]

29
app/Livewire/Search.php Normal file
View file

@ -0,0 +1,29 @@
<?php
namespace App\Livewire;
use App\Models\User;
use Livewire\Attributes\Validate;
use Livewire\Component;
use Spatie\Searchable\ModelSearchAspect;
use Spatie\Searchable\Search as SpatieSearch;
class Search extends Component
{
#[Validate('string|min:3')]
public string $searchText = '';
public $searchResults = [];
public function render()
{
return view('livewire.search');
}
public function updated()
{
$this->searchResults = (new SpatieSearch())
->registerModel(User::class, 'name')
->perform($this->searchText);
}
}