Пример #1
0
 public function store()
 {
     // dd(Input::all());
     $adhesion = new Adhesion();
     $adhesion->fill(Input::except('adherent', 'adherent2', '_token', '_method'));
     $adhesion->is_payed = Input::get('is_payed') ? 1 : 0;
     // return dd($adhesion);
     $adhesion->save();
     $type = Input::get('type');
     switch ($type) {
         case 'conso':
             $adhesion->personne()->attach(Input::get('adherent'));
             break;
         case 'couple':
             $adhesion->personne()->attach(Input::get('adherent'));
             $adhesion->personne()->attach(Input::get('adherent2'));
             break;
         case 'pro_personne':
             $adhesion->personne()->attach(Input::get('adherent'));
             break;
         case 'pro_structure':
             $adhesion->structure()->attach(Input::get('adherent'));
             break;
         default:
             dd('problème');
             break;
     }
     // dd($adhesion);
 }