info("Can't get hostname"); return self::FAILURE; } //Used cache $size = $this->getUsedCached(); $server = \App\Models\Server::query()->where("servername", "=", $hostname)->first(); if(is_null($server)) { $server = new \App\Models\Server(); $server->servername = $hostname; $server->storage = disk_free_space(storage_path("cache")) - (1024*1000000) + $size; } $server->last_seen = date("Y-m-d H:i:s"); $server->userd = $size; $server->saveOrFail(); return 0; } private function getUsedCached() { $r = \Illuminate\Support\Facades\Storage::disk("cache")->allFiles(); $size = 0; foreach ($r as $item) { $size += \Illuminate\Support\Facades\Storage::disk("cache")->size($item); } return $size; } }