Why didn't you put all information you had currently in studio_classes table in classes table, and just add "studio_id" in classes table.
And then, you just have a "belongsTo" relation between ClassModel and Studio.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
It is really hard to define a good title for this question...
I am having hard time defining a specific relationship with the following tables:

Let me first explain the tables.
There are many studios. Each Studio says what type of classes it has with price, duration, etc.
Each Instructor can create new classes in a studio "X" by selecting the currently available class types with their existing price, duration, etc.
Note: class_types table holds all possible sports. By "currently available class types" I mean the studios_classes table where the Studio define what classes it has for the studio.
I want from the Class model (which I named ClassModel because "class" is reserved PHP word) to be able to access the Studio. This has to be done through StudioClass model that I used as pivot model for studios_classes table.
Obviously one class can belong to a single studio and hasManyThrough is not convenient in this case.
I defined the other side of the relation for a Studio having many ClassModel as follows and it is working properly:
class Studio extends Model
{
public function classes()
{
return $this->hasManyThrough(ClassModel::class, StudioClass::class, null, 'studio_class_id');
}
}
https://laravel.com/docs/5.6/eloquent-relationships#eager-loading
You set your relations from Class to StudioClass (named studioclass) and from StudioClass to Studio (named studio)
and then you can get data from studio table like that :
$class = Class::with('studioclass.studio')->find($id);
Please or to participate in this conversation.