larabra/laravel-media-library-input
Composer 安装命令:
composer require larabra/laravel-media-library-input
包简介
HTML input for Spatie Media Library
README 文档
README
This is where your description should go. Take a look at contributing.md to see a to do list.
Installation
Via Composer
$ composer require larabra/laravel-media-library-input
Usage
Model
// app\Model\News.php namespace App\Models; use Illuminate\Database\Eloquent\Model as Model; use Larabra\LaravelMediaLibraryInput\Casts\MediaCastAttribute; // <--- use Larabra\LaravelMediaLibraryInput\Models\MediableModel; // <--- use Spatie\MediaLibrary\HasMedia; class News extends Model implements HasMedia { use InteractsWithMedia; use MediableModel; // <--- create/add medias with form submit // "cover" is a fake field, so add it as append and create its cast protected $appends = [ 'cover', ]; protected $casts = [ 'cover' => MediaCastAttribute::class, ]; // ... }
Controller
// app\Http\Controllers\NewsController.php <?php namespace App\Http\Controllers; use App\Repositories\NewsRepository; use Larabra\LaravelMediaLibraryInput\Http\Controllers\MediableController; class NewsController extends AppBaseController { use MediableController; // <--- add controller methods to manager medias /** @var NewsRepository */ private $newsRepositorysitory; public function __construct(NewsRepository $newsRepository) { $this->newsRepository = $newsRepository; }
Views
{!! Form::label('cover', 'Capas:') !!} {!! Form::medias('cover', ['multiple' => true]) !!}
Change log
Please see the changelog for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email author email instead of using the issue tracker.
Credits
License
MIT. Please see the license file for more information.
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-19