viralsbackpack/backpackimageupload

Manager images in laravel backpack

1.0 2019-09-09 15:29 UTC

This package is auto-updated.

Last update: 2024-05-10 02:29:08 UTC


README

Latest Version on Packagist Total Downloads Build Status StyleCI

This is where your description should go. Take a look at contributing.md to see a to do list.

Installation

Via Composer

$ composer require viralsbackpack/backpackimageupload

Run command:

php artisan vendor:publish --provider="ViralsBackpack\BackPackImageUpload\BackPackImageUploadServiceProvider"

php artisan migrate

Create the symbolic link, run command:

php artisan storage:link

Config

Config package in config/backpackimageupload.php.

Usage

Add trait ViralsBackpack\BackPackImageUpload\Traits\HasImages to model has image, Eg:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Backpack\CRUD\CrudTrait;
use ViralsBackpack\BackPackImageUpload\Traits\HasImages;// <------------------------------- this one

class Tag extends Model
{
    use CrudTrait;
    use HasImages; // <------------------------------- this one

    /*
    |--------------------------------------------------------------------------
    | GLOBAL VARIABLES
    |--------------------------------------------------------------------------
    */

    protected $table = 'tags';
    protected $fillable = ['name'];
}

Add field:

$this->crud->addField([
    'name' => 'images',
    'label' => 'Images',
    'type' => 'virals_browse_image',
]);

Package support upload image and pick uploaded image in server

Function provide:

Initialize the model

$model = Test::find($id);

Get all Image for model

$model->images;

Create Image

$model->createImage($params);

Update Image

$model->updateImage($params);

Delete Image:(delete image file and record)

$model->updateImage($params);

$params: array($link1, $link2) or string url image

Change log

Please see the changelog for more information on what has changed recently.

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

license. Please see the license file for more information.