dimanche 15 décembre 2019

Add an array of ids to other table in Laravel

I have two tables stories and featured Story so I want to add the few story ids to featured table in a single request. How to do that?

here is my code to add the single id to featured story table.

public function saveFeatured($id)
    {
        # code...
        $story = $this->getById($id);
        $storyId = $story->id;
        $featured = new FeaturedStory();
        $featured->story_id = $storyId;
        $featured->save();
        return "Added to featured StoryList";
    }


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire