mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-08-01 08:16:55 -04:00
60 lines
1.7 KiB
PHP
60 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Modules\GoogleCloudPlatform\Helpers;
|
|
|
|
use File;
|
|
use Setting;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class Helper
|
|
{
|
|
public static function getConfig()
|
|
{
|
|
$generalSetting = \Modules\GeneralSetting\Entities\GeneralSetting::first();
|
|
if(!empty($generalSetting)){
|
|
$config = null;
|
|
$value = $generalSetting->gcp_storage;
|
|
|
|
if(!empty($value) && $value != '') {
|
|
|
|
$fixed_data = preg_replace_callback ( '!s:(\d+):"(.*?)";!', function($match) {
|
|
return ($match[1] == strlen($match[2])) ? $match[0] : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
|
|
}, $value );
|
|
|
|
$config = unserialize($fixed_data);
|
|
}
|
|
|
|
return $config;
|
|
}
|
|
}
|
|
|
|
public static function getStorageConfig()
|
|
{
|
|
$config = self::getConfig();
|
|
|
|
if(isset($config['GOOGLE_CLOUD_PROJECT_ID'])){
|
|
|
|
$storage_config['driver'] = 'gcs';
|
|
$storage_config['project_id'] = $config['GOOGLE_CLOUD_PROJECT_ID'];
|
|
$storage_config['bucket'] = $config['GOOGLE_CLOUD_STORAGE_BUCKET'];
|
|
$storage_config['storage_api_uri'] = 'https://storage.googleapis.com';
|
|
$storage_config['key_file'] = json_decode($config['GOOGLE_CLOUD_AUTH_JSON_OBJECT'],true);
|
|
|
|
return $storage_config;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static function getImageDirectoryPath()
|
|
{
|
|
$config = self::getConfig();
|
|
return $config['GOOGLE_CLOUD_DIRECTORY_IMAGE'] ?? 'images';
|
|
}
|
|
|
|
public static function getVideoDirectoryPath()
|
|
{
|
|
$config = self::getConfig();
|
|
return $config['GOOGLE_CLOUD_DIRECTORY_VIDEO'] ?? 'videos';
|
|
}
|
|
} |