Skip to content

Quick Product Image class (product id , name and description) base on Spatie\MediaLibrary for Laravel

Notifications You must be signed in to change notification settings

skygdi/ProductImage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Quick Product Image class (product id , name and description) base on Spatie\MediaLibrary for Laravel

1.Install:

composer require skygdi/product-image

2.Public migration files:

php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider"
php artisan vendor:publish --provider="skygdi\ProductImage\ProductImageProvider"

3.Migrate

php artisan migrate

Change the #order_id input and #order_total value as your logic needed before clicking the paypal checkout button.

4.Usage:

use skygdi\ProductImage\model\ProductImage as ProductImage;
//In relation model define:
return $this->hasMany('skygdi\ProductImage\model\ProductImage','product_id');

//create
ProductImage::create([
  "product_id"    =>  1,
  "description"   =>  "description",
  "sort_index"    =>  1
]);

//Update or add an image:
ProductImage::find(1)->UploadImage($request->file('new_image'));

//Delete (include image if exist)
ProductImage::find(1)->delete();

//Retrieve image URL
ProductImage::find(1)->ImageUrl();

5.Testing: The fast test URL: yourUrl/skygdi/pi/test, or you could write on your own.

Route::get('/', function () {
    //Creating
    ProductImage::create([
        "product_id"    =>  1,
        "description"   =>  "description",
        "sort_index"    =>  1
    ]);
    */

    $pi = ProductImage::find(1);
    //$pi->UploadImage( storage_path('app/file.jpg') ); //From local file
    //$pi->UploadImage( $request->file('new_image') );  //From upload form
    //$pi->UploadImageFromUrl("https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png");    //From Internet
    echo "<img src='".url('/').$pi->ImageUrl()."'/>";
});

About

Quick Product Image class (product id , name and description) base on Spatie\MediaLibrary for Laravel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages