added search to product lis

pull/36/head
A1Gard 1 year ago
parent 23e5127e53
commit 7bcd5a5a8f

@ -172,10 +172,12 @@ class ProductController extends Controller
if ($request->filter == 'TRASH'){ if ($request->filter == 'TRASH'){
$n = $n->onlyTrashed(); $n = $n->onlyTrashed();
}else{ }else{
$n = $n->where('stock_status', $request->filter); $n = $n->where('stock_status', $request->filter);
} }
} }
if ($request->has('q')){
$n->where('name','LIKE','%'.$request->input('q').'%');
}
$products = $n->paginate(20); $products = $n->paginate(20);
return view('admin.product.productIndex', compact('products')); return view('admin.product.productIndex', compact('products'));
} }

@ -7,6 +7,12 @@
<div class="container"> <div class="container">
@include('starter-kit::component.err') @include('starter-kit::component.err')
<form action="" class="my-2">
<label for="q">
</label>
<input id="q" type="search" name="q" value="{{request()->get('q')}}" class="form-control" placeholder="{{__("Search")}}...">
</form>
<div class="alert alert-dark"> <div class="alert alert-dark">
<span> <span>
{{__("Filter")}}: {{__("Filter")}}:
@ -45,7 +51,7 @@
</th> </th>
<th> <th>
{{__("Action")}} {{__("Action")}}
<a href="{{route('admin.product.create')}}" class="btn btn-success float-start"><i <a href="{{route('admin.product.create')}}" class="btn btn-success float-end"><i
class="fa fa-plus"></i></a> class="fa fa-plus"></i></a>
</th> </th>
</tr> </tr>

Loading…
Cancel
Save