remove posts reference

This commit is contained in:
2025-12-23 10:34:05 +10:00
parent c0e595f88a
commit 74aef68edc
2 changed files with 31 additions and 31 deletions

View File

@@ -34,23 +34,23 @@ class SearchController extends Controller
$workshops = $workshopQuery->orderBy('starts_at', 'desc') $workshops = $workshopQuery->orderBy('starts_at', 'desc')
->paginate(6, ['*'], 'workshop'); ->paginate(6, ['*'], 'workshop');
$postQuery = Post::query()->where('status', 'published'); // $postQuery = Post::query()->where('status', 'published');
$postQuery->where(function ($query) use ($search_words) { // $postQuery->where(function ($query) use ($search_words) {
foreach ($search_words as $word) { // foreach ($search_words as $word) {
$query->where(function ($subQuery) use ($word) { // $query->where(function ($subQuery) use ($word) {
$subQuery->where('title', 'like', '%' . $word . '%') // $subQuery->where('title', 'like', '%' . $word . '%')
->orWhere('content', 'like', '%' . $word . '%'); // ->orWhere('content', 'like', '%' . $word . '%');
}); // });
} // }
}); // });
//
$posts = $postQuery->orderBy('created_at', 'desc') // $posts = $postQuery->orderBy('created_at', 'desc')
->paginate(6, ['*'], 'post') // ->paginate(6, ['*'], 'post')
->onEachSide(1); // ->onEachSide(1);
return view('search', [ return view('search', [
'workshops' => $workshops, 'workshops' => $workshops,
'posts' => $posts, // 'posts' => $posts,
'search' => $search, 'search' => $search,
]); ]);
} }

View File

@@ -1,23 +1,23 @@
<x-layout> <x-layout>
<x-mast title="Search" description='Results for "{{ $search }}"' /> <x-mast title="Search" description='Results for "{{ $search }}"' />
<x-container> <x-container>
<section class="bg-gray-100"> {{-- <section class="bg-gray-100">--}}
<h2 class="text-2xl font-bold my-6">Posts</h2> {{-- <h2 class="text-2xl font-bold my-6">Posts</h2>--}}
@if($posts->isEmpty()) {{-- @if($posts->isEmpty())--}}
<x-container class="mt-8"> {{-- <x-container class="mt-8">--}}
<x-none-found item="posts" search="{{ request()->get('search') }}" /> {{-- <x-none-found item="posts" search="{{ request()->get('search') }}" />--}}
</x-container> {{-- </x-container>--}}
@else {{-- @else--}}
<x-container class="mt-4" inner-class="grid md:grid-cols-2 lg:grid-cols-3 gap-8 w-full"> {{-- <x-container class="mt-4" inner-class="grid md:grid-cols-2 lg:grid-cols-3 gap-8 w-full">--}}
@foreach ($posts as $post) {{-- @foreach ($posts as $post)--}}
<x-panel-post :post="$post" /> {{-- <x-panel-post :post="$post" />--}}
@endforeach {{-- @endforeach--}}
</x-container> {{-- </x-container>--}}
<x-container> {{-- <x-container>--}}
{{ $posts->appends(request()->except('post'))->links('', ['pageName' => 'post']) }} {{-- {{ $posts->appends(request()->except('post'))->links('', ['pageName' => 'post']) }}--}}
</x-container> {{-- </x-container>--}}
@endif {{-- @endif--}}
</section> {{-- </section>--}}
<section class="bg-gray-100"> <section class="bg-gray-100">
<h2 class="text-2xl font-bold my-6">Workshops</h2> <h2 class="text-2xl font-bold my-6">Workshops</h2>