Initial commit to new repo
This commit is contained in:
parent
a267f9bfcc
commit
a5173c981b
292 changed files with 17472 additions and 0 deletions
39
app/Services/PlaceService.php
Normal file
39
app/Services/PlaceService.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Place;
|
||||
use Illuminate\Http\Request;
|
||||
use Phaza\LaravelPostgis\Geometries\Point;
|
||||
|
||||
class PlaceService
|
||||
{
|
||||
/**
|
||||
* Create a place.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \App\Place
|
||||
*/
|
||||
public function createplace(Request $request)
|
||||
{
|
||||
//we’ll either have latitude and longitude sent together in a
|
||||
//geo-url (micropub), or seperatley (/admin)
|
||||
if ($request->input('geo') !== null) {
|
||||
$parts = explode(':', $request->input('geo'));
|
||||
$latlng = explode(',', $parts[1]);
|
||||
$latitude = $latlng[0];
|
||||
$longitude = $latlng[1];
|
||||
}
|
||||
if ($request->input('latitude') !== null) {
|
||||
$latitude = $request->input('latitude');
|
||||
$longitude = $request->input('longitude');
|
||||
}
|
||||
$place = new Place();
|
||||
$place->name = $request->input('name');
|
||||
$place->description = $request->input('description');
|
||||
$place->location = new Point((float) $latitude, (float) $longitude);
|
||||
$place->save();
|
||||
|
||||
return $place;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue