/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $input = $request->all(); $clientDetails = new ClientDetails(); //get client details from post request $clientDetails->name = $input['name']; $clientDetails->bio = $input['bio']; //get point of contacts $pointOfContacts = $input['point_of_contacts']; //save them to the database and return the ids to save them along with the leave behind if (!empty($pointOfContacts)) { $arrayOfPersonIds = Person::savePeople($pointOfContacts); $clientDetails->point_of_contact_ids = serialize($arrayOfPersonIds); } $clientDetails->save(); return 'success'; }