While eager loading the relationship it return empty array as result but after getting the result relationship works fine..
Inside relation containing function $this has no attribute value while eager loading.
I have tried to eager load the relationship without eager loading and $this
has all the attributes value.
- Controller
$temp = StipendCalcVols::with('stipendCalcTypes')->where('vol_id', 110)->first();
- Model
public function stipendCalcTypes() {
dd($this); // null attributes
return $this->hasMany(StipendCalcTypes::class, 'table_id', 'vol_id')
->where('stipend_calc_id', $this->stipend_calc_id)->where('table_name', 'volunteers');
}
$this
should have attributes value.
$this
have at this point in your opinion? – Namoshek$this->stipend_calc_id
or$this->id
expecting model any attributes @Namoshek – Basanta Tajpuriya