/** * Saves fonts to the project * * @param Project $project * @param Request $request * @return string */ public function storeFonts(Project $project, Request $request) { if ($request->ajax()) { $fontIds = $request->all()['ids']; foreach ($fontIds as $id) { $project->fonts()->save(new Font(['myfonts_id' => $id])); } } return 'hello'; }