Beispiel #1
0
 public function create(Resume $resume, array $data)
 {
     \DB::beginTransaction();
     try {
         $skills = $data['skills_ids'];
         $certificate = $resume->certificates()->create($data);
         if ($skills == NULL) {
             $certificate->skills()->sync([]);
         } else {
             if (!is_array($skills)) {
                 $skills = explode(',', $skills);
             }
             $certificate->skills()->sync($skills);
         }
         $certificate->save();
         \DB::commit();
         return $certificate;
     } catch (\Exception $e) {
         \DB::rollback();
         throw $e;
     }
 }