mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-31 05:31:10 -04:00 
			
		
		
		
	add auto update feature
This commit is contained in:
		
							
								
								
									
										35
									
								
								app/Space/SiteApi.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								app/Space/SiteApi.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Laraspace\Space; | ||||
|  | ||||
| use GuzzleHttp\Client; | ||||
| use GuzzleHttp\Exception\RequestException; | ||||
|  | ||||
| trait SiteApi | ||||
| { | ||||
|  | ||||
|     protected static function getRemote($url, $data = array()) | ||||
|     { | ||||
|         $base = 'https://codeload.github.com/'; | ||||
|  | ||||
|         $client = new Client(['verify' => false, 'base_uri' => $base]); | ||||
|  | ||||
|         $headers['headers'] = array( | ||||
|             'Accept'        => 'application/json', | ||||
|             'Referer'       => url('/'), | ||||
|             'crater'        => getFullVersion() | ||||
|         ); | ||||
|  | ||||
|         $data['http_errors'] = false; | ||||
|  | ||||
|         $data = array_merge($data, $headers); | ||||
|  | ||||
|         try { | ||||
|             $result = $client->get($url, $data); | ||||
|         } catch (RequestException $e) { | ||||
|             $result = $e; | ||||
|         } | ||||
|  | ||||
|         return $result; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user