Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Nezo96-39273050's avatar

Livewire 3 "escapeWhenCastingToString":protected ?

Okay, i am novice with laravel and livewire. I am trying to get search results from my db with livewire.

[A small addition] In my dev env i use supabase and in production i have mysql installed localy on server.

So i got this "message" object(Illuminate\Database\Eloquent\Collection)#1292 (2) { ["items":protected]=> array(0) { } ["escapeWhenCastingToString":protected]=> bool(false) } from var_dump.

In my component i use basic livewire render function

<?php

namespace App\Livewire;

use App\Models\Movie;
use Livewire\Component;

class NavbarSearch extends Component
{
    public $search = "";

    public function render()
    {
        $results = [];

        if (strlen($this->search) >= 3) {
            // $results = Movie::get();
            $results = Movie::where('title', 'like', '%' . $this->search . '%')->get();
        }

        return view('livewire.navbar-search', ['movies' => $results]);
    }
}

If i use $results = Movie::get(); instead Movie::where()i do get all data from database.

My data binding works without problem because when i var_dump $this->search; i do get exactly what i type in search input.

My Movie model is just basic model with $filable fields

class Movie extends Model
{
    use HasFactory;

    protected $fillable = [
        'title',
        'slug',
        'release',
        'rating',
        'duration',
        'url',
        'poster',
        'dabing',
        'trailer'
    ];
}
0 likes
3 replies
Tray2's avatar

I would suggest using the same RDBMS in both dev and prod, it will make things easier for you.

Nezo96-39273050's avatar

This problem is related to dev env (supabase), not to prod. After everything will work i push changes to github and than i pull it to prod. server @tray2

Nezo96-39273050's avatar
Nezo96-39273050
OP
Best Answer
Level 1

So i found problem. Problem is that in my column 'title' i do have movie names, but there are some uppercase letters and this seems to be the problem. Lets say i have Rebel Moon in my title column and i want to search it by title so i write rebel and now problem happens, because in title column is no rebel but Rebel. Query distinguishes whether a letter is uppercase or lowercase. If i search Rebel or ebel it works. 🙄

So the answers are here:

If you use mariaDB (MYSQL): ⏬

With the default collations, LIKE is case-insensitive Wich means this will work: $results = Movie::where('title', 'like', '%' . $this->search . '%')->get();

If you use POSTGRE DB ⏬

LIKE and ILIKE allow pattern matching within character-based column data. Their syntax is identical, but LIKE is case-sensitive, while ILIKE is case-insensitive.

If i use $results = Movie::where('title', 'ilike', '%' . $this->search . '%')->get(); it works how it should be. 👌

1 like

Please or to participate in this conversation.