everywell/imagination 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

everywell/imagination

Composer 安装命令:

composer require everywell/imagination

包简介

A Laravel package that allows to handle images on your models seamlessly

README 文档

README

A Laravel package that allows to handle images on your Eloquent models seamlessly.

Installation

To install this package just a few steps are needed

Composer

Pull this package in through Composer using the following command inside your terminal:

composer require everywell/imagination

Service Provider

Add the package to your application service providers in config/app.php file.

'providers' => [
    
    /*
     * Laravel Framework Service Providers...
     */
    Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
    Illuminate\Auth\AuthServiceProvider::class,
    ...
    
    /**
     * Third Party Service Providers...
     */
    EveryWell\Imagination\ImaginationServiceProvider::class,

],

Config File

Publish the package config file to your aplication running the following command inside your terminal:

php artisan vendor:publish --provider="EveryWell\Imagination\ImaginationServiceProvider"

Trait and Contract

Include HasImages trait and also implement HasImages contract inside your model class.

use EveryWell\Imagination\Traits\HasImages;
use EveryWell\Imagination\Contracts\HasImages as HasImagesContract;

class News extends Model implements HasImagesContract
{
    use HasImages;

Images attribute

Add an images array attribute to your model containing the fields that should be handled as images.

use EveryWell\Imagination\Traits\HasImages;
use EveryWell\Imagination\Contracts\HasImages as HasImagesContract;

class News extends Model implements HasImagesContract
{
    use HasImages;
    
    protected $fillable = [
        'title',
        'text',
        'banner',
        'image'
    ];
        
    protected $images = [
        'banner',
        'image' => [
            'discard_original' => true, // Optional: if true, doesn't save the original version of the image
            'dimensions' => [           // Optional: specifies different dimensions than the default config
                [
                    'name' => 'thumb',
                    'width' => 150
                ],
                [
                    'name' => 'small',
                    'width' => 250
                ],
                [
                    'name' => 'regular',
                    'width' => 600
                ]
            ]
        ]
    ];

And that's it!

统计信息

  • 总下载量: 1.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-08-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固