Skip to content

Commit

Permalink
add version 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Moamen Eltouny committed May 28, 2021
1 parent 36f10fc commit 39d776e
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2020 Pharaonic. https://pharaonic.io
Copyright (c) 2021 Pharaonic. https://pharaonic.io

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ $ php artisan migrate
// Using HasImages in Article Model
...
use Pharaonic\Laravel\Images\HasImages;
use Pharaonic\Laravel\Helpers\Traits\HasCustomAttributes;


class Article extends Model
{
Expand Down
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
"name": "pharaonic/laravel-has-images",
"description": "Laravel - Model's Multi Images",
"keywords": [
"php",
"laravel",
"has images",
"laravel images",
"laravel files",
"php images",
"php files",
"images",
"pharaonic"
"laravel",
"php"
],
"license": "MIT",
"authors": [
{
"name": "Raggi",
"email": "support@pharaonic.io",
"homepage": "https://pharaonic.io"
"name": "Moamen Eltouny (Raggi)",
"email": "raggi@raggitech.com"
}
],
"require": {
Expand Down
9 changes: 5 additions & 4 deletions src/HasImages.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@

use Exception;
use Illuminate\Http\UploadedFile;
use Pharaonic\Laravel\Helpers\Traits\HasCustomAttributes;

/**
* Has Images Trait
*
* @version 1.0
* @author Raggi <support@pharaonic.io>
* @license http://opensource.org/licenses/mit-license.php MIT License
* @version 2.0
* @author Moamen Eltouny (Raggi) <raggi@raggitech.com>
*/
trait HasImages
{
use HasCustomAttributes;

/**
* Images Atrributes on Save/Create
*
* @var array
*/
protected static $imagesItems = [];


/**
* @return void
*/
Expand Down
15 changes: 12 additions & 3 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
/**
* Image Model
*
* @version 1.0
* @author Raggi <support@pharaonic.io>
* @license http://opensource.org/licenses/mit-license.php MIT License
* @version 2.0
* @author Moamen Eltouny (Raggi) <raggi@raggitech.com>
*/
class Image extends Model
{
Expand Down Expand Up @@ -39,6 +38,16 @@ public function getUrlAttribute()
return $this->file->url;
}

/**
* Get Thumbnail
*
* @return string
*/
public function getThumbnailAttribute()
{
return $this->file->thumbnail ?? null;
}

/**
* Set Sort Index
*/
Expand Down
8 changes: 3 additions & 5 deletions src/ImagesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class ImagesServiceProvider extends ServiceProvider
*/
public function register()
{
//
// Migrations Loading
$this->loadMigrationsFrom(__DIR__ . '/database/migrations');
}

/**
Expand All @@ -26,10 +27,7 @@ public function boot()
{
// Publishes
$this->publishes([
__DIR__ . '/database/migrations/images.stub' => database_path(sprintf('migrations/%s_create_images_table.php', date('Y_m_d_His', time() + 3))),
__DIR__ . '/database/migrations/2021_02_01_000004_create_images_table.php' => database_path('migrations/2021_02_01_000004_create_images_table.php'),
], ['pharaonic', 'laravel-has-images']);

// Loads
$this->loadMigrationsFrom(__DIR__ . '/database/migrations');
}
}
File renamed without changes.

0 comments on commit 39d776e

Please sign in to comment.