Stefan Todorov
Stefan Todorov

Reputation: 33

Laravel CRUD ORM Can't find model

I have been trying to associate a User with a Profile. Here is my code:

Profile Model:

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

User Model:

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);
    }

Route (It's meant to be "profil"):

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

Error: http://prntscr.com/ff6y0a

Any tips on doing the rest of the CRUD functionality is very welcome!

Upvotes: 1

Views: 66

Answers (1)

Sandeesh
Sandeesh

Reputation: 11916

Change App/Profile to App\Profile in your User model relationship.

Upvotes: 1

Related Questions