I am consuming the events as discussed in https://docs.spatie.be/laravel-medialibrary/v5/advanced-usage/consuming-events, but what I am trying to achieve is to get the associated parent model that was used to attach this media. Is there an easier way to do this.
Currently, I am doing this on the Event definition.
$model = $event->media->getModel();
$modelInstance = app($model->model_type);
$libraryItemInstance = $libraryItemModel->find($model->model_id);
Here's an easy way to get the model where the media is attached to:
$model = $media->model;
馃憤
Most helpful comment
Here's an easy way to get the model where the media is attached to: