skip to Main Content

How to apply multiple where condition on laravel eloquent having mutliple models

I have a model with four relations like as below public function custform_formfields() { return $this->hasOne(FormFieldMapping::class,'field_id','field_id'); } public function custform_fieldtype() { return $this->hasOne(FieldType::class, 'fieldtype_id', 'html_field_type'); } public function custform_forms() { return $this->hasOne(CustomForms::class,'form_id', 'form_id'); } public function custform_options() { return $this->hasOne(FormOptions::class,'option_id',…

VIEW QUESTION

Laravel belongsToMany select all specified ids

Relation public function groups() { return $this->belongsToMany('AppModelsItemGroup','item_to_group','item_id','item_group_id'); } ** How to select all Items that have item_group_id 0 and 9 BOTH?** $zero_and_nine_count = AppModelsItem::with(['groups' => function ($query) { $where[] = ['item_group_id', , 0]; $where[] = ['item_group_id', '=', 9]; $query->where($where); }])->count();…

VIEW QUESTION
Back To Top
Search