/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $id = Resume::first()->id;
     factory(Language::class)->create(['resume_id' => $id, 'name' => 'English', 'proficiency' => 'Fluent']);
     factory(Language::class)->create(['resume_id' => $id, 'name' => 'Portuguese', 'proficiency' => 'Fluent']);
     factory(Language::class)->create(['resume_id' => $id, 'name' => 'Spanish', 'proficiency' => 'Basic']);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $skills = Skill::lists('id');
     $last = count($skills) - 1;
     $resume = Resume::first();
     for ($i = 0; $i < 1; $i++) {
         $certificate = $resume->certificates()->create(['title' => 'PHP Master', 'length' => '300 hours', 'certified_by' => 'My Friend']);
         if (count($skills)) {
             $certificate->skills()->attach($skills[rand(0, $last)]);
         }
     }
 }
 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;
     }
 }