Reputation: 1
I am trying to fix all issues but I get Attempt to read property "taqseet" on null
.
public function taqseet()
{
return $this->hasMany(Taqseet::class, 'stud_prog_id', 'id');
}
the error point to this line
$link = StudentProgramLink::with(['sanad','taqseet', 'student'])->find($StudProgLink);
When I dd($link)
, there's taqseet
data:
#relations: array:3 [▼
"sanad" => Illuminate\Database\Eloquent\Collection {#2490 ▶}
"taqseet" => Illuminate\Database\Eloquent\Collection {#2486 ▼
#items: array:4 [▼
0 => App\Models\Taqseet {#2531 ▶}
1 => App\Models\Taqseet {#2529 ▶}
2 => App\Models\Taqseet {#2528 ▶}
3 => App\Models\Taqseet {#2527 ▶}
]
#escapeWhenCastingToString: false
}
"student" => App\Models\Student {#2547 ▶}
I can't find a solution for this.
I tried with withDefault
function but it does not work with HasMany
relation, it only works with BelongsTo
.
Upvotes: 0
Views: 54