I
I
ilysion_in_life2018-08-18 11:56:21
Laravel
ilysion_in_life, 2018-08-18 11:56:21

How to make a correct request to the Laravel database?

Hello uv. connoisseurs, I have a problem with the request, in general, in fact, I want to do the right filter by price, and then I got a hitch with the wording of the request. The table has 2 fields with prices price_weekend_max and price_weekend_max_comm when displaying these prices, I add them, i.e. $c->price_weekend_max + $c->price_weekend_max_comm and I get one single price for which I am trying to make a filter. The filter itself works according to the following principle: the usual slider from one price to another, min \ max, the prices are transferred to the method and there I want to filter the data with a query

$filtered_items = Cottage::orderBy('priority', 'desc');
$filtered_items = $filtered_items
                        ->where('price_weekend_max + price_weekend_max_comm','>=', $data['price_from']) 
                        ->where('price_weekend_max + price_weekend_max_comm','<=', $data['price_to']);

but it doesn't work when querying, I get an error, here is a query with an error
SQLSTATE[42S22]: Column not found: 1054 Unknown column '47000' in 'where clause' (SQL: select count(*) as aggregate from `cottages_new` where `persons_min` >= 1 and `47000` >= 0 and `47000` <= 0 and `publish` = 1) help me to do it right

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question