2017-06-02 24 views
1

我一直在嘗試將用戶與配置文件相關聯。 這裏是我的代碼:Laravel CRUD ORM找不到型號

簡介型號:

class Profile extends Model 
{ 
    public function user(){ 
     return $this->belongsTo('App\User'); 
    } 
} 

用戶模型:

class User extends Authenticatable 

{ 
    ... 
    public function profile(){ 
     return $this->hasOne('App/Profile'); 
    } 
} 

ProfileController可:

public function show($username) 
    { 
     $user = User::where('username',$username)->first(); 
     $profile = $user->profile; 
     return view('profiles.show')->withProfile($profile); 
    } 

路線(它的意思是 「PROFIL」):

Route::resource('profil','ProfileController'); 

錯誤: http://prntscr.com/ff6y0a

做的CRUD功能,其餘任何提示是非常歡迎!

回答

1

將您的User模型關係中的App/Profile更改爲App\Profile