24/05
2018
dev-master
9999999-devproduct image
The Requires
by Peter
product image
1.Install:, (*1)
composer require skygdi/product-image
2.Public migration files:, (*2)
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" php artisan vendor:publish --provider="skygdi\ProductImage\ProductImageProvider"
3.Migrate, (*3)
php artisan migrate
Change the #order_id input and #order_total value as your logic needed before clicking the paypal checkout button., (*4)
4.Usage:, (*5)
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., (*6)
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()."'/>"; });
product image