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.'); } }); }
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; } }
public function invited() { $user = Auth::user(); $participations = Participant::where('mail', $user->mail)->get(); $rooms = array(); foreach ($participations as $part) { $rooms[] = $part->room; } return view('room.rooms', ['rooms' => $rooms]); }
public function getParticipantByCode($pcode, $org_id) { return Participant::where('participant_id', $pcode)->where('org_id', $org_id)->first(); }
public function getParticipants(Request $request) { $query = $request->all()['q']; $participants = Participant::where('fullname', 'LIKE', '%' . $query . '%')->get(); return $participants; }
public function hideThreads(Request $request, $slug) { $user = User::where('id', $request->user()->id)->first(); $thread = Thread::where('slug', $slug)->first(); if ($user && $thread) { $destroy = Participant::where('thread_id', $thread->id)->where('user_id', $request->user()->id)->first(); $destroy->deleted_at = new Carbon(); $destroy->save(); return redirect()->route('messages')->withMessage('Переписка архивирована.'); } else { return redirect()->route('messages')->withError('Ошибка, свяжитесь с администратором.'); } }