Hello, please go easy on me as I just began my journey into coding.
I have an issue with TntSearch in Laravel and I really can't wrap my head around it.
To summarize, I want to search a model by three attributes: city, region and type.
While searching for "city" and "region" works fine, "type" gives me some weird problems.
It has four options "Bowl", "Pipe", "Park" and "Street", but only "Park" and "Pipe" are giving back results, while "Bowl" and "Street" return zero hits even tho there are some records.
If I search for "park" it works
What makes it even more strange to me is the fact that if I search for a term that actually doesn't exist I get the usual page "No posts for this search terms"
while if I search for one of those two terms, I have the same empty page but with pagination controls.
Any help would be hugely appreciated.
I have this in my model
<?php
namespace App\Models;
use App\Models\Image;
use App\Models\Region;
use Laravel\Scout\Searchable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Spot extends Model
{
use HasFactory, Searchable;
protected $fillable = [
'name',
'city',
'address',
'type',
'description',
'image',
'user_id',
];
public function toSearchableArray(){
$region = $this->region;
$array = [
'id' => $this->id,
'name' => $this->name,
'city' => $this->city,
'type' => $this->type,
'region' => $region,
];
return $array;
}
public function user(){
return $this->belongsTo(User::class);
}
public function region(){
return $this->belongsTo(Region::class);
}
}
Hello, please go easy on me as I just began my journey into coding.
I have an issue with TntSearch in Laravel and I really can't wrap my head around it. To summarize, I want to search a model by three attributes: city, region and type. While searching for "city" and "region" works fine, "type" gives me some weird problems. It has four options "Bowl", "Pipe", "Park" and "Street", but only "Park" and "Pipe" are giving back results, while "Bowl" and "Street" return zero hits even tho there are some records.
If I search for "park" it works
What makes it even more strange to me is the fact that if I search for a term that actually doesn't exist I get the usual page "No posts for this search terms"
while if I search for one of those two terms, I have the same empty page but with pagination controls.
Any help would be hugely appreciated.
I have this in my model
The route in web.php
And the function in my controller is
scout.php is configured