To achieve the stated requirements, your database should consist of 4 tables.
Here's the simplified version of the database
staffs
roles
projects
project_staff
- id (optional, but useful in certain contexts)
- project_id
- staff_id
You need that 4th table to support the fact that a staff member can be assigned to multiple projects and that a project can have multiple staff members assigned to it.
As for model relationships :
Project
/**
* Staff members that belong to the project.
*/
public function staffs() {
return $this->belongsToMany('App\Staff');
}
Staff
/**
* Projects that belong to the staff member.
*/
public function projects() {
return $this->belongsToMany('App\Project');
}
/**
* The role that the member belongs to.
*/
public function role() {
return $this->belongsTo('App\Role');
}
Role
/**
* Staff members having the current role
*/
public function staffs() {
return $this->hasMany('App\Staff');
}