'Laravel how to store api parent with child data at the same time?

so i want to store parent data with child in the same time ? the relationship between parent is one to many, i dont know how to store an array in laravel api. i was tried looping data child, but i dont know my code was right or not.

  public function store(Request $request)
    {
        $request->validate($request, [
            'title' => 'required|string',
            'name => 'required|string',
            'child.*' => 'required|string',
      ]);
      $child= $request->child;
      $chl = [];
      foreach ($child as $cd){
          array_push($chl, feature::create($cd));
      }
      $this->parent->create($request->all());
      return $this->index();
    }

I want make this:

{
  "title": "First Post",
  "desc": "Desc of Post",
  "image": "image3.jpg",
  "category_id": 1,
  "tags": [
    "one",
    "two",
    "three"
  ]
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source