Auth: convert auth views and verification email to Nova layout
This commit is contained in:
@@ -4,7 +4,6 @@ namespace App\Services;
|
||||
use App\Models\Artwork;
|
||||
use App\Models\Category;
|
||||
use App\Models\ContentType;
|
||||
use App\Models\ArtworkFeature;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Contracts\Pagination\CursorPaginator;
|
||||
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
|
||||
@@ -220,14 +219,48 @@ class ArtworkService
|
||||
}
|
||||
}
|
||||
|
||||
$categoryIds = $this->categoryAndDescendantIds($current);
|
||||
|
||||
$query = $this->browseQuery($sort)
|
||||
->whereHas('categories', function ($q) use ($current) {
|
||||
$q->where('categories.id', $current->id);
|
||||
->whereHas('categories', function ($q) use ($categoryIds) {
|
||||
$q->whereIn('categories.id', $categoryIds);
|
||||
});
|
||||
|
||||
return $query->cursorPaginate($perPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collect category id plus all descendant category ids.
|
||||
*
|
||||
* @return array<int, int>
|
||||
*/
|
||||
private function categoryAndDescendantIds(Category $category): array
|
||||
{
|
||||
$allIds = [(int) $category->id];
|
||||
$frontier = [(int) $category->id];
|
||||
|
||||
while (! empty($frontier)) {
|
||||
$children = Category::whereIn('parent_id', $frontier)
|
||||
->pluck('id')
|
||||
->map(static fn ($id): int => (int) $id)
|
||||
->all();
|
||||
|
||||
if (empty($children)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$newIds = array_values(array_diff($children, $allIds));
|
||||
if (empty($newIds)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$allIds = array_values(array_unique(array_merge($allIds, $newIds)));
|
||||
$frontier = $newIds;
|
||||
}
|
||||
|
||||
return $allIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get featured artworks ordered by featured_at DESC, optionally filtered by type.
|
||||
* Uses artwork_features table and applies public/approved/published filters.
|
||||
|
||||
Reference in New Issue
Block a user