H
H
hakkol2016-06-02 14:31:49
Laravel
hakkol, 2016-06-02 14:31:49

Why doesn't the where method work in Laravel?

Good day, I ran into the following problem - I was developing a site on Laravel. There is a table of products, the user can review the product, after which the admin approves the review (in the review table, the 'is_approved' field becomes equal to 1, by default 0). In the database I use tinyint for the 'is_approved' field. To get all approved reviews I use the following code: where reviews is a one-to-many relationship between the product and reviews table what could be the problem? The php versions on the local machine and on the server are the same.
$this->reviews->where('is_approved', 1);
$this->reviews->where('is_approved', '1');
$reviews->where('is_approved', 1);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Igor, 2016-06-02
@hakkol

have you tried it like this return $this->reviews->where('is_approved', true);?

A
Andrey, 2016-06-02
@VladimirAndreev

does the field have the same type on the server and in the database?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question