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

afoysal's avatar

Fetch null values in Laravel Query

In my Laravel application if I use below query I am getting all values including null values.

    Address::query();

But if I use below Query I am getting values from first_name starts with certain character and other columns value is not null.

    Address::where('first_name', 'LIKE', $request->letter.'%')->get();

I would like to fetch values from first_name column starts with certain character and other columns value is null or not null both.

Thanks

0 likes
1 reply
Snapey's avatar

This

Address::query();

just creates an instance of query builder and does not return any data at all

This

Address::where('first_name', 'LIKE', $request->letter.'%')->get();

returns all records where first_name begins with the specified letter. It does not care about the values of the other columns.

Do you want to re-state your problem please.

1 like

Please or to participate in this conversation.