update: livewire

This commit is contained in:
HDVinnie
2024-03-03 22:41:29 -05:00
parent 8d6e3631fe
commit bde593e48b
117 changed files with 1792 additions and 1735 deletions
+6 -3
View File
@@ -20,14 +20,17 @@ use Livewire\Component;
class BookmarkButton extends Component
{
public Torrent $torrent;
public User $user;
public bool $isBookmarked;
public int $bookmarksCount;
final public function store(): void
{
if ($this->user->bookmarks()->where('torrent_id', '=', $this->torrent->id)->exists()) {
$this->dispatchBrowserEvent('error', ['type' => 'error', 'message' => 'Torrent Has Already Been Bookmarked!']);
$this->dispatch('error', type: 'error', message: 'Torrent Has Already Been Bookmarked!');
return;
}
@@ -35,7 +38,7 @@ class BookmarkButton extends Component
$this->user->bookmarks()->attach($this->torrent->id);
$this->isBookmarked = true;
$this->bookmarksCount++;
$this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'Torrent Has Been Bookmarked Successfully!']);
$this->dispatch('success', type: 'success', message: 'Torrent Has Been Bookmarked Successfully!');
}
final public function destroy(): void
@@ -43,7 +46,7 @@ class BookmarkButton extends Component
$this->user->bookmarks()->detach($this->torrent->id);
$this->isBookmarked = false;
$this->bookmarksCount--;
$this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'Torrent Has Been Unbookmarked Successfully!']);
$this->dispatch('success', type: 'success', message: 'Torrent Has Been Unbookmarked Successfully!');
}
final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application