addMonth(1), function () use ($yabs_id) { return self::where('id', $yabs_id)->with(['server', 'disk_speed', 'network_speed', 'server.location', 'server.provider']) ->get(); }); } public static function allYabs() { return Cache::remember("all_yabs", now()->addMonth(1), function () { return self::with(['server', 'disk_speed', 'network_speed', 'server.location', 'server.provider']) ->get(); }); } public function server() { return $this->hasOne(Server::class, 'id', 'server_id'); } public function disk_speed() { return $this->hasOne(DiskSpeed::class, 'id', 'id'); } public function network_speed() { return $this->hasMany(NetworkSpeed::class, 'id', 'id'); } public static function buildYabsArray($data): array { $speed_tests = []; foreach ($data->network_speed as $ns) { $speed_tests[] = array( 'location' => $ns->location, 'send' => $ns->send.' '.$ns->send_type, 'receive' => $ns->receive.' '.$ns->receive_type, ); } return array( 'date_time' => $data->output_date, 'location' => $data->server->location->name, 'provider' => $data->server->provider->name, 'cpu' => array( 'cores' => $data->cpu_cores, 'speed_mhz' => $data->cpu_freq, 'model' => $data->cpu_model, 'aes' => $data->aes === 1, 'vm' => $data->vm === 1, 'GB5_single' => $data->gb5_single, 'GB5_multi' => $data->gb5_multi, ), 'ram' => array( 'amount' => $data->ram.' '.$data->ram_type, 'mb' => $data->ram_mb, ), 'disk' => array( 'amount' => $data->disk.' '.$data->disk_type, 'gb' => $data->disk_gb, 'speed_tests' => array( '4k' => $data->disk_speed->d_4k.' '.$data->disk_speed->d_4k_type, '64k' => $data->disk_speed->d_64k.' '.$data->disk_speed->d_64k_type, '512k' => $data->disk_speed->d_512k.' '.$data->disk_speed->d_512k_type, '1m' => $data->disk_speed->d_1m.' '.$data->disk_speed->d_1m_type, ), ), 'network' => array( 'has_ipv6' => $data->has_ipv6 === 1, 'speed_tests' => $speed_tests ), ); } }