/** * @param $id * @return mixed */ public function showProject($id) { $project = Project::find($id); if ($id == 'random') { $projects = Project::all(); $project = $projects[mt_rand(0, count($projects) - 1)]; } if (!$project) { return redirect('search')->with('error', 'Oops! It seems we can\'t find the page you are looking for. Try search instead.'); } $geojson = 'pin-l-circle-stroked+1abc9c(' . $project->geo()->lng . ',' . $project->geo()->lat . ')/' . $project->geo()->lng . ',' . $project->geo()->lat . '),13'; $map_image_link = 'https://api.tiles.mapbox.com/v4/codeforafrica.ji193j10/' . $geojson . '/520x293.png256?' . 'access_token=pk.eyJ1IjoiY29kZWZvcmFmcmljYSIsImEiOiJVLXZVVUtnIn0.JjVvqHKBGQTNpuDMJtZ8Qg'; $data = compact('project', 'map_image_link', 'geojson'); return view('home.project', $data); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $project = Project::find($id); if ($id == 'random') { $projects = Project::all(); $project = $projects[mt_rand(0, count($projects) - 1)]; } if (!$project) { return response()->json(array('error' => true, 'project' => 'Not found'), 404); } if (\Input::has('embed')) { $geojson = 'pin-l-circle-stroked+1abc9c(' . $project->geo_lng . ',' . $project->geo_lat . ')/' . $project->geo_lng . ',' . $project->geo_lat . '),13'; $map_image_link = 'http://api.tiles.mapbox.com/v4/codeforafrica.ji193j10/' . $geojson . '/600x250.png256?' . 'access_token=pk.eyJ1IjoiY29kZWZvcmFmcmljYSIsImEiOiJVLXZVVUtnIn0.JjVvqHKBGQTNpuDMJtZ8Qg'; $data = compact('project', 'map_image_link', 'geojson'); return view('home.project_embed', $data); } return response()->json(array('error' => false, 'project' => $project), 200); }
/** * Execute the command. * * @return void */ public function handle() { $alert = Alert::find($this->alert_id); if ($alert->status != 0) { return; } else { $alert->status = 1; $alert->save(); } $project = Project::find($alert->project_id); $project_lat = $project->geo->lat; $project_lng = $project->geo->lng; if ($project_lat != 450.0 && $project_lng != 450.0) { $subscriptions = Subscription::where('sw_lat', '<', $project_lat)->where('sw_lng', '<', $project_lng)->where('ne_lat', '>', $project_lat)->where('ne_lng', '>', $project_lng)->select('user_id')->distinct()->get(); foreach ($subscriptions as $subscription) { $user = User::find($subscription->user_id); $data = compact('user', 'project'); \Mail::queue('emails.alerts.status', $data, function ($message) use($user) { $message->to($user->email, '')->subject('[#GreenAlert] You\'ve got an update'); }); } } }