I need create relationships between them like this:
device hasOne department
department belongsToMany devices
Is it one-to-many relationship?
So next I created the table department_devices with department_id and device_id referencing on id in devices and id in departments and these models:
Device
Department
DepartmentDevice
But i dont know how to put the relationships into the models ....
// Device
public function department(){
return $this->hasOne('App\Department');
}
// Department
public function devices(){
return $this->belongsToMany('App\Device');
}
but what I have to use types and location with access data ... when the tables names locations, types I assume the table locations name location but locations name location, types name type ... I dont understand well