lundi 13 avril 2020

SQLSTATE[42S22]: Column not found in Laravel

Hello Following is my query, but I get error while run it:

$out_let_product = OutLet::where('id', Redis::get('out_let_id') )->with(
    ['products' => function($query){
        $query->with(['prices', 'combinations' => function($query){
            $query->where('prices.active', '=', '1');                
        }]);
    }])->get();

In above code 'prices' and 'combinations' = function in product model. and it's working perfectly but the problem is when I include " $query->where('prices.active', '=', '1'); " this line inside, system raised error like below:

"message": "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'prices.active' in 'where clause' (SQL: select * from product_combinations where product_combinations.product_id in (1, 2, 3) and prices.active = 1 and product_combinations.deleted_at is null)",



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire