Add a helper artisan command to update place model structure
This commit is contained in:
parent
4afb6a3ae9
commit
e540eb767f
3 changed files with 60 additions and 0 deletions
58
app/Console/Commands/UpdatePlacesURLs.php
Normal file
58
app/Console/Commands/UpdatePlacesURLs.php
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Place;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class UpdatePlacesURLs extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'places:update-urls';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Copy any URLs in the place model to the new external URLs JSON column.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The places collection.
|
||||||
|
*
|
||||||
|
* @var Illuminate\Database\Eloquent\Collection
|
||||||
|
*/
|
||||||
|
protected $places;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->places = Place::all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
foreach ($this->places as $place) {
|
||||||
|
if ($place->foursqaure !== null) {
|
||||||
|
$place->external_urls = $place->foursquare;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info('All Places have had their external URLs values updated to the new structure.');
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,6 +17,7 @@ class Kernel extends ConsoleKernel
|
||||||
Commands\ParseCachedWebMentions::class,
|
Commands\ParseCachedWebMentions::class,
|
||||||
Commands\ReDownloadWebMentions::class,
|
Commands\ReDownloadWebMentions::class,
|
||||||
Commands\GenerateToken::class,
|
Commands\GenerateToken::class,
|
||||||
|
Commands\UpdatePlacesURLs::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## Version {next}
|
## Version {next}
|
||||||
- Transition to using a JSON column for external urls of places
|
- Transition to using a JSON column for external urls of places
|
||||||
|
- Add a command to update external url structure of places
|
||||||
|
|
||||||
## Version 0.5.19 (2017-06-27)
|
## Version 0.5.19 (2017-06-27)
|
||||||
- Fix error in App\\WebMention.php
|
- Fix error in App\\WebMention.php
|
||||||
|
|
Loading…
Add table
Reference in a new issue