php - Laravel 5 Throw an exception: BadMethodCallException with message 'Call to undefined method Illuminate\Database\Query\Builder::tags() -


i'm using laravel 5, , i'm bit new framework. searched lot problem, in return got nothing related.

so, have 2 models: article , tag.

in article model have method this:

public function tags() {     return $this->belongstomany("app\tag"); } 

and in tag model have method this:

public function articles() {     return $this->belongstomany("app\article"); } 

now thing when i'm testing in tinker this:

$article->tags()->attach(1); 

it gives me following exception:

badmethodcallexception message 'call undefined method illuminate\database\query\builder::tags()'

but when i'm calling this:

$tag->articles()->attach(1); 

it totally works charm , doesn't throw kind of exception whatsoever.

i'm learning stuff laracast , classes , methods , files kind of this: badmethodcallexception message 'call undefined method illuminate\database\query\builder::belongtomany()'

except think don't have typo problem.

well, got answer on own & share others.

the code doesn't have problem.

i should've restarted tinker. tinker problem.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -