This is an external open-source GitHub repository imported into the WOCSOL Marketplace for discovery. The original repository owner is the primary creator.
Associate files with Eloquent models
Associate files with Eloquent models
Associate files with Eloquent models [](https://github.com/spatie/laravel-medialibrary/releases) [](https://github.com/spatie/laravel-medialibrary/actions/workflows/run-tests.yml) [](https://packagist.org/packages/spatie/laravel-medialibrary) This package can associate all sorts of files with Eloquent models. It provides a simple API to work with. To learn all about it, head over to [the extensive documentation](https://spatie.be/docs/laravel-medialibrary). Here are a few short examples of what you can do: ```php $newsItem = News::find(1); $newsItem->addMedia($pathToFile)->toMediaCollection('images'); ``` It can handle your uploads directly: ```php $newsItem->addMedia($request->file('image'))->toMediaCollection('images'); ``` Want to store some large files on another filesystem? No problem: ```php $newsItem->addMedia($smallFile)->toMediaCollection('downloads', 'local'); $newsItem->addMedia($bigFile)->toMediaCollection('downloads', 's3'); ``` The storage of the files is handled by [Laravel's Filesystem](https://laravel.com/docs/filesystem), so you can use any filesystem you like. Additionally, the package can create image manipulations on images and pdfs that have been added in the media library. Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource). ## Support us [ ](https://spatie.be/github-ad-click/laravel-medialibrary) We invest a lot of resources
Ask questions or discuss this product. New comments are reviewed before publishing.
Loading comments...