added search

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

@ -228,7 +228,28 @@ class ClientController extends Controller
public function search(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) 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"> <ul class="list-group">
@foreach($posts as $post) @foreach($posts as $post)
<li class="list-group-item"> <li class="list-group-item">
<img src="{{$post->imgUrl()}}" class="float-start x64-img me-2" alt="">
<h6>
<a href="{{$post->webUrl()}}"> <a href="{{$post->webUrl()}}">
{{$post->title}} {{$post->title}}
</a> </a>
</h6>
<p class="text-muted">
{{$post->subtitle}}
</p>
</li> </li>
@endforeach @endforeach
</ul> </ul>
@ -49,9 +55,15 @@
<ul class="list-group"> <ul class="list-group">
@foreach($products as $product) @foreach($products as $product)
<li class="list-group-item"> <li class="list-group-item">
<img src="{{$product->thumbUrl()}}" class="float-start x64-img me-2" alt="">
<h6>
<a href="{{$product->webUrl()}}"> <a href="{{$product->webUrl()}}">
{{$product->name}} {{$product->name}}
</a> </a>
</h6>
<p class="text-muted">
{{$product->excerpt}}
</p>
</li> </li>
@endforeach @endforeach
</ul> </ul>
@ -66,9 +78,15 @@
<ul class="list-group"> <ul class="list-group">
@foreach($clips as $clip) @foreach($clips as $clip)
<li class="list-group-item"> <li class="list-group-item">
<img src="{{$clip->imgUrl()}}" class="float-start x64-img me-2" alt="">
<h6>
<a href="{{$clip->webUrl()}}"> <a href="{{$clip->webUrl()}}">
{{$clip->title}} {{$clip->title}}
</a> </a>
</h6>
<p class="text-muted">
{{Str::limit(strip_tags($clip->body))}}
</p>
</li> </li>
@endforeach @endforeach
</ul> </ul>

@ -2,9 +2,9 @@
<h4> <h4>
{{__("Search")}} {{__("Search")}}
</h4> </h4>
<form action=""> <form action="{{route('client.search')}}" class="side-data">
<div class="input-group mb-3"> <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"> <button class="btn btn-outline-secondary" type="submit" id="button-addon2">
<i class="ri-search-2-line"></i> <i class="ri-search-2-line"></i>
</button> </button>

@ -2,9 +2,9 @@
<h4> <h4>
{{__("Search")}} {{__("Search")}}
</h4> </h4>
<form action=""> <form action="{{route('client.search')}}" class="side-data">
<div class="input-group mb-3"> <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"> <button class="btn btn-outline-secondary" type="submit" id="button-addon2">
<i class="ri-search-2-line"></i> <i class="ri-search-2-line"></i>
</button> </button>

@ -2,9 +2,9 @@
<h4> <h4>
{{__("Search")}} {{__("Search")}}
</h4> </h4>
<form action=""> <form action="{{route('client.search')}}" class="side-data">
<div class="input-group mb-3"> <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"> <button class="btn btn-outline-secondary" type="submit" id="button-addon2">
<i class="ri-search-2-line"></i> <i class="ri-search-2-line"></i>
</button> </button>

@ -3,9 +3,9 @@
<h4> <h4>
{{__("Search")}} {{__("Search")}}
</h4> </h4>
<form action="" class="side-data"> <form action="{{route('client.search')}}" class="side-data">
<div class="input-group mb-3"> <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"> <button class="btn btn-outline-secondary" type="submit" id="button-addon2">
<i class="ri-search-2-line"></i> <i class="ri-search-2-line"></i>
</button> </button>

Loading…
Cancel
Save