Skip to content

Use it with laravel media library package #34

Pinned Answered by rahulhaque
allaghi asked this question in Q&A
Discussion options

You must be logged in to vote

I am wondering if is there any a proper way to use it with laravel media library package.

Yes, there is.

// Single file
$model->addMedia(Filepond::field($request->image)->getFile())->usingName('...')->toMediaCollection('...');

// Multiple files
$images = Filepond::field($request->images)->getFile();
foreach ($images as $image) {
    $model->addMedia($image)->usingName('...')->toMediaCollection('...');
}

I recommend using preserveOriginal() if you want the temporary files to be available when used with soft delete enabled.

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@rahulhaque
Comment options

@allaghi
Comment options

@allaghi
Comment options

@allaghi
Comment options

@rahulhaque
Comment options

Answer selected by allaghi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants