I've Module that have multiple media. I want to use eloquent to store data in three table. My tables are as follow
users, DrivingSession, Media ,DrivingSession model contains the user_id and Media model have the driving_session_id. I want to store DrivingSession image/videos created by specific user inside the Media model.My model functions are.
Users.php
public function drivingsessions(){
return $this->hasmany(DrivingSession::class);
}
DrivingSession.php
public function user(){
return $this->belongsToMany(User::class);
}
public function Medias(){
return $this->hasMany(Media::class);
}
Media.php
public function drivingSession(){
return $this->belongsToMany(DrivingSession::class);
}
I want to store user_id for reference in DrivingSessions table and the attached Media to Medias table. how can I do this ?
blongsToMany
?? Spelling error – RiggsFolly