api_token, $this->url); $response = $http->post("hosts/{$host_id}/functions/" . $func, $requests); $json = $response->json(); $status = $response->status(); return [$json, $status]; } public function remote($func, $requests) { $http = Http::remote($this->api_token, $this->url); $response = $http->post('functions/' . $func, $requests); $json = $response->json(); $status = $response->status(); return [$json, $status]; } public function remotePost($path = '', $data = []) { $http = Http::remote($this->api_token, $this->url); $response = $http->post($path, $data); $json = $response->json(); $status = $response->status(); return [$json, $status]; } protected static function boot() { parent::boot(); static::creating(function ($model) { // if local if (!app()->environment('local')) { $model->api_token = Str::random(60); } }); } }