added search

improved ui of tag & search page
pull/49/head
A1Gard 4 months ago
parent b75f078c56
commit 738e8d7835

@ -228,7 +228,28 @@ class ClientController extends Controller
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)

@ -155,3 +155,10 @@ body {
}
}
.x64-img{
width: 64px;
height: 64px;
object-fit: cover;
}

@ -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>
@ -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>
@ -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>

@ -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>

@ -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>

@ -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>

@ -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>

Loading…
Cancel
Save