refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s

This commit is contained in:
Kroonk
2026-05-22 16:19:55 +02:00
parent 38cc4c09ca
commit a213a1dba0
2215 changed files with 242567 additions and 6015 deletions

View File

@@ -0,0 +1,60 @@
<?php
namespace App\Helpers;
use App\Models\Account\Account;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\Filesystem\FilesystemAdapter;
class StorageHelper
{
/**
* Get a filesystem instance.
*
* @param string $name
* @return \Illuminate\Filesystem\FilesystemAdapter
*/
public static function disk($name = null): FilesystemAdapter
{
/** @var \Illuminate\Filesystem\FilesystemAdapter */
$disk = Storage::disk($name);
return $disk;
}
/**
* Get the storage size of the account, in bytes.
*
* @param Account $account
* @return int
*/
public static function getAccountStorageSize(Account $account): int
{
$documentsSize = DB::table('documents')
->where('account_id', $account->id)
->sum('filesize');
$photosSize = DB::table('photos')
->where('account_id', $account->id)
->sum('filesize');
return $documentsSize + $photosSize;
}
/**
* Indicates whether the account has the reached the maximum storage size.
*
* @param Account $account
* @return bool
*/
public static function hasReachedAccountStorageLimit(Account $account): bool
{
if (! config('monica.requires_subscription')) {
return false;
}
$currentAccountSize = self::getAccountStorageSize($account);
return $currentAccountSize > (config('monica.max_storage_size') * 1000000);
}
}