You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							33 lines
						
					
					
						
							641 B
						
					
					
				
			
		
		
	
	
							33 lines
						
					
					
						
							641 B
						
					
					
				<?php
 | 
						|
 | 
						|
namespace App\DotsAPI\API\v2;
 | 
						|
 | 
						|
use App\DotsAPI\API\v2\AbstractItemAPI;
 | 
						|
use App\Models\City;
 | 
						|
 | 
						|
class CityAPI extends AbstractItemAPI
 | 
						|
{
 | 
						|
    public function getMap() {
 | 
						|
        $endpoint = '/api/v2/cities';
 | 
						|
 | 
						|
        $citiesMap = $this->fetcher->get($endpoint);
 | 
						|
 | 
						|
        return $citiesMap;
 | 
						|
    }
 | 
						|
 | 
						|
    public function saveMap($cities) {
 | 
						|
        foreach ($cities as $city) {
 | 
						|
            $uuid = $city['id'];
 | 
						|
            $name = $city['name'];
 | 
						|
            $url = $city['url'];
 | 
						|
 | 
						|
            City::firstOrCreate([
 | 
						|
                'uuid' => $uuid,
 | 
						|
                'name' => $name,
 | 
						|
                'url' => $url
 | 
						|
            ]);
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 | 
						|
 |