mercredi 25 novembre 2015

laravel- many to many relationship with tags

it is my article model

              function tags()
               {
                return $this->belongsToMany('App\Tag')->withTimestamps();
               }

it is my article model

             function articles()
              {
              return $this->belongsToMany('App\Article');
              }


it is my article controllers store method

               public function store(ArticleRequest $request, 
                Article $article)   
                       {
              $article=Auth::user()->articles()->create($request->all());

                 $article->tags()->attach($request->input('tags'));

                 return redirect('articles');

                  }

i had this error

BadMethodCallException in Builder.php line 2071: Call to undefined method Illuminate\Database\Query\Builder::tags()

help me resolve this``



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1T3nuhb
via IFTTT

Aucun commentaire:

Enregistrer un commentaire