Esempio n. 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     for ($i = 0; $i < 10; $i++) {
         $p = new Participant();
         $p->first_name = 'random ' . rand();
         $p->last_name = 'randomgen';
         $p->sex = rand() % 2 ? 'm' : 'f';
         $p->save();
     }
 }
Esempio n. 2
0
 public function facebookLogin(Request $request, $offline = null)
 {
     if ($offline) {
         $facebook_id = '129795977365516';
         $name = 'Offline User';
         $gender = 'male';
     } else {
         $fb = new Facebook\Facebook(['app_id' => config('services.facebook.client_id'), 'app_secret' => config('services.facebook.client_secret'), 'default_graph_version' => 'v2.5', 'default_access_token' => $request->input('access_token')]);
         try {
             $response = $fb->get('/me?fields=id,name,gender,email');
         } catch (Facebook\Exceptions\FacebookResponseException $e) {
             return response('Graph returned an error: ' . $e->getMessage(), 500);
         } catch (Facebook\Exceptions\FacebookSDKException $e) {
             return response('Facebook SDK returned an error: ' . $e->getMessage(), 500);
         }
         $user = $response->getGraphUser();
         $facebook_id = $user->getId();
         $name = $user->getName();
         $gender = $user->getProperty('gender');
     }
     $participant = Participant::where('facebook_id', $facebook_id)->first();
     if ($participant) {
         session(['participantId' => $participant->id]);
         return response()->json(['alreadyExists' => true]);
     }
     $participant = new Participant();
     $participant->name = $name;
     $participant->facebook_id = $facebook_id;
     $participant->gender = $gender;
     session(['participant' => $participant]);
     return response()->json(['alreadyExists' => false]);
 }
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     //
     parent::boot($router);
     $router->model('project', 'App\\Project');
     $router->model('participants', 'App\\Participant');
     $router->model('projects', 'App\\Project');
     $router->model('questions', 'App\\Question');
     $router->model('organizations', 'App\\Organization');
     $router->model('result', 'App\\Result');
     $router->model('code', 'App\\PLocation');
     $router->bind('pcode', function ($value, $route) {
         if ($route->project->validate == 'person') {
             $pcode = \App\Participant::where('org_id', $route->project->organization->id)->where('participant_code', $value)->first();
         } elseif ($route->project->validate == 'pcode') {
             $pcode = \App\PLocation::where('org_id', $route->project->organization->id)->where('pcode', $value)->first();
         }
         if (!is_null($pcode)) {
             return $pcode;
         } else {
             \App::abort(404, 'Not Found.');
         }
     });
     $router->bind('person', function ($value, $route) {
         //dd($route->project);
         $person = \App\Participant::where('participant_code', $value)->where('org_id', $route->project->org_id)->first();
         if (!is_null($person)) {
             return $person;
         } else {
             \App::abort(404, 'Not Found.');
         }
     });
 }
Esempio n. 4
0
 /**
  * Insert new Tournament Participant
  *
  * @param  array  $data
  * @return Participant
  */
 public function create_participant(array $data)
 {
     $player = \DB::table('participants')->where('tournament_id', '=', $data['tournament_id'])->where('player_id', '=', $data['player_id'])->where('division_id', '=', $data['division_id'])->first();
     if (is_null($player)) {
         return Participant::create(['tournament_id' => $data['tournament_id'], 'player_id' => $data['player_id'], 'division_id' => $data['division_id']]);
     }
 }
Esempio n. 5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //Unguard
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     //Truncate
     Participant::truncate();
     //Event::truncate();
     Tag::truncate();
     Post::truncate();
     //Image::truncate();
     DB::statement('TRUNCATE `taggables`;');
     //DB::statement('TRUNCATE `imagables`;');
     DB::statement('TRUNCATE `participations`;');
     DB::statement('TRUNCATE `albumables`;');
     Event::reindex();
     Participant::reindex();
     User::reindex();
     Album::reindex();
     //Call
     $this->call(ParticipantTableSeeder::class);
     $this->call(EventTableSeeder::class);
     $this->call(TagTableSeeder::class);
     //Reguard
     Model::reguard();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
Esempio n. 6
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $meetupgroup = ['pcf', 'biker', 'afterdark', 'lover', ''];
     foreach (range(1, 30) as $index) {
         Participant::create(['fullname' => $faker->name(), 'contactno' => $faker->phoneNumber(), 'email' => $faker->email(), 'meetupgroup' => $meetupgroup[rand(0, 4)], 'comment' => $faker->sentence(3)]);
     }
 }
Esempio n. 7
0
 public function storeMessage($user, $input)
 {
     $thread = Thread::create(['subject' => $input['subject']]);
     Message::create(['thread_id' => $thread->id, 'user_id' => Auth::user()->id, 'body' => $input['message']]);
     Participant::create(['thread_id' => $thread->id, 'user_id' => Auth::user()->id, 'last_read' => new Carbon()]);
     Participant::create(['thread_id' => $thread->id, 'user_id' => $user->id, 'last_read' => new Carbon()]);
     $this->sentMessageNotification($user);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $maxParticipantID = Participant::count();
     $maxTrialID = Trial::count();
     for ($i = 0; $i < 1000; $i++) {
         $p = new Participation();
         $p->participant_id = rand(1, $maxParticipantID);
         $p->trial_id = rand(1, $maxTrialID);
         $p->save();
     }
     //
 }
Esempio n. 9
0
 public function update($id)
 {
     try {
         $thread = Thread::findOrFail($id);
     } catch (ModelNotFoundException $e) {
         Session::flash('error_message', 'The thread with ID: ' . $id . ' was not found.');
         return redirect('messages');
     }
     $message = Message::create(['thread_id' => $thread->id, 'user_id' => Auth::user()->id, 'body' => Input::get('message')]);
     $participant = Participant::firstOrCreate(['thread_id' => $thread->id, 'user_id' => Auth::user()->id]);
     $participant->last_read = new Carbon();
     $participant->save();
     return redirect('/message/' . $id);
 }
 private function composeTotal()
 {
     view()->composer('partials.admin_sidebar', function ($view) {
         $view->with('totalusers', User::all()->count());
         //total admin
         $view->with('totalparticipants', Participant::all()->count());
         //total participant
         $view->with('totalevents', Event::all()->count());
         //total event
         $view->with('totalposts', Post::all()->count());
         //total post
         $view->with('totaltags', Tag::all()->count());
         //total tag
         $view->with('totalimages', Image::all()->count());
         //total image
     });
 }
Esempio n. 11
0
 /**
  * Temporary function to migrate old data
  * @param type $pid
  */
 public function migrate($pid, $pcode, $org)
 {
     //echo $org;
     $pcode = substr($pcode, 0, -1);
     // get participant
     $participant = \App\Participant::find($pid);
     // attach participant to pcode
     if (!empty($pcode)) {
         $location = \App\PLocation::where('org_id', $org)->where('pcode', $pcode)->first();
         if (!empty($location)) {
             $participant->pcode()->attach($location->primaryid);
             $participant->save();
         } else {
             return false;
         }
     }
     return;
 }
 public function store(storePlaythroughRequest $request)
 {
     print_r($request->all());
     $game = $request->get('game');
     $users = $request->get('players');
     $winners = $request->get('winners');
     $userArr = explode(',', $users);
     $winnerArr = explode(',', $winners);
     $date = Carbon::createFromFormat('m/d/Y', $request->get('daterange'));
     $time = Carbon::createFromFormat('g:i', $request->get('timerange'));
     $playthrough = Playthrough::create(['game_id' => $game, 'played' => $date, 'duration' => $time, 'notes' => $request->get('notes')]);
     foreach ($userArr as $user) {
         if (in_array($user, $winnerArr)) {
             $w = 1;
         } else {
             $w = 0;
         }
         Participant::create(['playthrough_id' => $playthrough->id, 'game_id' => $game, 'user_id' => $user, 'score' => $request->input('person-' . $user), 'winner' => $w]);
     }
     return redirect()->route('playthrough');
 }
Esempio n. 13
0
 /**
  * 识别指令
  *
  * @param string $message
  * @return array
  */
 public static function recognizeCommands($message)
 {
     $result = [];
     foreach (explode("\n", $message) as $line) {
         foreach (self::COMMAND_SIGNS as $name => $signs) {
             foreach ($signs as $sign) {
                 if (false !== mb_strpos($line, $sign)) {
                     preg_match("|.*{$sign}(.+){$sign}.*|", $line, $matches);
                     if (!empty($matches)) {
                         if ('TOPIC' === $name) {
                             $data = Program::filterTopic($matches[1]);
                         }
                         if ('PARTICIPANT' === $name) {
                             $data = Participant::filterParticipantNames($matches[1]);
                         }
                         $result[$name] = $data ?? [];
                     }
                 }
             }
         }
     }
     return $result;
 }
Esempio n. 14
0
 public function join_external(Request $request, $token)
 {
     $inv = Invitation::where('token', '=', $token)->firstOrFail();
     $part = Participant::findOrFail($inv->participant);
     $room = Room::findOrFail($inv->room);
     if ($part->moderator) {
         $pass = $room->mod_pass;
     } else {
         $pass = $room->att_pass;
     }
     //check if meeting running and create if needed
     $bbb_id = bbbController::running($room);
     if (!$bbb_id) {
         $bbb_id = bbbController::create($room);
     }
     //join meeting
     $bbb = new BigBlueButton($bbb_id);
     $params = array('meetingId' => $room->bbb_meeting_id, 'username' => $part->mail, 'userId' => '', 'webVoiceConf' => '', 'password' => $pass);
     try {
         $result = $bbb->getJoinMeetingURL($params);
     } catch (Exception $e) {
         throw new Exception($e->getMessage() . "\n");
     }
     return redirect($result);
 }
 public function deleteParticipants($id)
 {
     $participant = Participant::find($id);
     $participantTypeall = Participators_type::where('participant_id', '=', $participant->id)->first();
     $participantType = Participators_type::find($participantTypeall->id);
     $participant->delete();
     $participantType->delete();
     if ($participant && $participantType) {
         return redirect()->action('HomeController@index');
     }
 }
Esempio n. 16
0
 public function addParticipants($participants, $id)
 {
     Participant::firstOrCreate(['user_id' => $participants, 'thread_id' => $id]);
 }
Esempio n. 17
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     //TODO high security mode
     $room = Room::findOrFail($id);
     if (!roomController::checkOwner($room)) {
         throw new Exception('Unauthorized');
     }
     //make validations
     $validator = Validator::make($request->all(), ['name' => 'required', 'email' => 'array']);
     $validator->each('email', ['email']);
     if ($validator->fails()) {
         return redirect('room/edit/' . $id)->withErrors($validator)->withInput()->with('validation_err', true);
     }
     $room->name = $request->input('name');
     $room->recording = empty($request->input('recording')) ? 0 : 1;
     $room->public = empty($request->input('public')) ? 0 : 1;
     $room->save();
     //we save the participants
     $emails = $request->input('email');
     $moderators = $request->input('moderator');
     if (!$moderators) {
         $moderators = array();
     }
     //delete old participants before adding new
     $room->participants()->delete();
     if (is_array($emails)) {
         foreach ($emails as $email) {
             $participant = new Participant();
             $participant->mail = $email;
             $participant->room_id = $room->id;
             if (in_array($email, $moderators)) {
                 $participant->moderator = 1;
             }
             $participant->save();
         }
     }
     return Redirect::action('roomController@show', $room->id);
 }
Esempio n. 18
0
 public function friendsSaveMessage(Request $request, $id)
 {
     $this->validate($request, ['name' => 'required|min:2', 'body' => 'required']);
     $user = User::where('id', $request->user()->id)->first();
     $friends = User::where('id', $id)->first();
     if ($user && $friends) {
         if (!$user->isFriendsWith($friends) || $user->id == $friends->id) {
             return redirect()->route('home')->withError('Ошибка, свяжитесь с администратором.');
         }
         $thread = new Thread();
         $thread->user_id = $user->id;
         $thread->name = $request->get('name');
         $thread->slug = md5($thread->user_id . '_' . $thread->name . new Carbon());
         $thread->save();
         $thread->addParticipants($friends->id, $thread->id);
         $message = new Message();
         $message->thread_id = $thread->id;
         $message->user_id = $user->id;
         $message->body = $request->get('body');
         $message->save();
         $participant = new Participant();
         $participant->thread_id = $thread->id;
         $participant->user_id = $user->id;
         $participant->last_read = new Carbon();
         $participant->save();
         return redirect()->route('messages')->withMessage('Сообщение отправлено.');
     } else {
         return redirect()->route('messages')->withError('Ошибка, свяжитесь с администратором.');
     }
 }
Esempio n. 19
0
 public function getParticipants(Request $request)
 {
     $query = $request->all()['q'];
     $participants = Participant::where('fullname', 'LIKE', '%' . $query . '%')->get();
     return $participants;
 }
 /**
  * @param $input
  * @return mixed
  */
 private function createParticipantStub($input, $pcode_id, $org)
 {
     $attributes['participant_id'] = array_key_exists('participant_id', $input) ? $input['participant_id'] : null;
     $participant = Participant::firstOrNew(['participant_id' => $attributes['participant_id'], 'pcode_id' => $pcode_id, 'org_id' => $org]);
     $participant->name = array_key_exists('name', $input) ? $input['name'] : 'No Name';
     $participant->avatar = array_key_exists('avatar', $input) ? $input['avatar'] : '';
     $participant->email = array_key_exists('email', $input) ? $input['email'] : 'No Email';
     $participant->nrc_id = array_key_exists('nrc_id', $input) ? $input['nrc_id'] : null;
     $participant->dob = array_key_exists('dob', $input) ? $input['dob'] : '';
     $participant->base = array_key_exists('base', $input) ? $input['base'] : '';
     $participant->gender = array_key_exists('gender', $input) ? $input['gender'] : 'Not Specified';
     $participant->participant_id = array_key_exists('participant_id', $input) ? $input['participant_id'] : null;
     return $participant;
 }
Esempio n. 21
0
 public function index($participant_id)
 {
     $participant = Participant::find($participant_id);
     $data['trials'] = $participant->trials()->get();
     return view('participant', $data);
 }
Esempio n. 22
0
 public function addParticipant(Request $request)
 {
     $participations = null;
     $event = Event::find($request->input('id'));
     //get participant or user model
     if ($request->input('participationType') === 'participant') {
         $participant = Participant::where('fullname', '=', $request->input('fullname'))->firstOrFail();
         $id = $participant->id;
         $participations = $event->participantsParticipation;
     } else {
         $user = User::where('fullname', '=', $request->input('fullname'))->firstOrFail();
         $id = $user->id;
         $participations = $event->usersParticipation;
     }
     $p = null;
     //check whether the participation exist
     foreach ($participations as $participation) {
         if ($participation->participationable_id == $id) {
             $p = $participation;
             break;
         }
     }
     //if does not exist
     if ($p == null) {
         $participation = new Participation();
         $participation->payment = $request->input('amount');
         $participation->paid = 0;
         $participation->attend = 0;
         $participation->event_id = $event->id;
         $participation->note = '';
         if ($request->input('participationType') === 'participant') {
             $this->syncParticipation($participation, $id, 'App\\Participant');
         } else {
             $this->syncParticipation($participation, $id, 'App\\User');
         }
         $participation->save();
         return 1;
     } else {
         return 0;
     }
 }
 /**
  * @param $input
  * @return mixed
  */
 private function createParticipantStub($input, $org)
 {
     $attributes['participant_id'] = array_key_exists('participant_id', $input) ? $input['participant_id'] : null;
     if (array_key_exists('nrc_id', $input)) {
         if ($input['nrc_id']) {
             $nrc_id = $input['nrc_id'];
         } else {
             $nrc_id = null;
         }
     } else {
         $nrc_id = null;
     }
     $participant = Participant::firstOrNew(['participant_id' => $attributes['participant_id'], 'org_id' => $org, 'nrc_id' => $nrc_id]);
     $participant->name = array_key_exists('name', $input) ? $input['name'] : 'No Name';
     $participant->avatar = array_key_exists('avatar', $input) ? $input['avatar'] : '';
     $participant->email = array_key_exists('email', $input) ? $input['email'] : 'No Email';
     if (array_key_exists('nrc_id', $input)) {
         if ($input['nrc_id']) {
             $participant->nrc_id = $input['nrc_id'];
         } else {
             $participant->nrc_id = null;
         }
     } else {
         $participant->nrc_id = null;
     }
     $participant->dob = array_key_exists('dob', $input) ? $input['dob'] : '';
     $array = [];
     $participant->phones = array_key_exists('phones', $input) ? $input['phones'] : $array;
     //$participant->base = (array_key_exists('base', $input)? $input['base']:'');
     $participant->gender = array_key_exists('gender', $input) ? $input['gender'] : 'Not Specified';
     $participant->participant_code = array_key_exists('participant_id', $input) ? $input['participant_id'] : null;
     return $participant;
 }