mirror of
https://github.com/NyaaStudios/nyaabooru.git
synced 2025-12-10 05:42:58 +00:00
Add post deletion w/ confirmation, search (broken), profile page
This commit is contained in:
parent
bfb497c367
commit
827d125639
21 changed files with 374 additions and 27 deletions
23
app/Livewire/Pages/Profile.php
Normal file
23
app/Livewire/Pages/Profile.php
Normal 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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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
29
app/Livewire/Search.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue