I have a question. I have two tables: devices and faces
In these databases, one device can be assigned to one person (this is one to one relationship), but one person can have many devices (so this is a ratio from one to many). How can I do this in Laravel? For one to one, it's a little easier, and in the model I can do this:
Devices
class Devices extends Model
{
public function persons(){
return $this->hasOne('App\Persons','id');
}
}
Faces
class Persons extends Model
{
public function devices(){
return $this->belongsTo('App\Devices');
}
}
SO I think this relationship is one to one: one device is assigned to one person.
How can I get many devices for one person? Has changed. Who owns the "Man in Man" model? Will it be good for these options?
Arlid source
share