What is your question ? I don't see any real problem arount the query.
Mar 8, 2023
4
Level 1
Foreign key in front
Here I've relationship for getting items from category. but when I check laravel debugger query, it shows where condition in first and then relationship in last, if I add multiple where conditions, foreign_key loading after all the where conditions, how to set foreign_key in first public function items(){ return $this->hasMany(\App\Items::class, 'category_id', 'id')->where(['items.available'=>1]); }
select * from items where (items.available = 1) and items.category_id in (633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 728, 729, 730, 885) and items.deleted_at is null
Please or to participate in this conversation.