Files
InvoiceShelf/app/Support/Media/CustomPathGenerator.php
Darko Gjorgjijoski 4c3d809f89 refactor(support): group Bouncer, Media, Setup files into subdirs
Finishes the Support/ consolidation pass: the three remaining root-level files get grouped into purpose-named subdirs, matching the shape the Pdf/, Hashids/, Update/, and Module/ subdirs took in the earlier sweep.

- BouncerDefaultScope → Support/Bouncer/ (Bouncer-specific authorization scope)

- CustomPathGenerator → Support/Media/ (Spatie MediaLibrary path generator — media config references it from config/media-library.php)

- InstallWizardAuth → Support/Setup/ (folded into the existing Setup/ subdir alongside EnvironmentManager, FilePermissionChecker, InstallUtils, RequirementsChecker — it's install-wizard-flow state)

4 consumer files updated (AppServiceProvider, LoginController, UseInstallWizardTokenAuth middleware, config/media-library.php). app/Support/ root is now completely empty of standalone PHP files except helpers.php.
2026-04-11 15:00:00 +02:00

48 lines
1.2 KiB
PHP

<?php
namespace App\Support\Media;
use App\Models\Estimate;
use App\Models\Invoice;
use App\Models\Payment;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
use Spatie\MediaLibrary\Support\PathGenerator\PathGenerator;
class CustomPathGenerator implements PathGenerator
{
public function getPath(Media $media): string
{
return $this->getBasePath($media).'/';
}
public function getPathForConversions(Media $media): string
{
return $this->getBasePath($media).'/conversations/';
}
public function getPathForResponsiveImages(Media $media): string
{
return $this->getBasePath($media).'/responsive-images/';
}
/*
* Get a unique base path for the given media.
*/
protected function getBasePath(Media $media): string
{
$folderName = null;
if ($media->model_type == Invoice::class) {
$folderName = 'Invoices';
} elseif ($media->model_type == Estimate::class) {
$folderName = 'Estimates';
} elseif ($media->model_type == Payment::class) {
$folderName = 'Payments';
} else {
$folderName = $media->getKey();
}
return $folderName;
}
}