faber44 / open-admin-media-library
Media-library extension for Laravel Open-Admin
0.0.3
2023-12-29 19:40 UTC
Requires
- php: ^8.1
- open-admin-org/open-admin: ^1.0
- spatie/laravel-medialibrary: ^11.0.0
Requires (Dev)
- phpunit/phpunit: ^10.1
This package is auto-updated.
Last update: 2025-03-29 01:08:00 UTC
README
Install
composer require Faber44/open-admin-media-library
Usage
protected function form() { $form = new Form(new MyModel); // Single media $form->mediaLibrary('image', 'Image') ->responsive() ->removable(); // Multiple media field $form->multipleMediaLibrary('photos', 'Photos') ->responsive() ->removable(); return $form; }
Note: you have to add setPhotosAttribute and setImageAttribute methods to your model:
class MyModel extends Model implements HasMedia { use InteractsWithMedia; public function setPhotosAttribute() { // you can leave it empty } public function setImageAttribute() { } }
Thanks to nicklasos/laravel-admin-media-library.
Thanks to luischavez/laravel-admin-media-library for code samples.