Closed jacob418 closed 2 years ago
@jacob418 UUID as PK is not supported
That's sad because this way we can not use this package at all, I was really looking forward to use it.
Hi.
You can easily solve this issue by replacing the MedialibraryRequest
class in the container.
Create a request class
php artisan make:request MediaLibraryRequest
Extend the original class and overwrite the resourceExists
method
<?php
namespace App\Http\Requests;
class MediaLibraryRequest extends \DmitryBubyakin\NovaMedialibraryField\Http\Requests\MedialibraryRequest
{
public function resourceExists(): bool
{
return $this->route('resourceId') !== 'undefined';
}
}
Replace the class in the container in your AppServiceProvider
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->bind(MedialibraryRequest::class, \App\Http\Requests\MediaLibraryRequest::class);
}
}
@zsoltgyure ty for the tip, I hope i get to try it out some day.
In my project I'm using UUID for the primary keys of models, therefore I had to change the
media
table to useuuidMorphs
instead of normalmorphs
.\DmitryBubyakin\NovaMedialibraryField\Http\Requests\MedialibraryRequest::resourceExists
checks weather a model exists by testing weather the paramresourceId
is numeric. Since UUID's are not numeric\DmitryBubyakin\NovaMedialibraryField\TransientModel
comes into use. However this model has a numeric key, so it will cause an exception[...] invalid input syntax for type uuid: "1" (SQL: select * from "media" where "media"."model_id" = 1 and "media"."model_id" is not null and "media"."model_type" = DmitryBubyakin\NovaMedialibraryField\TransientModel)
.Is there any way to get this package to work with UUID's?