/** * Execute the console command. * * @return mixed */ public function handle() { Hotspot::truncate(); $places = Place::all(); $clusters = $this->getClusters($places->all(), 1.5); $centroids = $this->getCentroids($clusters); $hotspots = array_map(function ($centroid) { $locality = $this->getLocalityForLatLon($centroid['latitude'], $centroid['longitude']); $categories = []; foreach ($centroid['places'] as $place) { foreach ($place->ranks as $rank) { if (!isset($categories[$rank->category->name])) { $categories[$rank->category->name] = 0; } $categories[$rank->category->name]++; } } arsort($categories); $categoryNames = array_keys($categories); return Hotspot::create(['name' => $locality, 'known_for' => implode(', ', $categoryNames), 'latitude' => $centroid['latitude'], 'longitude' => $centroid['longitude'], 'count' => $centroid['count']]); }, $centroids); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $places = Place::all(); return view('places/index')->with('places', $places); }
public function index() { $Places = Place::all(); return response()->json($Places); }
public function getPlaces() { $response = $this->response; $places = Place::all(); return $response->successResponse(200, "All available places", $places); }
public function index() { return view('admin.place.index')->withPlaces(Place::all()); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $places = Place::all()->load('user'); return response()->json($places); }