feat: implement search functionality in MusicProductionController, enhance view with search form and localization support for search results
This commit is contained in:
@@ -19,10 +19,28 @@ class MusicProductionController extends Controller
|
||||
$settings->{$setting->key} = $setting->value;
|
||||
}
|
||||
|
||||
// Get active music productions
|
||||
$productions = MusicProduction::active()
|
||||
->ordered()
|
||||
->paginate(9); // Using 9 for nice grid layout (3 per row)
|
||||
$search = trim((string) request('q', ''));
|
||||
|
||||
$productionsQuery = MusicProduction::active()->ordered();
|
||||
|
||||
if ($search !== '') {
|
||||
$locale = app()->getLocale();
|
||||
|
||||
$productionsQuery->where(function ($query) use ($search, $locale) {
|
||||
$query->where('title', 'like', "%{$search}%")
|
||||
->orWhere('client_name', 'like', "%{$search}%")
|
||||
->orWhere('slug', 'like', "%{$search}%")
|
||||
->orWhereHas('translations', function ($translationQuery) use ($search, $locale) {
|
||||
$translationQuery
|
||||
->where('status', 'published')
|
||||
->whereIn('field_name', ['title', 'client_name', 'content'])
|
||||
->where('field_value', 'like', "%{$search}%")
|
||||
->where('language_code', $locale);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$productions = $productionsQuery->paginate(9)->withQueryString();
|
||||
|
||||
// --- Footer Logic ---
|
||||
$renderedFooter = null;
|
||||
@@ -50,6 +68,7 @@ class MusicProductionController extends Controller
|
||||
|
||||
return view('front.music-productions.index', [
|
||||
'productions' => $productions,
|
||||
'search' => $search,
|
||||
'settings' => $settings,
|
||||
'header' => 'partials.header-center-nav',
|
||||
'renderedFooter' => $renderedFooter,
|
||||
|
||||
@@ -7,6 +7,8 @@ return [
|
||||
'meta-index-title' => 'Music production, soundtracks and corporate music projects.',
|
||||
'meta-index-description' => 'Explore our albums, singles and production work published on Spotify, YouTube and digital platforms.',
|
||||
'empty' => 'No music productions registered yet.',
|
||||
'search_placeholder' => 'Search by title or client name…',
|
||||
'search_no_results' => 'No results found for “:query”.',
|
||||
'card_category_default' => 'Production',
|
||||
'view_details_tooltip' => 'View details',
|
||||
'project_details' => 'Project Details',
|
||||
|
||||
@@ -7,6 +7,8 @@ return [
|
||||
'meta-index-title' => 'Müzik prodüksiyonu, film müzikleri ve kurumsal müzik çalışmalarımız.',
|
||||
'meta-index-description' => 'Spotify, YouTube ve dijital platformlarda yayımlanan albüm, single ve prodüksiyon projelerimizi keşfedin.',
|
||||
'empty' => 'Şu anda kayıtlı müzik prodüksiyonu bulunmuyor.',
|
||||
'search_placeholder' => 'Başlık veya müşteri adı ile ara…',
|
||||
'search_no_results' => '“:query” için sonuç bulunamadı.',
|
||||
'card_category_default' => 'Prodüksiyon',
|
||||
'view_details_tooltip' => 'Detayları görüntüle',
|
||||
'project_details' => 'Proje Detayları',
|
||||
|
||||
@@ -25,6 +25,22 @@
|
||||
|
||||
<h1 class="xl:!text-[2.4rem] !text-[calc(1.365rem_+_1.38vw)] font-semibold !leading-[1.15] !mb-5 xl:!px-14">{{ __('music_productions.meta-index-title') }}</h1>
|
||||
<p class="lead !text-[1.1rem]">{{ __('music_productions.meta-index-description') }}</p>
|
||||
<form
|
||||
action="{{ route('music-productions.index') }}"
|
||||
method="GET"
|
||||
role="search"
|
||||
class="search-form relative !mt-8 w-full max-w-3xl !mx-auto before:content-['\eca5'] before:block before:absolute before:-translate-y-2/4 before:text-[1.05rem] before:!text-[#747ed1] before:z-[1] before:left-5 before:top-2/4 before:font-Unicons"
|
||||
>
|
||||
<input
|
||||
type="search"
|
||||
name="q"
|
||||
value="{{ $search ?? request('q') }}"
|
||||
class="form-control relative block w-full text-[0.95rem] font-medium !text-[#60697b] bg-[rgba(255,255,255,0.95)] shadow-[0_0_1.25rem_rgba(30,34,40,0.08)] rounded-[50rem] border border-solid border-[rgba(8,60,130,0.1)] !pl-12 !pr-5 py-[0.85rem] min-h-[3rem] focus:shadow-[0_0_1.25rem_rgba(116,126,209,0.18)] focus-visible:!border-[#747ed1] placeholder:!text-[#959ca9] placeholder:opacity-100"
|
||||
placeholder="{{ __('music_productions.search_placeholder') }}"
|
||||
aria-label="{{ __('music_productions.search_placeholder') }}"
|
||||
autocomplete="off"
|
||||
>
|
||||
</form>
|
||||
</div>
|
||||
<!-- /column -->
|
||||
</div>
|
||||
@@ -134,7 +150,13 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-16 h-16 text-gray-300 mx-auto !mb-4">
|
||||
<path d="M12 3v10.55c-.59-.34-1.27-.55-2-.55-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4V7h4V3h-6z"/>
|
||||
</svg>
|
||||
<p class="text-[#aab0bc] text-lg">{{ __('music_productions.empty') }}</p>
|
||||
<p class="text-[#aab0bc] text-lg">
|
||||
@if(!empty($search))
|
||||
{{ __('music_productions.search_no_results', ['query' => $search]) }}
|
||||
@else
|
||||
{{ __('music_productions.empty') }}
|
||||
@endif
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user