laravel-medialibrary: Return value of Spatie\MediaLibrary\PathGenerator\BasePathGenerator::getBasePath() must be of the type string, null returned
Getting an error in Laravel 6.2
Symfony\Component\Debug\Exception\FatalThrowableError
Return value of Spatie\MediaLibrary\PathGenerator\BasePathGenerator::getBasePath() must be of the type string, null returned
vendor/spatie/laravel-medialibrary/src/PathGenerator/BasePathGenerator.php:39
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 5
- Comments: 21 (5 by maintainers)
I had this error and it occurred because I didn’t save the model first
$model->save()
before creating media to attach and calling$media->getUrl()
So check to make sure you save the model first and it exists in the database if you are calling that method.
This issue was again introduced in version 9.8.3
@vlados if you already know a solution, feel free to PR the fix + tests to make sure the bug isn’t introduced again.