Skip to content

Commit

Permalink
added search
Browse files Browse the repository at this point in the history
improved ui of tag & search page
  • Loading branch information
A1Gard committed Sep 1, 2024
1 parent b75f078 commit 738e8d7
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 18 deletions.
23 changes: 22 additions & 1 deletion app/Http/Controllers/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,28 @@ public function submitComment(Request $request)

public function search(Request $request)
{

$q = trim($request->input('q'));
if (mb_strlen($q) < 3) {
return abort(403, __('Search word is too short'));
}
$q = '%'.$q.'%';
$posts = Post::where('status', 1)->where(function($query) use ($q) {
$query->where('title', 'LIKE', $q)
->orWhere('subtitle', 'LIKE', $q)
->orWhere('body', 'LIKE', $q);
})->paginate(100);
$products = Product::where('status', 1)->where(function($query) use ($q) {
$query->where('name', 'LIKE', $q)
->orWhere('excerpt', 'LIKE', $q)
->orWhere('description', 'LIKE', $q);
})->paginate(100);
$clips = Clip::where('status', 1)->where(function($query) use ($q) {
$query->where('title', 'LIKE', $q)
->orWhere('body', 'LIKE', $q);
})->paginate(100);
$title = __('Search for') . ': ' . $request->input('q');
$subtitle = '';
return view('client.tag', compact('posts', 'products', 'clips', 'title', 'subtitle'));
}

public function group($slug)
Expand Down
7 changes: 7 additions & 0 deletions resources/sass/client-custom/_general.scss
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,10 @@ body {

}
}


.x64-img{
width: 64px;
height: 64px;
object-fit: cover;
}
36 changes: 27 additions & 9 deletions resources/views/client/tag.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@
<ul class="list-group">
@foreach($posts as $post)
<li class="list-group-item">
<a href="{{$post->webUrl()}}">
{{$post->title}}
</a>
<img src="{{$post->imgUrl()}}" class="float-start x64-img me-2" alt="">
<h6>
<a href="{{$post->webUrl()}}">
{{$post->title}}
</a>
</h6>
<p class="text-muted">
{{$post->subtitle}}
</p>
</li>
@endforeach
</ul>
Expand All @@ -49,9 +55,15 @@
<ul class="list-group">
@foreach($products as $product)
<li class="list-group-item">
<a href="{{$product->webUrl()}}">
{{$product->name}}
</a>
<img src="{{$product->thumbUrl()}}" class="float-start x64-img me-2" alt="">
<h6>
<a href="{{$product->webUrl()}}">
{{$product->name}}
</a>
</h6>
<p class="text-muted">
{{$product->excerpt}}
</p>
</li>
@endforeach
</ul>
Expand All @@ -66,9 +78,15 @@
<ul class="list-group">
@foreach($clips as $clip)
<li class="list-group-item">
<a href="{{$clip->webUrl()}}">
{{$clip->title}}
</a>
<img src="{{$clip->imgUrl()}}" class="float-start x64-img me-2" alt="">
<h6>
<a href="{{$clip->webUrl()}}">
{{$clip->title}}
</a>
</h6>
<p class="text-muted">
{{Str::limit(strip_tags($clip->body))}}
</p>
</li>
@endforeach
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<h4>
{{__("Search")}}
</h4>
<form action="">
<form action="{{route('client.search')}}" class="side-data">
<div class="input-group mb-3">
<input type="search" class="form-control" placeholder="{{__('Search')}}...">
<input type="search" name="q" class="form-control" placeholder="{{__('Search')}}...">
<button class="btn btn-outline-secondary" type="submit" id="button-addon2">
<i class="ri-search-2-line"></i>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<h4>
{{__("Search")}}
</h4>
<form action="">
<form action="{{route('client.search')}}" class="side-data">
<div class="input-group mb-3">
<input type="search" class="form-control" placeholder="{{__('Search')}}...">
<input type="search" name="q" class="form-control" placeholder="{{__('Search')}}...">
<button class="btn btn-outline-secondary" type="submit" id="button-addon2">
<i class="ri-search-2-line"></i>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<h4>
{{__("Search")}}
</h4>
<form action="">
<form action="{{route('client.search')}}" class="side-data">
<div class="input-group mb-3">
<input type="search" class="form-control" placeholder="{{__('Search')}}...">
<input type="search" name="q" class="form-control" placeholder="{{__('Search')}}...">
<button class="btn btn-outline-secondary" type="submit" id="button-addon2">
<i class="ri-search-2-line"></i>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<h4>
{{__("Search")}}
</h4>
<form action="" class="side-data">
<form action="{{route('client.search')}}" class="side-data">
<div class="input-group mb-3">
<input type="search" class="form-control" placeholder="{{__('Search')}}...">
<input type="search" name="q" class="form-control" placeholder="{{__('Search')}}...">
<button class="btn btn-outline-secondary" type="submit" id="button-addon2">
<i class="ri-search-2-line"></i>
</button>
Expand Down

0 comments on commit 738e8d7

Please sign in to comment.