【问题标题】:Laravel CRUD ORM Can't find modelLaravel CRUD ORM 找不到模型
【发布时间】:2017-11-04 06:48:55
【问题描述】:

我一直在尝试将用户与个人资料相关联。 这是我的代码:

个人资料模型:

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

用户模型:

class User extends Authenticatable

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

配置文件控制器:

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

路线(意思是“轮廓”):

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

错误: http://prntscr.com/ff6y0a

非常欢迎任何有关执行其余 CRUD 功能的提示!

【问题讨论】:

    标签: php laravel orm relationship crud


    【解决方案1】:

    在您的 User 模型关系中将 App/Profile 更改为 App\Profile

    【讨论】:

      猜你喜欢
      • 2017-02-09
      • 2015-04-25
      • 2023-02-04
      • 1970-01-01
      • 2021-01-10
      • 1970-01-01
      • 1970-01-01
      • 2013-05-02
      相关资源
      最近更新 更多