Thursday, March 16, 2017

How do i sync tags on laravel

insertData Controller

    public function insertArticle(Request $request)
            {
                $article = new Article();
                $article->title = $request['title'];
                $article->content = $request['content'];

                //code to sync tags for this article

                $article->save()
                return redirect()->back();
           }

Tags are located in another table called tags containing id and name. I am connecting tags table to articles table by using pivot table article_tag which contains article_id and tag_id entries, and i have set up the relations as well as the foreign keys in the pivot table. What i am wishing to do is synchronize tags for a certain article when i need to update it



via Ardit Mata

Advertisement