api refactoring

This commit is contained in:
Čarodej
2022-05-11 09:19:55 +02:00
parent d2371e667f
commit c0e431b384
76 changed files with 1142 additions and 690 deletions
@@ -3,7 +3,8 @@ namespace Support\Demo\Actions;
use ByteUnits\Metric;
use Illuminate\Support\Str;
use Domain\Files\Requests\UploadRequest;
use Domain\Files\Requests\UploadFileRequest;
use Domain\Files\Requests\UploadChunkRequest;
class FakeUploadFileAction
{
@@ -11,7 +12,7 @@ class FakeUploadFileAction
* Upload file
*/
public function __invoke(
UploadRequest $request
UploadChunkRequest|UploadFileRequest $request
): array {
$file = $request->file('file');
$thumbnail = 'data:' . $request->file('file')->getMimeType() . ';base64, ' . base64_encode(file_get_contents($request->file('file')));
+10 -10
View File
@@ -142,11 +142,11 @@ if (! function_exists('get_settings')) {
}
}
if (! function_exists('get_settings_in_json')) {
if (! function_exists('getAllSettings')) {
/**
* Get all app settings and return them as json
*/
function get_settings_in_json()
function getAllSettings()
{
return json_decode(
Setting::all()
@@ -156,13 +156,13 @@ if (! function_exists('get_settings_in_json')) {
}
}
if (! function_exists('get_setup_status')) {
if (! function_exists('getInstallationStatus')) {
/**
* Check if setup wizard was passed
*
* @return string
*/
function get_setup_status()
function getInstallationStatus()
{
$setup_success = get_settings('setup_wizard_success');
@@ -501,14 +501,14 @@ if (! function_exists('make_single_input')) {
}
}
if (! function_exists('format_gigabytes')) {
if (! function_exists('toGigabytes')) {
/**
* Format integer to gigabytes
*
* @param $gigabytes
* @return string
*/
function format_gigabytes($gigabytes)
function toGigabytes($gigabytes)
{
if ($gigabytes >= 1000) {
return Metric::gigabytes($gigabytes)->format('Tb/');
@@ -518,14 +518,14 @@ if (! function_exists('format_gigabytes')) {
}
}
if (! function_exists('format_megabytes')) {
if (! function_exists('toMegabytes')) {
/**
* Format string to formated megabytes string
*
* @param $megabytes
* @return string
*/
function format_megabytes($megabytes)
function toMegabytes($megabytes)
{
if ($megabytes >= 1000) {
return $megabytes / 1000 . 'GB';
@@ -539,14 +539,14 @@ if (! function_exists('format_megabytes')) {
}
}
if (! function_exists('format_bytes')) {
if (! function_exists('toBytes')) {
/**
* Convert megabytes to bytes
*
* @param $megabytes
* @return int|string
*/
function format_bytes($megabytes)
function toBytes($megabytes)
{
return Metric::megabytes($megabytes)->numberOfBytes();
}