cipemotion/medialibrary

一个Laravel媒体库。

2.1.0 2022-02-16 14:08 UTC

README

一个使您能够轻松实现自己的WordPress风格媒体选择器组件的媒体库包。

此包依赖于 intervention/image

配置

app.php 中的提供者数组中添加服务提供者。

CipeMotion\Medialibrary\ServiceProvider::class,
Intervention\Image\ImageServiceProvider::class

可选:将 intervention/image Facade 添加到 app.php 中的别名数组。

'Image' => Intervention\Image\Facades\Image::class,

发布配置文件

php artisan vendor:publish --provider="CipeMotion\Medialibrary\ServiceProvider" --tag="config"

阅读配置文件并更改所需的内容。

数据库

发布迁移文件

php artisan vendor:publish --provider="CipeMotion\Medialibrary\ServiceProvider" --tag="migrations"

运行迁移

php artisan migrate

关系

在您的所有者模型上添加

public function files()
{
    return $this->hasMany(\CipeMotion\Medialibrary\Entities\File::class, 'owner_id');
}

在您的模型上添加

public function attachebles()
{
    return $this->morphToMany(\CipeMotion\Medialibrary\Entities\File::class, 'attachable', 'medialibrary_attachable');
}