2
我即三個表:雄辯:如何獲得逆
- 人(含列:ID &名)
- 分配(與列:PERSON_ID & PROJECT_ID)
- 項目(列:編號&標題)
我有Assignments表,因爲每個人都可以分配給許多項目。
我有這三種模式:
// People.php
public function projectAssigned()
{
return $this->hasMany('App\Assignment', 'person_id');
}
// Assignment.php
public function person()
{
return $this->belongsTo('App\People', 'person_id');
}
public function project()
{
return $this->belongsTo('App\Project', 'project_id');
}
public function task()
{
return $this->hasMany('App\Task', 'assignment_id');
}
// Project.php
public function assignment()
{
return $this->hasMany('App\Assignment', 'project_id');
}
獲得的特定項目中分配的人的名單很簡單:
how I get it:
@foreach($project->assignment as $person)
<tr>
<td>{{$person->person->firstname.' '.$person->person->lastname}}</td>
</tr>
@endforeach
我的問題是:如何讓人們名單未在特定項目中分配?