app/Http/Services/SurveyService.php
//Crear en la tabla "survey"
Crear en la tabla "survey"
Crear en la tabla " survey "
function createSurvey($request)
  {
    $return = [];
    $newSurvey = new Survey();
    $newSurvey->fill($request->all())->save();
    $dataUser = User::select('id')->get();
    if ($dataUser->count() > 0) {
      foreach ($dataUser as $v) {
        (new UserSurvey())->fill(['user_id' => $v['id'], 'survey_id' => $newSurvey->id])->save();
        $return[] = $v['id'];
      }
    }
    return $return;
  }
function createSurvey ( $ request ) { $ return = [ ] ; $ newSurvey = new Survey ( ) ; $ newSurvey -> fill ( $ request -> all ( ) ) -> save ( ) ; $ dataUser = User :: select ( 'id' ) -> get ( ) ; if ( $ dataUser -> count ( ) > 0 ) { foreach ( $ dataUser as $ v ) { ( new UserSurvey ( ) ) -> fill ( [ 'user_id' => $ v [ 'id' ] , 'survey_id' => $ newSurvey -> id ] ) -> save ( ) ; $ return [ ] = $ v [ 'id' ] ; } } return $ return ; }
Crear en la tabla "survey"
Crear en la tabla " survey "