Friday, March 17, 2017

Laravel Eloquent is case sensitive

I want to check if the inputted data already exists in the database. I've been trying to input data that already exists (but with different case) to test it. Here is my query

        $existing = AmenityType::all()
        ->where('type', $req->type)
        ->first();

but it doesn't return anything even if I did this

->where('lower(type)', strtolower($req->type))

The database collation is 'utf8mb4_unicode_ci'

Thank you.



via user5156944

Advertisement