Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieving media of a model in Laravel Nova from another Laravel application #405

Open
pkollarova opened this issue Jul 20, 2023 · 0 comments

Comments

@pkollarova
Copy link

I have 2 Laravel apps - One that allows users to upload images to their profile and one that is used just as an admin panel (using Nova). Both admin and user app use the same database but they are on different websites/domains. Also both apps are on the same VPS.

Is it possible to retrieve images in the UserResource in the admin app from the user app?

I've tried approach like this but no luck:

In UserResource

Images::make('Documents', 'documents')
                        ->conversionOnIndexView('thumb')
                        ->fullSize()->enableExistingMedia(),

In User model

public function registerMediaCollections() : void {
        $this->addMediaCollection('document')
            ->useDisk('media');
    }

public function documents() {
        return $this->hasMany(Media::class, 'model_id')
            ->where('collection_name', 'document');
    }

In filesystem config

'media' => [
            'driver' => 'local',
            'root'   => parent_public_path('img/documents'),
            'url'    => env('PARENT_APP_URL').'/img/documents',
            'visibility' => 'public',
        ],

Function parent_public_path

function parent_public_path($path = '')
    {
        return '/var/www/userapp.myapp.com/public_html/public'.($path ? DIRECTORY_SEPARATOR.ltrim($path, DIRECTORY_SEPARATOR) : $path);
    }

PARENT_APP_URL equals https://userapp.myapp.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant