TurkishSearchable isminde bir trait oluşturun ve ardındanbu traiti model içerisinde kullanın. Büyük küçük harf hatanızı giderecektir.
app/Traits/TurkishSearchable.php
<?php
namespace App\Traits;
use Illuminate\Database\Eloquent\Builder;
trait TurkishSearchable
{
public function scopeTurkishSearch(Builder $query, $column, $searchTerm)
{
$searchTerm = $this->normalizeTurkishString($searchTerm);
return $query->where(function ($q) use ($column, $searchTerm) {
$q->whereRaw("LOWER($column) LIKE ?", ['%' . $searchTerm . '%']);
});
}
protected function normalizeTurkishString($string)
{
$replacements = [
'ı' => 'i', 'İ' => 'i', 'ş' => 's', 'Ş' => 's',
'ç' => 'c', 'Ç' => 'c', 'ğ' => 'g', 'Ğ' => 'g',
'ü' => 'u', 'Ü' => 'u', 'ö' => 'o', 'Ö' => 'o'
];
return strtr(mb_strtolower($string), $replacements);
}
}app/Models/TestModel.php
<?php
namespace App\Models;
use App\Traits\TurkishSearchable;
use Wildside\Userstamps\Userstamps;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class TestModel extends Model
{
use SoftDeletes, Userstamps, TurkishSearchable;
protected $fillable = [
'is_active',
'content',
];
}