Customize Media Path Generation
5.xCurator uses Path Generators to determine where files are stored. You can set these globally in the config or per instance on a CuratorPicker field.
Built-in Generators:
DefaultPathGenerator: Saves indisk/directory.DatePathGenerator: Saves indisk/directory/Y/m/d.UserPathGenerator: Saves indisk/directory/user-auth-identifier.
Custom Generator:
Implement the PathGenerator interface to create your own logic.
use Awcodes\Curator\PathGenerators\DatePathGenerator;
use Awcodes\Curator\PathGenerators; // For interface
// Per instance
CuratorPicker::make('image')->pathGenerator(DatePathGenerator::class);
// Custom implementation
class CustomPathGenerator implements PathGenerator
{
public function getPath(?string $baseDir = null): string
{
return ($baseDir ? $baseDir . '/' : '') . 'my/custom/path';
}
}