Пример #1
0
 /**
  * @param array $data
  */
 private function execute(array $data)
 {
     /**
      * User
      */
     foreach ($data as $user) {
         $profile = $user['profile'];
         $events = $user['events'];
         unset($user['profile'], $user['events']);
         $user_data = \Flocc\User::create($user);
         $user_id = $user_data->getId();
         /**
          * User profile
          */
         $profile['user_id'] = $user_id;
         \Flocc\Profile::create($profile);
         /**
          * User events
          */
         foreach ($events as $event) {
             $scoring = $event['scoring'];
             unset($event['scoring']);
             $event['user_id'] = $user_id;
             $event = \Flocc\Events\Events::create($event);
             /**
              * Event activities
              */
             \Flocc\Events\Activities::create(['event_id' => $event->getId(), 'activity_id' => rand(1, 3)]);
             /**
              * Event members
              */
             \Flocc\Events\Members::create(['event_id' => $event->getId(), 'user_id' => $user_id, 'status' => 'member']);
             /**
              * Add scoring
              */
             $scoring['event_id'] = $event->getId();
             \Flocc\Events\Scoring::create([$scoring]);
         }
         /**
          * Mail label
          */
         \Flocc\Mail\Labels::create(['user_id' => $user_id, 'name' => 'Skrzynka odbiorcza', 'type' => 'inbox']);
         \Flocc\Mail\Labels::create(['user_id' => $user_id, 'name' => 'Kosz', 'type' => 'trash']);
         \Flocc\Mail\Labels::create(['user_id' => $user_id, 'name' => 'Archiwum', 'type' => 'archive']);
     }
 }
Пример #2
0
 /**
  * Add new member or follower
  *
  * @param int $event_id
  * @param int $user_id
  * @param string $status
  *
  * @return bool
  */
 public function addNew($event_id, $user_id, $status)
 {
     $insert = Members::create(['event_id' => $event_id, 'user_id' => $user_id, 'status' => $status]);
     return $insert === null ? false : true;
 }