Updated array() usages to be []

This commit is contained in:
cp6 2023-03-31 11:38:21 +11:00
parent 8a6748f1b0
commit f488e10c2f
3 changed files with 30 additions and 30 deletions

View File

@ -264,7 +264,7 @@ class ApiController extends Controller
protected function storeServer(Request $request)
{
$rules = array(
$rules = [
'hostname' => 'min:3',
'server_type' => 'required|integer',
'os_id' => 'required|integer',
@ -289,9 +289,9 @@ class ApiController extends Controller
'price' => 'required|numeric',
'payment_term' => 'required|integer',
'next_due_date' => 'date',
);
];
$messages = array(
$messages = [
'required' => ':attribute is required',
'min' => ':attribute must be longer than 3',
'integer' => ':attribute must be an integer',
@ -300,7 +300,7 @@ class ApiController extends Controller
'numeric' => ':attribute must be a float',
'ip' => ':attribute must be a valid IP address',
'date' => ':attribute must be a date Y-m-d',
);
];
$validator = Validator::make($request->all(), $rules, $messages);
@ -375,7 +375,7 @@ class ApiController extends Controller
public function updateServer(Request $request)
{
$rules = array(
$rules = [
'hostname' => 'string|min:3',
'server_type' => 'integer',
'os_id' => 'integer',
@ -398,9 +398,9 @@ class ApiController extends Controller
'price' => 'numeric',
'payment_term' => 'integer',
'next_due_date' => 'date',
);
];
$messages = array(
$messages = [
'required' => ':attribute is required',
'min' => ':attribute must be longer than 3',
'integer' => ':attribute must be an integer',
@ -408,7 +408,7 @@ class ApiController extends Controller
'size' => ':attribute must be exactly :size characters',
'numeric' => ':attribute must be a float',
'date' => ':attribute must be a date Y-m-d',
);
];
$validator = Validator::make($request->all(), $rules, $messages);
@ -430,22 +430,22 @@ class ApiController extends Controller
public function updatePricing(Request $request)
{
$rules = array(
$rules = [
'price' => 'required|numeric',
'currency' => 'required|string|size:3',
'term' => 'required|integer',
'active' => 'integer',
'next_due_date' => 'date',
);
];
$messages = array(
$messages = [
'required' => ':attribute is required',
'integer' => ':attribute must be an integer',
'string' => ':attribute must be a string',
'size' => ':attribute must be exactly :size characters',
'numeric' => ':attribute must be a float',
'date' => ':attribute must be a date Y-m-d',
);
];
$validator = Validator::make($request->all(), $rules, $messages);

View File

@ -47,7 +47,7 @@ class HomeController extends Controller
$p->stopTimer();
$information = array(
$information = [
'servers' => $service_count['servers'],
'domains' => $service_count['domains'],
'shared' => $service_count['shared'],
@ -67,7 +67,7 @@ class HomeController extends Controller
'execution_time' => number_format($p->getTimeTaken(), 2),
'servers_summary' => $server_summary,
'currency' => Session::get('dashboard_currency')
);
];
return view('home', compact('information'));
}

View File

@ -58,20 +58,20 @@ class Yabs extends Model
{
$speed_tests = [];
foreach ($data->network_speed as $ns) {
$speed_tests[] = array(
$speed_tests[] = [
'location' => $ns->location,
'send' => $ns->send . ' ' . $ns->send_type,
'receive' => $ns->receive . ' ' . $ns->receive_type,
);
];
}
return array(
return [
'date_time' => $data->output_date,
'location' => $data->server->location->name,
'provider' => $data->server->provider->name,
'uptime' => $data->uptime,
'distro' => $data->distro,
'kernel' => $data->kernel,
'cpu' => array(
'cpu' => [
'cores' => $data->cpu_cores,
'speed_mhz' => $data->cpu_freq,
'model' => $data->cpu_model,
@ -79,30 +79,30 @@ class Yabs extends Model
'vm' => $data->vm === 1,
'GB5_single' => $data->gb5_single,
'GB5_multi' => $data->gb5_multi,
),
'ram' => array(
],
'ram' => [
'amount' => $data->ram . ' ' . $data->ram_type,
'mb' => $data->ram_mb,
'swap' => array(
'swap' => [
'amount' => $data->swap ?? null . ' ' . $data->swap_type ?? null,
'mb' => $data->swap_mb ?? null,
),
),
'disk' => array(
],
],
'disk' => [
'amount' => $data->disk . ' ' . $data->disk_type,
'gb' => $data->disk_gb,
'speed_tests' => array(
'speed_tests' => [
'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(
],
],
'network' => [
'has_ipv6' => $data->has_ipv6 === 1,
'speed_tests' => $speed_tests
),
);
],
];
}
public static function speedAsMbps(string $string): float