Conoslidate external URLs for a place into a single JSON column
This commit is contained in:
parent
3d734201a2
commit
8ae5d4e770
6 changed files with 63 additions and 22 deletions
|
@ -47,7 +47,11 @@ class PlaceService
|
|||
{
|
||||
//check if the place exists if from swarm
|
||||
if (array_key_exists('url', $checkin['properties']) && ends_with(parse_url($checkin['properties']['url'][0], PHP_URL_HOST), 'foursquare.com')) {
|
||||
$place = Place::where('foursquare', $checkin['properties']['url'][0])->get();
|
||||
$place = Place::where(
|
||||
'external_urls',
|
||||
'@>',
|
||||
json_encode('foursquare' => $checkin['properties']['url'][0]
|
||||
)->get();
|
||||
if (count($place) === 1) {
|
||||
return $place->first();
|
||||
}
|
||||
|
|
20
composer.lock
generated
20
composer.lock
generated
|
@ -8,16 +8,16 @@
|
|||
"packages": [
|
||||
{
|
||||
"name": "aws/aws-sdk-php",
|
||||
"version": "3.30.1",
|
||||
"version": "3.30.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/aws/aws-sdk-php.git",
|
||||
"reference": "d234cb5e111945eb4bfca7eda0eef07a25750b29"
|
||||
"reference": "20539a38dc643a2700f80ae8647dbd1a05d3f7a9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/d234cb5e111945eb4bfca7eda0eef07a25750b29",
|
||||
"reference": "d234cb5e111945eb4bfca7eda0eef07a25750b29",
|
||||
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/20539a38dc643a2700f80ae8647dbd1a05d3f7a9",
|
||||
"reference": "20539a38dc643a2700f80ae8647dbd1a05d3f7a9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -84,7 +84,7 @@
|
|||
"s3",
|
||||
"sdk"
|
||||
],
|
||||
"time": "2017-06-22T22:40:58+00:00"
|
||||
"time": "2017-06-23T18:54:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "barnabywalters/mf-cleaner",
|
||||
|
@ -2728,16 +2728,16 @@
|
|||
},
|
||||
{
|
||||
"name": "psy/psysh",
|
||||
"version": "v0.8.7",
|
||||
"version": "v0.8.8",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/bobthecow/psysh.git",
|
||||
"reference": "be969b9dc89dcaefdb9a3117fa91fa38bca19f50"
|
||||
"reference": "fe65c30cbc55c71e61ba3a38b5a581149be31b8e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/be969b9dc89dcaefdb9a3117fa91fa38bca19f50",
|
||||
"reference": "be969b9dc89dcaefdb9a3117fa91fa38bca19f50",
|
||||
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/fe65c30cbc55c71e61ba3a38b5a581149be31b8e",
|
||||
"reference": "fe65c30cbc55c71e61ba3a38b5a581149be31b8e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2797,7 +2797,7 @@
|
|||
"interactive",
|
||||
"shell"
|
||||
],
|
||||
"time": "2017-06-20T12:51:31+00:00"
|
||||
"time": "2017-06-24T06:16:19+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ramsey/uuid",
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class UpdatePlacesTableAddExternalUrls extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('places', function (Blueprint $table) {
|
||||
$table->jsonb('external_urls')->nullable();
|
||||
$table->index('external_urls');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('places', function (Blueprint $table) {
|
||||
$table->dropIndex('places_external_urls_index');
|
||||
$table->dropColumn('external_urls');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
use App\Place;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Phaza\LaravelPostgis\Geometries\Point;
|
||||
|
||||
class PlacesTableSeeder extends Seeder
|
||||
{
|
||||
|
@ -11,13 +13,14 @@ class PlacesTableSeeder extends Seeder
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('places')->insert([
|
||||
'name' => 'The Bridgewater Pub',
|
||||
'slug' => 'the-bridgewater-pub',
|
||||
'description' => 'A lovely local pub with a decent selection of cask ales',
|
||||
'location' => 'POINT(-2.3805 53.4983)',
|
||||
'created_at' => '2016-01-12 16:19:00',
|
||||
'updated_at' => '2016-01-12 16:19:00',
|
||||
$place = new Place();
|
||||
$place->name = 'The Bridgewater Pub';
|
||||
$place->description = 'A lovely local pub with a decent selection of cask ales';
|
||||
$place->location = new Point('53.4983', '-2.3805');
|
||||
$place->external_urls = json_encode([
|
||||
'foursqaure' => 'https://foursqaure.com/v/123435/the-bridgewater-pub',
|
||||
'osm' => 'https://www.openstreetmap.org/way/987654',
|
||||
]);
|
||||
$place->save();
|
||||
}
|
||||
}
|
||||
|
|
6
package-lock.json
generated
6
package-lock.json
generated
|
@ -4329,9 +4329,9 @@
|
|||
}
|
||||
},
|
||||
"webStorage": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/webStorage/-/webStorage-1.2.3.tgz",
|
||||
"integrity": "sha1-CHN87eWk2ouophKKYoQHB0Cwxxg="
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/webStorage/-/webStorage-1.2.4.tgz",
|
||||
"integrity": "sha1-/jNN8N5uLe58i9A2uxVaw115FTY="
|
||||
},
|
||||
"webworkify": {
|
||||
"version": "1.4.0",
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"mapbox-gl": "^0.38.0",
|
||||
"marked": "^0.3.6",
|
||||
"normalize.css": "^7.0.0",
|
||||
"webStorage": "^1.2.3"
|
||||
"webStorage": "^1.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.18.0",
|
||||
|
|
Loading…
Add table
Reference in a new issue