Merge remote-tracking branch 'origin/master' into email-verification

This commit is contained in:
Milos Holba
2021-05-26 13:17:39 +02:00
139 changed files with 6938 additions and 4526 deletions
@@ -1,7 +1,6 @@
<?php
namespace App\Http\Controllers\Admin;
use DB;
use App\Models\User;
use ByteUnits\Metric;
use App\Services\StripeService;
@@ -11,9 +10,8 @@ use App\Http\Resources\UsersCollection;
class DashboardController extends Controller
{
/**
* @param StripeService $stripe
*/
private StripeService $stripe;
public function __construct(StripeService $stripe)
{
$this->stripe = $stripe;
@@ -32,7 +30,7 @@ class DashboardController extends Controller
// Get total storage usage
$storage_usage = Metric::bytes(
DB::table('files')->sum('filesize')
\DB::table('files')->sum('filesize')
)->format();
return [
@@ -9,9 +9,8 @@ use App\Http\Resources\InvoiceAdminCollection;
class InvoiceController extends Controller
{
/**
* @param StripeService $stripe
*/
private StripeService $stripe;
public function __construct(StripeService $stripe)
{
$this->stripe = $stripe;
@@ -12,6 +12,8 @@ use Illuminate\Contracts\Routing\ResponseFactory;
class PagesController extends Controller
{
private $demo;
public function __construct()
{
$this->demo = resolve(DemoService::class);
@@ -18,12 +18,13 @@ use Illuminate\Contracts\Routing\ResponseFactory;
class PlanController extends Controller
{
/**
* @param StripeService $stripe
*/
public function __construct(StripeService $stripe)
private StripeService $stripe;
private DemoService $demo;
public function __construct()
{
$this->stripe = $stripe;
$this->stripe = resolve(StripeService::class);
$this->demo = resolve(DemoService::class);
}
@@ -12,9 +12,8 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
class SettingController extends Controller
{
/**
* SettingController constructor.
*/
private $demo;
public function __construct()
{
$this->demo = resolve(DemoService::class);
@@ -23,6 +23,8 @@ use App\Http\Requests\Admin\ChangeStorageCapacityRequest;
class UserController extends Controller
{
private StripeService $stripe;
public function __construct(StripeService $stripe)
{
$this->stripe = $stripe;
@@ -25,11 +25,13 @@ class AppFunctionsController extends Controller
*
* @var array
*/
private $blacklist = [
private array $blacklist = [
'purchase_code',
'license',
];
private StripeService $stripe;
public function __construct(StripeService $stripe)
{
$this->stripe = $stripe;
@@ -149,6 +149,7 @@ class EditItemsController extends Controller
*
* @param Request $request
* @return string
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function zip_multiple_files(Request $request)
{
@@ -15,6 +15,10 @@ use App\Http\Requests\Payments\RegisterNewPaymentMethodRequest;
class PaymentMethodsController extends Controller
{
private StripeService $stripe;
private DemoService $demo;
public function __construct(StripeService $stripe)
{
$this->stripe = $stripe;
+21 -30
View File
@@ -277,7 +277,7 @@ function is_visitor($shared)
*
* @param $request
* @param $name
* @return string
* @return string|null
*/
function store_avatar($request, $name)
{
@@ -290,14 +290,20 @@ function store_avatar($request, $name)
// Store avatar
$image_path = Str::random(16) . '-' . $image->getClientOriginalName();
// Create intervention image
$img = Image::make($image->getRealPath());
if (in_array($image->getClientMimeType(), ['image/gif', 'image/jpeg', 'image/jpg', 'image/png', 'image/webp'])) {
// Create intervention image
$img = Image::make($image->getRealPath());
// Generate thumbnail
$img->fit('150', '150')->stream();
// Generate thumbnail
$img->fit('150', '150')->stream();
// Store thumbnail to disk
Storage::put("avatars/$image_path", $img);
// Store thumbnail to disk
Storage::put("avatars/$image_path", $img);
}
if ($image->getClientMimeType() === 'image/svg+xml') {
Storage::putFileAs('avatars', $image, $image_path);
}
// Return path to image
return "avatars/$image_path";
@@ -308,7 +314,7 @@ function store_avatar($request, $name)
*
* @param $request
* @param $name
* @return string
* @return string|null
*/
function store_system_image($request, $name)
{
@@ -505,7 +511,7 @@ function format_date($date, $format = '%d. %B. %Y, %H:%M')
/**
* Get file type from mimetype
*
* @param $file
* @param $file_mimetype
* @return string
*/
function get_file_type($file_mimetype)
@@ -513,25 +519,11 @@ function get_file_type($file_mimetype)
// Get mimetype from file
$mimetype = explode('/', $file_mimetype);
switch ($mimetype[0]) {
case 'image':
return 'image';
break;
case 'video':
return 'video';
break;
case 'audio':
return 'audio';
break;
default:
return 'file';
if (in_array($mimetype[0], ['image', 'video', 'audio'])) {
return $mimetype[0];
}
return 'file';
}
/**
@@ -585,7 +577,7 @@ function get_pretty_name($basename, $name, $mimetype)
* Get exif data from jpeg image
*
* @param $file
* @return array
* @return array|null
*/
function get_image_meta_data($file)
{
@@ -853,10 +845,9 @@ function set_time_by_user_timezone($time)
$user = Auth::user();
if ($user) {
// Get the value of timezone if user have some
$time_zone = intval($user->settings->timezone * 60 ?? null);
return Carbon::parse($time)->addMinutes($time_zone ?? null);
return Carbon::parse($time)->addMinutes($time_zone ?? 0);
}
return Carbon::parse($time);