BadMethodCallException in Builder.php: Call to undefined method Laravel 5.0 -


as title says i'm getting error in laravel 5.0 whilst trying upgrade laravel 4.2 application.

the exact error message is: call undefined method illuminate\database\query\builder::orders()

i error when try fetch authenticated users orders controller following line:

$this->user->orders()->orderby('created_at', 'desc')->get() 

a parent class sets $this->user as:

$this->user = auth::user(); 

the user models relationship orders is:

public function orders() {     return $this->hasmany('app\models\order'); } 

to confuse me more $this->user->orders() returns error i'm experiencing user::whereid($this->user->id)->first()->orders() returns orders expecting.

when dump both $this->user->orders() , user::whereid($this->user->id)->first()->orders() same output on screen.

can explain , possibly point me towards correct way solution feels hacky , i'm sure there cleaner way accomplish i'm trying do.

thanks

apologies answering own question again, have found proper soloution issue.

i had left default user model in app folder since installing laravel 5, , user model laravel using when called auth::user().

i needed change config/auth.php use customised user model , working expected.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -