Pint
This commit is contained in:
@@ -5,7 +5,6 @@ namespace App\Livewire;
|
||||
use App\Models\Comment;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AdminCommentSearch extends Component
|
||||
{
|
||||
@@ -41,7 +40,7 @@ class AdminCommentSearch extends Component
|
||||
->paginate(12);
|
||||
|
||||
return view('livewire.admin-comment-search', [
|
||||
'comments' => $comments
|
||||
'comments' => $comments,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,9 @@ namespace App\Livewire;
|
||||
use App\Enums\UserRole;
|
||||
use App\Models\Comment;
|
||||
use App\Models\User;
|
||||
|
||||
use Livewire\Attributes\Url;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Livewire\Attributes\Url;
|
||||
|
||||
class AdminUserSearch extends Component
|
||||
{
|
||||
@@ -41,12 +40,12 @@ class AdminUserSearch extends Component
|
||||
{
|
||||
$users = User::when($this->patreon !== [], fn ($query) => $query->whereJsonContains('roles', UserRole::SUPPORTER->value))
|
||||
->when($this->banned !== [], fn ($query) => $query->whereJsonContains('roles', UserRole::BANNED->value))
|
||||
->when($this->search !== '', fn ($query) => $query->where('name', 'like', '%'.$this->search.'%'))
|
||||
->when($this->search !== '', fn ($query) => $query->where('name', 'like', '%'.$this->search.'%'))
|
||||
->when($this->discordId !== '', fn ($query) => $query->where('discord_id', '=', $this->discordId))
|
||||
->paginate(20);
|
||||
|
||||
return view('livewire.admin-user-search', [
|
||||
'users' => $users
|
||||
'users' => $users,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Livewire\Attributes\Url;
|
||||
|
||||
use App\Models\SiteBackground;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Livewire\Attributes\Url;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class BackgroundImages extends Component
|
||||
{
|
||||
@@ -19,17 +18,15 @@ class BackgroundImages extends Component
|
||||
public function render()
|
||||
{
|
||||
$now = Carbon::now();
|
||||
|
||||
$images = SiteBackground::when($this->filter === 'active', fn ($query) =>
|
||||
$query->whereDate('date_start', '<=', $now)->whereDate('date_end', '>=', $now)
|
||||
)
|
||||
->when($this->filter === 'inactive', fn ($query) =>
|
||||
$query->whereDate('date_start', '>', $now)->orWhereDate('date_end', '<', $now)
|
||||
|
||||
$images = SiteBackground::when($this->filter === 'active', fn ($query) => $query->whereDate('date_start', '<=', $now)->whereDate('date_end', '>=', $now)
|
||||
)
|
||||
->when($this->filter === 'inactive', fn ($query) => $query->whereDate('date_start', '>', $now)->orWhereDate('date_end', '<', $now)
|
||||
)
|
||||
->paginate(10);
|
||||
|
||||
return view('livewire.background-images', [
|
||||
'images' => $images
|
||||
'images' => $images,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\Episode;
|
||||
use App\Models\User;
|
||||
use App\Notifications\CommentNotification;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Component;
|
||||
use Maize\Markable\Models\Like;
|
||||
|
||||
class Comment extends Component
|
||||
@@ -30,21 +26,21 @@ class Comment extends Component
|
||||
public $liked = false;
|
||||
|
||||
public $replyState = [
|
||||
'body' => ''
|
||||
'body' => '',
|
||||
];
|
||||
|
||||
public $isEditing = false;
|
||||
|
||||
public $editState = [
|
||||
'body' => ''
|
||||
'body' => '',
|
||||
];
|
||||
|
||||
protected $listeners = [
|
||||
'refresh' => '$refresh'
|
||||
'refresh' => '$refresh',
|
||||
];
|
||||
|
||||
protected $validationAttributes = [
|
||||
'replyState.body' => 'reply'
|
||||
'replyState.body' => 'reply',
|
||||
];
|
||||
|
||||
public function updatedIsEditing($isEditing)
|
||||
@@ -54,7 +50,7 @@ class Comment extends Component
|
||||
}
|
||||
|
||||
$this->editState = [
|
||||
'body' => $this->comment->body
|
||||
'body' => $this->comment->body,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -73,13 +69,14 @@ class Comment extends Component
|
||||
|
||||
$this->comment->delete();
|
||||
|
||||
$this->dispatch('refresh');
|
||||
$this->dispatch('refresh');
|
||||
}
|
||||
|
||||
public function postReply()
|
||||
{
|
||||
if (!($this->comment->depth() < 2)) {
|
||||
$this->addError('replyState.body', "Too many sub comments.");
|
||||
if (! ($this->comment->depth() < 2)) {
|
||||
$this->addError('replyState.body', 'Too many sub comments.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -91,13 +88,14 @@ class Comment extends Component
|
||||
$seconds = RateLimiter::availableIn($rateLimitKey);
|
||||
|
||||
$this->addError('replyState.body', "Too many comments. Try again in {$seconds} seconds.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
RateLimiter::hit($rateLimitKey, $rateLimitMinutes);
|
||||
|
||||
$this->validate([
|
||||
'replyState.body' => 'required'
|
||||
'replyState.body' => 'required',
|
||||
]);
|
||||
|
||||
$reply = $this->comment->children()->make($this->replyState);
|
||||
@@ -110,25 +108,25 @@ class Comment extends Component
|
||||
if ($reply->commentable_type == Episode::class && $user->id !== $reply->parent->user->id) {
|
||||
$episode = Episode::where('id', $reply->commentable_id)
|
||||
->firstOrFail();
|
||||
|
||||
|
||||
$url = route('hentai.index', ['title' => $episode->slug]);
|
||||
|
||||
$reply->parent->user->notify(
|
||||
new CommentNotification(
|
||||
"{$user->name} replied to your comment.",
|
||||
Str::limit($reply->body, 50),
|
||||
"{$user->name} replied to your comment.",
|
||||
Str::limit($reply->body, 50),
|
||||
"{$url}#comment-{$reply->id}"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->replyState = [
|
||||
'body' => ''
|
||||
'body' => '',
|
||||
];
|
||||
|
||||
$this->isReplying = false;
|
||||
|
||||
$this->dispatch('refresh')->self();
|
||||
$this->dispatch('refresh')->self();
|
||||
}
|
||||
|
||||
public function like()
|
||||
@@ -144,6 +142,7 @@ class Comment extends Component
|
||||
if ($this->liked) {
|
||||
$this->liked = false;
|
||||
$this->likeCount--;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -163,4 +162,4 @@ class Comment extends Component
|
||||
{
|
||||
return view('livewire.comment');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
|
||||
class Comments extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
@@ -14,21 +13,21 @@ class Comments extends Component
|
||||
public $model;
|
||||
|
||||
public $newCommentState = [
|
||||
'body' => ''
|
||||
'body' => '',
|
||||
];
|
||||
|
||||
protected $validationAttributes = [
|
||||
'newCommentState.body' => 'comment'
|
||||
'newCommentState.body' => 'comment',
|
||||
];
|
||||
|
||||
protected $listeners = [
|
||||
'refresh' => '$refresh'
|
||||
'refresh' => '$refresh',
|
||||
];
|
||||
|
||||
public function postComment()
|
||||
{
|
||||
$this->validate([
|
||||
'newCommentState.body' => 'required'
|
||||
'newCommentState.body' => 'required',
|
||||
]);
|
||||
|
||||
$user = auth()->user();
|
||||
@@ -39,6 +38,7 @@ class Comments extends Component
|
||||
$seconds = RateLimiter::availableIn($rateLimitKey);
|
||||
|
||||
$this->addError('newCommentState.body', "Too many comments. Try again in {$seconds} seconds.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class Comments extends Component
|
||||
$comment->save();
|
||||
|
||||
$this->newCommentState = [
|
||||
'body' => ''
|
||||
'body' => '',
|
||||
];
|
||||
|
||||
$this->resetPage();
|
||||
@@ -65,7 +65,7 @@ class Comments extends Component
|
||||
->paginate(50);
|
||||
|
||||
return view('livewire.comments', [
|
||||
'comments' => $comments
|
||||
'comments' => $comments,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class DownloadButton extends Component
|
||||
public $fillNumbers;
|
||||
|
||||
public $fileSize;
|
||||
|
||||
|
||||
public $background = 'bg-rose-600';
|
||||
|
||||
public $fileExtension = 'HEVC';
|
||||
@@ -33,7 +33,7 @@ class DownloadButton extends Component
|
||||
public function clicked($downloadId)
|
||||
{
|
||||
$download = Downloads::find($downloadId);
|
||||
if (!$download) {
|
||||
if (! $download) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,9 @@ namespace App\Livewire;
|
||||
use App\Models\Episode;
|
||||
use App\Models\User;
|
||||
use App\Models\UserDownload;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
|
||||
class DownloadsFree extends Component
|
||||
{
|
||||
@@ -51,6 +49,7 @@ class DownloadsFree extends Component
|
||||
if (Carbon::parse($alreadyDownloaded->created_at)->addHours(6) <= Carbon::now()) {
|
||||
// Already expired
|
||||
$alreadyDownloaded->delete();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -65,6 +64,7 @@ class DownloadsFree extends Component
|
||||
if ($user->downloads_left <= 0) {
|
||||
// Daily limit reached
|
||||
$this->granted = 3;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -75,9 +75,9 @@ class DownloadsFree extends Component
|
||||
$this->granted = 1;
|
||||
|
||||
UserDownload::create([
|
||||
'user_id' => $user->id,
|
||||
'episode_id' => $this->episodeId,
|
||||
'interpolated' => $this->interpolated,
|
||||
'user_id' => $user->id,
|
||||
'episode_id' => $this->episodeId,
|
||||
'interpolated' => $this->interpolated,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Downloads;
|
||||
use Livewire\Attributes\Url;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Livewire\Attributes\Url;
|
||||
|
||||
class DownloadsSearch extends Component
|
||||
{
|
||||
@@ -17,7 +17,7 @@ class DownloadsSearch extends Component
|
||||
public $order = 'created_at_desc';
|
||||
|
||||
public $options = [
|
||||
'FHD' => true,
|
||||
'FHD' => true,
|
||||
'FHD 48fps' => true,
|
||||
];
|
||||
|
||||
@@ -25,24 +25,25 @@ class DownloadsSearch extends Component
|
||||
|
||||
#[Url(history: true)]
|
||||
public $studios = [];
|
||||
|
||||
public $studiosCopy = [];
|
||||
|
||||
// To toggle individual option selection
|
||||
public function toggleOption($option)
|
||||
{
|
||||
$this->options[$option] = !$this->options[$option];
|
||||
$this->options[$option] = ! $this->options[$option];
|
||||
$this->resetPage();
|
||||
}
|
||||
|
||||
// To toggle dropdown visibility
|
||||
public function toggleDropdown()
|
||||
{
|
||||
$this->isOpen = !$this->isOpen;
|
||||
$this->isOpen = ! $this->isOpen;
|
||||
}
|
||||
|
||||
protected $queryString = [
|
||||
'fileSearch' => ['except' => '', 'as' => 'fS'],
|
||||
'order' => ['except' => '', 'as' => 'order'],
|
||||
'fileSearch' => ['except' => '', 'as' => 'fS'],
|
||||
'order' => ['except' => '', 'as' => 'order'],
|
||||
];
|
||||
|
||||
public function updatingFileSearch()
|
||||
@@ -87,7 +88,7 @@ class DownloadsSearch extends Component
|
||||
public function clicked($downloadId)
|
||||
{
|
||||
$download = Downloads::find($downloadId);
|
||||
if (!$download) {
|
||||
if (! $download) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -96,9 +97,9 @@ class DownloadsSearch extends Component
|
||||
cache()->forget("episode_{$download->episode->id}_download_{$download->type}");
|
||||
}
|
||||
|
||||
public function mount()
|
||||
public function mount()
|
||||
{
|
||||
if (!auth()->user()->hasRole(\App\Enums\UserRole::SUPPORTER)) {
|
||||
if (! auth()->user()->hasRole(\App\Enums\UserRole::SUPPORTER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -144,15 +145,17 @@ class DownloadsSearch extends Component
|
||||
|
||||
$downloads = Downloads::when($this->fileSearch != '', fn ($query) => $query->where('url', 'like', '%'.$this->fileSearch.'%'))
|
||||
->whereIn('type', $this->getSelectedTypes())
|
||||
->when($this->studios !== [], fn ($q) => $q->whereHas('episode', fn ($query) => $query->whereHas('studio', function ($query) { $query->whereIn('slug', $this->studios); })))
|
||||
->when($this->studios !== [], fn ($q) => $q->whereHas('episode', fn ($query) => $query->whereHas('studio', function ($query) {
|
||||
$query->whereIn('slug', $this->studios);
|
||||
})))
|
||||
->whereNotNull('size')
|
||||
->orderBy($orderby, $orderdirection)
|
||||
->paginate(20);
|
||||
|
||||
return view('livewire.downloads-search', [
|
||||
'downloads' => $downloads,
|
||||
'query' => $this->fileSearch,
|
||||
'studiocount' => is_array($this->studios) ? count($this->studios) : 0,
|
||||
'downloads' => $downloads,
|
||||
'query' => $this->fileSearch,
|
||||
'studiocount' => is_array($this->studios) ? count($this->studios) : 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,9 @@ namespace App\Livewire;
|
||||
|
||||
use App\Models\Episode;
|
||||
use App\Models\User;
|
||||
use Livewire\Component;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
use Livewire\Component;
|
||||
use Maize\Markable\Models\Like;
|
||||
|
||||
class LikeButton extends Component
|
||||
@@ -52,6 +51,7 @@ class LikeButton extends Component
|
||||
if ($this->liked) {
|
||||
$this->liked = false;
|
||||
$this->likeCount--;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Episode;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Attributes\Url;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Livewire\Attributes\Url;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class LiveSearch extends Component
|
||||
{
|
||||
@@ -20,14 +20,17 @@ class LiveSearch extends Component
|
||||
|
||||
#[Url(history: true)]
|
||||
public $tags = [];
|
||||
|
||||
public $tagsCopy = [];
|
||||
|
||||
#[Url(history: true)]
|
||||
public $studios = [];
|
||||
|
||||
public $studiosCopy = [];
|
||||
|
||||
#[Url(history: true)]
|
||||
public $blacklist = [];
|
||||
|
||||
public $blacklistCopy = [];
|
||||
|
||||
#[Url(history: true)]
|
||||
@@ -72,7 +75,7 @@ class LiveSearch extends Component
|
||||
public function mount()
|
||||
{
|
||||
// User blacklist
|
||||
if (Auth::check() && empty($this->blacklist) && !empty(auth()->user()->tag_blacklist)) {
|
||||
if (Auth::check() && empty($this->blacklist) && ! empty(auth()->user()->tag_blacklist)) {
|
||||
$this->blacklist = auth()->user()->tag_blacklist;
|
||||
}
|
||||
|
||||
@@ -118,11 +121,15 @@ class LiveSearch extends Component
|
||||
}
|
||||
|
||||
$user_id = Auth::check() ? auth()->user()->id : 0;
|
||||
$episodes = Episode::with('gallery')->when($this->search != '', fn ($query) => $query->where(function($query) { $query->where('title', 'like', '%'.$this->search.'%')->orWhere('title_search', 'like', '%'.$this->search.'%')->orWhere('title_jpn', 'like', '%'.$this->search.'%'); }))
|
||||
->when($this->tags !== [], fn ($query) => $query->withAllTags($this->tags))
|
||||
->when($this->blacklist !== [], fn ($query) => $query->withoutTags($this->blacklist))
|
||||
->when($this->studios !== [], fn ($query) => $query->whereHas('studio', function ($query) { $query->whereIn('slug', $this->studios); }))
|
||||
->when($this->hideWatched !== [] && Auth::check(), fn ($query) => $query->whereDoesntHave('watched', function ($query) use ($user_id) {
|
||||
$episodes = Episode::with('gallery')->when($this->search != '', fn ($query) => $query->where(function ($query) {
|
||||
$query->where('title', 'like', '%'.$this->search.'%')->orWhere('title_search', 'like', '%'.$this->search.'%')->orWhere('title_jpn', 'like', '%'.$this->search.'%');
|
||||
}))
|
||||
->when($this->tags !== [], fn ($query) => $query->withAllTags($this->tags))
|
||||
->when($this->blacklist !== [], fn ($query) => $query->withoutTags($this->blacklist))
|
||||
->when($this->studios !== [], fn ($query) => $query->whereHas('studio', function ($query) {
|
||||
$query->whereIn('slug', $this->studios);
|
||||
}))
|
||||
->when($this->hideWatched !== [] && Auth::check(), fn ($query) => $query->whereDoesntHave('watched', function ($query) use ($user_id) {
|
||||
$query->where('user_id', $user_id);
|
||||
}))
|
||||
->when(Auth::guest(), fn ($query) => $query->withoutTags(['loli', 'shota']))
|
||||
@@ -140,16 +147,16 @@ class LiveSearch extends Component
|
||||
$this->dispatch('contentChanged');
|
||||
|
||||
return view('livewire.live-search', [
|
||||
'episodes' => $episodes,
|
||||
'tagcount' => is_array($this->tags) ? count($this->tags) : 0,
|
||||
'studiocount' => is_array($this->studios) ? count($this->studios) : 0,
|
||||
'blacklistcount' => is_array($this->blacklist) ? count($this->blacklist) : 0,
|
||||
'query' => $this->search,
|
||||
'selectedtags' => $this->tags,
|
||||
'selectedstudios' => $this->studios,
|
||||
'episodes' => $episodes,
|
||||
'tagcount' => is_array($this->tags) ? count($this->tags) : 0,
|
||||
'studiocount' => is_array($this->studios) ? count($this->studios) : 0,
|
||||
'blacklistcount' => is_array($this->blacklist) ? count($this->blacklist) : 0,
|
||||
'query' => $this->search,
|
||||
'selectedtags' => $this->tags,
|
||||
'selectedstudios' => $this->studios,
|
||||
'selectedblacklist' => $this->blacklist,
|
||||
'searchIsJpn' => $searchIsJpn,
|
||||
'view' => $this->view,
|
||||
'searchIsJpn' => $searchIsJpn,
|
||||
'view' => $this->view,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Episode;
|
||||
use Livewire\Component;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
|
||||
class NavLiveSearch extends Component
|
||||
{
|
||||
@@ -25,9 +25,9 @@ class NavLiveSearch extends Component
|
||||
}
|
||||
|
||||
return view('livewire.nav-live-search', [
|
||||
'episodes' => $episodes,
|
||||
'query' => $this->navSearch,
|
||||
'hide' => empty($this->navSearch),
|
||||
'episodes' => $episodes,
|
||||
'query' => $this->navSearch,
|
||||
'hide' => empty($this->navSearch),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,11 @@ namespace App\Livewire;
|
||||
use App\Models\Playlist;
|
||||
use App\Models\PlaylistEpisode;
|
||||
use App\Services\PlaylistService;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Attributes\Url;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Livewire\Attributes\Url;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class PlaylistOverview extends Component
|
||||
{
|
||||
|
||||
@@ -3,10 +3,9 @@
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Playlist;
|
||||
|
||||
use Livewire\Attributes\Url;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Livewire\Attributes\Url;
|
||||
|
||||
class Playlists extends Component
|
||||
{
|
||||
@@ -54,12 +53,12 @@ class Playlists extends Component
|
||||
$playlists = Playlist::where('is_private', 0)
|
||||
->withCount('episodes')
|
||||
->having('episodes_count', '>', 1)
|
||||
->when($this->search != '', fn($query) => $query->where('name', 'like', '%' . $this->search . '%'))
|
||||
->when($this->search != '', fn ($query) => $query->where('name', 'like', '%'.$this->search.'%'))
|
||||
->orderBy($orderby, $orderdirection)
|
||||
->paginate($this->pagination);
|
||||
|
||||
return view('livewire.playlists', [
|
||||
'playlists' => $playlists
|
||||
'playlists' => $playlists,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Comment;
|
||||
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
@@ -36,14 +35,13 @@ class UserComments extends Component
|
||||
$orderdirection = 'desc';
|
||||
}
|
||||
|
||||
|
||||
$comments = Comment::where('user_id', $this->model->id)
|
||||
->when($this->commentSearch != '', fn ($query) => $query->where('body', 'like', '%'.$this->commentSearch.'%'))
|
||||
->orderBy($orderby, $orderdirection)
|
||||
->paginate(10);
|
||||
|
||||
return view('livewire.user-comments', [
|
||||
'comments' => $comments
|
||||
'comments' => $comments,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Episode;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Attributes\Url;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
use Livewire\Attributes\Url;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class UserLikes extends Component
|
||||
{
|
||||
@@ -20,14 +20,17 @@ class UserLikes extends Component
|
||||
|
||||
#[Url(history: true)]
|
||||
public $tags = [];
|
||||
|
||||
public $tagsCopy = [];
|
||||
|
||||
#[Url(history: true)]
|
||||
public $studios = [];
|
||||
|
||||
public $studiosCopy = [];
|
||||
|
||||
#[Url(history: true)]
|
||||
public $blacklist = [];
|
||||
|
||||
public $blacklistCopy = [];
|
||||
|
||||
#[Url(history: true)]
|
||||
@@ -72,7 +75,7 @@ class UserLikes extends Component
|
||||
public function mount()
|
||||
{
|
||||
// User blacklist
|
||||
if (Auth::check() && empty($this->blacklist) && !empty(auth()->user()->tag_blacklist)) {
|
||||
if (Auth::check() && empty($this->blacklist) && ! empty(auth()->user()->tag_blacklist)) {
|
||||
$this->blacklist = auth()->user()->tag_blacklist;
|
||||
}
|
||||
|
||||
@@ -119,11 +122,15 @@ class UserLikes extends Component
|
||||
|
||||
$user_id = Auth::check() ? auth()->user()->id : 0;
|
||||
$episodes = Episode::whereHasLike(auth()->user())
|
||||
->when($this->search !== '', fn ($query) => $query->where(function($query) { $query->where('title', 'like', '%'.$this->search.'%')->orWhere('title_search', 'like', '%'.$this->search.'%')->orWhere('title_jpn', 'like', '%'.$this->search.'%'); }))
|
||||
->when($this->tags !== [], fn ($query) => $query->withAllTags($this->tags))
|
||||
->when($this->blacklist !== [], fn ($query) => $query->withoutTags($this->blacklist))
|
||||
->when($this->studios !== [], fn ($query) => $query->whereHas('studio', function ($query) { $query->whereIn('slug', $this->studios); }))
|
||||
->when($this->hideWatched !== [] && Auth::check(), fn ($query) => $query->whereDoesntHave('watched', function ($query) use ($user_id) {
|
||||
->when($this->search !== '', fn ($query) => $query->where(function ($query) {
|
||||
$query->where('title', 'like', '%'.$this->search.'%')->orWhere('title_search', 'like', '%'.$this->search.'%')->orWhere('title_jpn', 'like', '%'.$this->search.'%');
|
||||
}))
|
||||
->when($this->tags !== [], fn ($query) => $query->withAllTags($this->tags))
|
||||
->when($this->blacklist !== [], fn ($query) => $query->withoutTags($this->blacklist))
|
||||
->when($this->studios !== [], fn ($query) => $query->whereHas('studio', function ($query) {
|
||||
$query->whereIn('slug', $this->studios);
|
||||
}))
|
||||
->when($this->hideWatched !== [] && Auth::check(), fn ($query) => $query->whereDoesntHave('watched', function ($query) use ($user_id) {
|
||||
$query->where('user_id', $user_id);
|
||||
}))
|
||||
->orderBy($orderby, $orderdirection)
|
||||
@@ -137,16 +144,16 @@ class UserLikes extends Component
|
||||
}
|
||||
|
||||
return view('livewire.user-likes', [
|
||||
'episodes' => $episodes,
|
||||
'tagcount' => is_array($this->tags) ? count($this->tags) : 0,
|
||||
'studiocount' => is_array($this->studios) ? count($this->studios) : 0,
|
||||
'blacklistcount' => is_array($this->blacklist) ? count($this->blacklist) : 0,
|
||||
'query' => $this->search,
|
||||
'selectedtags' => $this->tags,
|
||||
'selectedstudios' => $this->studios,
|
||||
'episodes' => $episodes,
|
||||
'tagcount' => is_array($this->tags) ? count($this->tags) : 0,
|
||||
'studiocount' => is_array($this->studios) ? count($this->studios) : 0,
|
||||
'blacklistcount' => is_array($this->blacklist) ? count($this->blacklist) : 0,
|
||||
'query' => $this->search,
|
||||
'selectedtags' => $this->tags,
|
||||
'selectedstudios' => $this->studios,
|
||||
'selectedblacklist' => $this->blacklist,
|
||||
'searchIsJpn' => $searchIsJpn,
|
||||
'view' => $this->view,
|
||||
'searchIsJpn' => $searchIsJpn,
|
||||
'view' => $this->view,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Watched as UserWatched;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
@@ -14,7 +13,7 @@ class Watched extends Component
|
||||
|
||||
public $userId;
|
||||
|
||||
public function mount($user)
|
||||
public function mount($user)
|
||||
{
|
||||
$this->userId = $user ? $user->id : auth()->user()->id;
|
||||
}
|
||||
@@ -27,8 +26,8 @@ class Watched extends Component
|
||||
});
|
||||
|
||||
return view('livewire.watched', [
|
||||
'watched' => $watched,
|
||||
'watchedGrouped' => $watchedGrouped,
|
||||
'watched' => $watched,
|
||||
'watchedGrouped' => $watchedGrouped,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user