spatie/laravel-medialibrary
This is an external open-source GitHub repository imported into the WOCSOL Marketplace for discovery. The original repository owner is the primary creator.
Repository Details
Repository Description
Associate files with Eloquent models
Associate files with Eloquent models
<div align="left"> <a href="https://spatie.be/open-source?utm_source=github&utm_medium=banner&utm_campaign=laravel-medialibrary"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://spatie.be/packages/header/laravel-medialibrary/html/dark.webp"> <img alt="Logo for laravel-medialibrary" src="https://spatie.be/packages/header/laravel-medialibrary/html/light.webp"> </picture> </a> <h1>Associate files with Eloquent models</h1> [](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) </div> 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
Related Repositories
Product Discussion
Ask questions or discuss this product. New comments are reviewed before publishing.
Loading comments...