2017-10-21 8 views
0
User table 

id | name | user_type | email   | password 
1 | John | 1   | [email protected] | something 
2 | Roy | 1   | [email protected] | something 
3 | Rax | 1   | [email protected] | something 
4 | Ren | 1   | [email protected] | something 

AssignUser Table 

id | user_id  | assign_to_math | assign_to_chemistry 
1 | 3   | 2    | 1 
2 | 4   | 1    | 2 

があり、ここで4人のユーザーがアサイン表の最初の行ラックスで今 無駄であるユーザテーブルがあるジョンlaravel 5の関係は、だから、1

にロイ・化学に数学のためのtuitoinを割り当てている私が取得したいです関係

とジョンとロイの詳細私はそれを助けてください、なぜ知らない私のためにnull値を返すユーザーモデル

public function getInfoFormathTutor(){ 
     return $this->hasOne('App\AssignUser', 'id', 'assign_to_math'); 
    } 

にしようとした事前のおかげで

+0

のようなあなたの 'のApp \ AssignUser'モデルの外観は何ですか? – am05mhz

答えて

0

試してみてください。

public function getInfoFormathTutor(){ 
    return $this->hasOne('App\AssignUser', 'assign_to_math', 'id'); 
} 
関連する問題