public function assistents($id)
 {
     $votacio = Votacio::find($id);
     $assistents = $votacio->assistents()->select('id')->paginate(5);
     foreach ($assistents as $ass) {
         //$ass = array_add($ass, 'result', VotacioAssistent::find($ass->id)->assistent()->get());
         $ass->ass = VotacioAssistent::find($ass->id)->assistent()->first();
     }
     $assistents->id = $id;
     return view('assistentLayouts.index2')->with("ass", $assistents);
 }
 public function deleteRespostesAssistents($idVotacio, $idAssistent)
 {
     $vota = VotacioAssistent::where('assistent_id', '=', $idAssistent)->where('votacio_id', '=', $idVotacio)->first();
     if ($vota) {
         $vota->delete();
     }
 }
Example #3
0
 public function postAssistentVotacio()
 {
     $array = Request::input('vota');
     if ($array) {
         foreach ($array as $vota) {
             $id = Votacio::where('titol', "=", $vota)->select('id')->first();
             $voAs = VotacioAssistent::where('assistent_id', "=", Request::input('id'))->where('votacio_id', '=', $id->id)->get();
             if ($voAs->isEmpty()) {
                 $result = array('assistent_id' => Request::input('id'));
                 $result = array_add($result, 'votacio_id', $id->id);
                 $novaVoAs = VotacioAssistent::create($result);
             }
         }
     }
 }