From c2912781bfa8746002ecaa6e98ffea5e6994e5e4 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Fri, 30 Jun 2017 14:01:26 +0100 Subject: [PATCH] Allow databases to be seeded again --- app/Place.php | 8 ++++---- database/seeds/PlacesTableSeeder.php | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/Place.php b/app/Place.php index cc7a3341..b594f752 100644 --- a/app/Place.php +++ b/app/Place.php @@ -130,17 +130,17 @@ class Place extends Model return config('app.shorturl') . '/places/' . $this->slug; } - public function setExternalUrlsAttribute($value) + public function setExternalUrlsAttribute($url) { - $type = $this->getType($value); + $type = $this->getType($url); if ($type === null) { - throw new \Exception('Unkown external url type'); + throw new \Exception('Unkown external url type ' . $url); } $already = []; if (array_key_exists('external_urls', $this->attributes)) { $already = json_decode($this->attributes['external_urls'], true); } - $already[$type] = $value; + $already[$type] = $url; $this->attributes['external_urls'] = json_encode($already); } diff --git a/database/seeds/PlacesTableSeeder.php b/database/seeds/PlacesTableSeeder.php index cef1ebb6..4b787536 100644 --- a/database/seeds/PlacesTableSeeder.php +++ b/database/seeds/PlacesTableSeeder.php @@ -17,10 +17,8 @@ class PlacesTableSeeder extends Seeder $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->external_urls = 'https://foursquare.com/v/123435/the-bridgewater-pub'; + $place->external_urls = 'https://www.openstreetmap.org/way/987654'; $place->save(); } }