Q:

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.

A:

Calling all() already returns you a Collection so the where clause is done on the collection instead on the db. 
Try it like this:
$binds = array(strtolower($req->type));

$existing = AmenityType::whereRaw('lower(type) = ?'), $binds)->first();

var_dump($existing);

