Created
February 22, 2019 04:47
-
-
Save lawdoc71/f22ab0cfd48a2e8c0d39bc9965e3790d to your computer and use it in GitHub Desktop.
Laravel ImageUp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App; | |
| use QCod\ImageUp\HasImageUploads; | |
| use Illuminate\Database\Eloquent\Model; | |
| class User extends Model { | |
| use HasImageUploads; | |
| // which disk to use for upload, can be override by field options | |
| protected $imagesUploadDisk = 'local'; | |
| // path in disk to use for upload, can be override by field options | |
| protected $imagesUploadPath = 'uploads'; | |
| // auto upload allowed | |
| protected $autoUploadImages = true; | |
| // all the images fields for model | |
| protected static $imageFields = [ | |
| 'avatar' => [ | |
| // width to resize image after upload | |
| 'width' => 200, | |
| // height to resize image after upload | |
| 'height' => 100, | |
| // set true to crop image with the given width/height and you can also pass arr [x,y] coordinate for crop. | |
| 'crop' => true, | |
| // what disk you want to upload, default config('imageup.upload_disk') | |
| 'disk' => 'public', | |
| // a folder path on the above disk, default config('imageup.upload_directory') | |
| 'path' => 'avatars', | |
| // placeholder image if image field is empty | |
| 'placeholder' => '/images/avatar-placeholder.svg', | |
| // validation rules when uploading image | |
| 'rules' => 'image|max:2000', | |
| // override global auto upload setting coming from config('imageup.auto_upload_images') | |
| 'auto_upload' => false, | |
| // if request file is don't have same name, default will be the field name | |
| 'file_input' => 'photo' | |
| ], | |
| 'cover' => [ | |
| //... | |
| ] | |
| ]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment