skygdi / product-image
此包的最新版本(dev-master)没有提供许可信息。
产品图片
dev-master
2018-05-24 15:40 UTC
Requires
- spatie/laravel-medialibrary: ^7.0.0
This package is not auto-updated.
Last update: 2024-09-29 06:02:31 UTC
README
快速产品图片类(产品ID,名称和描述),基于Spatie\MediaLibrary for Laravel
1.安装
composer require skygdi/product-image
2.公开迁移文件
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" php artisan vendor:publish --provider="skygdi\ProductImage\ProductImageProvider"
3.迁移
php artisan migrate
在点击PayPal结账按钮之前,根据您的逻辑更改#order_id输入和#order_total值。
4.使用方法
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.测试:快速测试URL:yourUrl/skygdi/pi/test,或者您也可以自己编写。
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()."'/>"; });