Set icon filename generation as a helper function

This commit is contained in:
Bubka 2022-10-10 11:21:42 +02:00
parent e79ae0a3ed
commit 1af32ecbf4
3 changed files with 23 additions and 2 deletions

20
app/Helpers/Helpers.php Normal file
View File

@ -0,0 +1,20 @@
<?php
namespace App\Helpers;
use Illuminate\Support\Str;
class Helpers
{
/**
* Generate a unique filename
*
* @param string $ids twofaccount ids to delete
*
* @return string The filename
*/
public static function getUniqueFilename(string $extension): string
{
return Str::random(40).'.'.$extension;
}
}

View File

@ -29,6 +29,7 @@
use ParagonIE\ConstantTime\Base32;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Http;
use App\Helpers\Helpers;
class TwoFAccount extends Model implements Sortable
{
@ -537,7 +538,7 @@ private function storeImageAsIcon(string $url)
{
try {
$path_parts = pathinfo($url);
$newFilename = Str::random(40).'.'.$path_parts['extension'];
$newFilename = Helpers::getUniqueFilename($path_parts['extension']); //Str::random(40).'.'.$path_parts['extension'];
$imageFile = self::IMAGELINK_STORAGE_PATH . $newFilename;
try {

View File

@ -232,7 +232,7 @@
'QrCode' => App\Facades\QrCode::class,
'Groups' => App\Facades\Groups::class,
'TwoFAccounts' => App\Facades\TwoFAccounts::class,
'Helpers' => App\Helpers\Helpers::class,
],
];