Allow databases to be seeded again
This commit is contained in:
parent
cfea8c29c9
commit
c2912781bf
2 changed files with 6 additions and 8 deletions
|
@ -130,17 +130,17 @@ class Place extends Model
|
||||||
return config('app.shorturl') . '/places/' . $this->slug;
|
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) {
|
if ($type === null) {
|
||||||
throw new \Exception('Unkown external url type');
|
throw new \Exception('Unkown external url type ' . $url);
|
||||||
}
|
}
|
||||||
$already = [];
|
$already = [];
|
||||||
if (array_key_exists('external_urls', $this->attributes)) {
|
if (array_key_exists('external_urls', $this->attributes)) {
|
||||||
$already = json_decode($this->attributes['external_urls'], true);
|
$already = json_decode($this->attributes['external_urls'], true);
|
||||||
}
|
}
|
||||||
$already[$type] = $value;
|
$already[$type] = $url;
|
||||||
$this->attributes['external_urls'] = json_encode($already);
|
$this->attributes['external_urls'] = json_encode($already);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,8 @@ class PlacesTableSeeder extends Seeder
|
||||||
$place->name = 'The Bridgewater Pub';
|
$place->name = 'The Bridgewater Pub';
|
||||||
$place->description = 'A lovely local pub with a decent selection of cask ales';
|
$place->description = 'A lovely local pub with a decent selection of cask ales';
|
||||||
$place->location = new Point('53.4983', '-2.3805');
|
$place->location = new Point('53.4983', '-2.3805');
|
||||||
$place->external_urls = json_encode([
|
$place->external_urls = 'https://foursquare.com/v/123435/the-bridgewater-pub';
|
||||||
'foursqaure' => 'https://foursqaure.com/v/123435/the-bridgewater-pub',
|
$place->external_urls = 'https://www.openstreetmap.org/way/987654';
|
||||||
'osm' => 'https://www.openstreetmap.org/way/987654',
|
|
||||||
]);
|
|
||||||
$place->save();
|
$place->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue