Jan 11, 2018
0
Level 7
How do I load 3rd level relationship for user in SparkServiceProvider
I am successfully loading a relationship in SparkServiceProvider as per docs
Spark::swap('UserRepository@current', function() {
$user = Auth::user();
if ($user) {
$user->load('typable');
}
return $user;
});
Thats fine, it works, however I now need to load another level on the above typable relationship.
So a User has typable_id, and typable_type, with example type of student. That loads the student model in, and now on the student model there is a polymorphic relationship to tags, again, taggable_id, taggable_type.
In other words, a User is a Student, and Student hasMany tags.
Ok so how should I be accessing this relationship in the SparkServiceProvider above ? Obviously $user->load('taggable') is incorrect.
Please or to participate in this conversation.