Prakash
Prakash

Reputation: 71

Where Clause in eloquent is responding with `No Properties`

I am new to laravel. I am trying to keep a where clause for the get method like this.

$employees = newdb::where('status', 'Active');
$response = $employees;
return response()->json($response,200);

But i am getting No Properties as output

In PHP I used this

"SELECT * FROM newdb WHERE status = 'Draft'";

What am i doing wrong? I tried different suggestions But none worked correctly. How do i do this? What is wrong with my code?

Upvotes: 0

Views: 55

Answers (1)

Zayn Ali
Zayn Ali

Reputation: 4915

where method returns Builder object. So, you have to call get method on it to fetch data.

Try this

$employees = newdb::where('status', 'Active')->get();

return response()->json($employees, 200);

Upvotes: 2

Related Questions