I have the problem to make friends Spatie medialibrary with Voyager. When adding Bread to this table, there is a field called Model Name. If I fill it with model that implements HasMedia, the Bread has created successfully. But when browse 'media' table - this table is empty. If i fill field Model Name with any anothor value, there is error - such class doesnt exist.
Table does have fields, I can see it with php-my-admin
Update: I have added to my model code as it described in documentation https://docs.spatie.be/laravel-medialibrary/v7/basic-usage/preparing-your-model
namespace App;
use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
use Spatie\MediaLibrary\HasMedia\Interfaces\HasMedia;
class Game extends Model implements HasMedia
{
use HasMediaTrait;
...
}
adjust my model controller, so i can add image
public function store(Request $request)
{
$newGame = new Game;
$newGame->name = $request->game_name;
$newGame->addMediaFromRequest('game_shortcut')->toMediaCollection('shortcut'); // изображение
$newGame->save();
...
}
Now I have uploaded image-file in my filesystem, and image entry in spatie 'media' table related to Game object. http://joxi.ru/Vrwn5pbCKyWJgA
The problem is that I cant view 'media' table in Voyager, because I can not create BREAD properly
Update: if create BREAD without filling Model field, then it fails with
Symfony \ Component \ HttpKernel \ Exception \ AccessDeniedHttpException
This action is unauthorized
error when browsing the table