mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
vector maps coordinates added
This commit is contained in:
54
app/Console/Commands/Database/ImportGithubMeetups.php
Normal file
54
app/Console/Commands/Database/ImportGithubMeetups.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Database;
|
||||
|
||||
use App\Models\City;
|
||||
use App\Models\Country;
|
||||
use App\Models\Meetup;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ImportGithubMeetups extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'import:meetups';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$meetups = json_decode(file_get_contents(config_path('meetups/github.json')), true, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
foreach ($meetups as $meetup) {
|
||||
$city = City::updateOrCreate([
|
||||
'name' => $meetup['city'],
|
||||
], [
|
||||
'country_id' => Country::firstOrCreate([
|
||||
'code' => str($meetup['country'])
|
||||
->lower()
|
||||
->toString()
|
||||
], ['name' => $meetup['country']])->id,
|
||||
'longitude' => $meetup['longitude'],
|
||||
'latitude' => $meetup['latitude'],
|
||||
]);
|
||||
$meetup = Meetup::updateOrCreate(
|
||||
['name' => $meetup['name']],
|
||||
[
|
||||
'city_id' => $city->id,
|
||||
'link' => $meetup['url'],
|
||||
]);
|
||||
}
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user