✨ Ajoute la recherche par commentaire
This commit is contained in:
parent
ad682460e2
commit
42ab41af8c
@ -27,6 +27,11 @@ class Home extends Model implements Feedable
|
|||||||
return Str::words($this->description, 10);
|
return Str::words($this->description, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeComment(QueryBuilder $query, $comment): QueryBuilder
|
||||||
|
{
|
||||||
|
return $query->where('comment', 'LIKE', '%'.$comment.'%');
|
||||||
|
}
|
||||||
|
|
||||||
public function scopePriceMax(QueryBuilder $query, $price): QueryBuilder
|
public function scopePriceMax(QueryBuilder $query, $price): QueryBuilder
|
||||||
{
|
{
|
||||||
return $query->where('price', '<=', $price);
|
return $query->where('price', '<=', $price);
|
||||||
|
@ -19,6 +19,8 @@ class HomeController extends Controller
|
|||||||
{
|
{
|
||||||
$homes = QueryBuilder::for(Home::class)
|
$homes = QueryBuilder::for(Home::class)
|
||||||
->allowedFilters([
|
->allowedFilters([
|
||||||
|
AllowedFilter::scope('comment'),
|
||||||
|
|
||||||
AllowedFilter::scope('price_min'),
|
AllowedFilter::scope('price_min'),
|
||||||
AllowedFilter::scope('price_max'),
|
AllowedFilter::scope('price_max'),
|
||||||
|
|
||||||
|
@ -24,6 +24,9 @@
|
|||||||
<div class="collapse" id="filters">
|
<div class="collapse" id="filters">
|
||||||
<div class="card card-body">
|
<div class="card card-body">
|
||||||
<form>
|
<form>
|
||||||
|
<div class="row form-group">
|
||||||
|
<label class="col-lg-2" for="comment">Commentaire:</label><input type="text" name="filter[comment]" id="comment">
|
||||||
|
</div>
|
||||||
<div class="row form-group">
|
<div class="row form-group">
|
||||||
<label class="col-lg-2" for="price_min">Min prix:</label><input type="number" name="filter[price_min]" id="price_min">
|
<label class="col-lg-2" for="price_min">Min prix:</label><input type="number" name="filter[price_min]" id="price_min">
|
||||||
<label class="col-lg-2" for="price_max">Max prix:</label><input type="number" name="filter[price_max]" id="price_max">
|
<label class="col-lg-2" for="price_max">Max prix:</label><input type="number" name="filter[price_max]" id="price_max">
|
||||||
|
Loading…
Reference in New Issue
Block a user