Merge pull request #1121 from rahulshukla-webkul/development

Development
This commit is contained in:
Jitendra Singh 2019-06-27 14:43:31 +05:30 committed by GitHub
commit 561a2a763f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 61 additions and 7 deletions

View File

@ -244,6 +244,10 @@ Route::group(['middleware' => ['web']], function () {
'view' => 'admin::catalog.products.edit'
])->name('admin.catalog.products.productlinksearch');
Route::get('/products/{id}/{attribute_id}', 'Webkul\Product\Http\Controllers\ProductController@download')->defaults('_config', [
'view' => 'admin.catalog.products.edit'
])->name('admin.catalog.products.file.download');
// Catalog Category Routes
Route::get('/categories', 'Webkul\Category\Http\Controllers\CategoryController@index')->defaults('_config', [
'view' => 'admin::catalog.categories.index'

View File

@ -1,5 +1,5 @@
@if ($product[$attribute->code])
<a href="{{ Storage::url($product[$attribute->code]) }}" target="_blank">
<a href="{{ route('admin.catalog.products.file.download', [$product->product_id, $attribute->id] )}}">
<i class="icon sort-down-icon download"></i>
</a>
@endif

View File

@ -1,5 +1,5 @@
@if ($product[$attribute->code])
<a href="{{ Storage::url($product[$attribute->code]) }}" target="_blank">
<a href="{{ route('admin.catalog.products.file.download', [$product->product_id, $attribute->id] )}}">
<img src="{{ Storage::url($product[$attribute->code]) }}" class="configuration-image"/>
</a>
@endif

View File

@ -26,6 +26,7 @@ class View extends AbstractProduct
}
$data[] = [
'id' => $attribute->id,
'code' => $attribute->code,
'label' => $attribute->name,
'value' => $value,

View File

@ -11,6 +11,7 @@ use Webkul\Product\Repositories\ProductAttributeValueRepository as ProductAttrib
use Webkul\Attribute\Repositories\AttributeFamilyRepository as AttributeFamily;
use Webkul\Category\Repositories\CategoryRepository as Category;
use Webkul\Inventory\Repositories\InventorySourceRepository as InventorySource;
use Illuminate\Support\Facades\Storage;
/**
* Product controller
@ -294,4 +295,20 @@ class ProductController extends Controller
return view($this->_config['view']);
}
}
/**
* Download image or file
*
* @param int $productId, $attributeId
* @return \Illuminate\Http\Response
*/
public function download($productId, $attributeId)
{
$productAttribute = $this->productAttributeValue->findOneWhere([
'product_id' => $productId,
'attribute_id' => $attributeId
]);
return Storage::download($productAttribute['text_value']);
}
}

View File

@ -5,6 +5,8 @@ namespace Webkul\Shop\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Webkul\Product\Repositories\ProductRepository as Product;
use Webkul\Product\Repositories\ProductAttributeValueRepository as ProductAttributeValue;
use Illuminate\Support\Facades\Storage;
/**
* Product controller
@ -29,16 +31,26 @@ class ProductController extends Controller
*/
protected $product;
/**
* ProductAttributeValueRepository object
*
* @var array
*/
protected $productAttributeValue;
/**
* Create a new controller instance.
*
* @param \Webkul\Product\Repositories\ProductRepository $product
* @param \Webkul\Product\Repositories\ProductRepository $product
* @param \Webkul\Product\Repositories\ProductAttributeValue $productAttributeValue
* @return void
*/
public function __construct( Product $product)
public function __construct(Product $product, ProductAttributeValue $productAttributeValue)
{
$this->product = $product;
$this->productAttributeValue = $productAttributeValue;
$this->_config = request('_config');
}
@ -56,4 +68,20 @@ class ProductController extends Controller
return view($this->_config['view'], compact('product','customer'));
}
/**
* Download image or file
*
* @param int $productId, $attributeId
* @return \Illuminate\Http\Response
*/
public function download($productId, $attributeId)
{
$productAttribute = $this->productAttributeValue->findOneWhere([
'product_id' => $productId,
'attribute_id' => $attributeId
]);
return Storage::download($productAttribute['text_value']);
}
}

View File

@ -115,6 +115,11 @@ Route::group(['middleware' => ['web', 'locale', 'theme', 'currency']], function
'redirect' => 'shop.home.index'
])->name('shop.reviews.store');
// Download file or image
Route::get('/product/{id}/{attribute_id}', 'Webkul\Shop\Http\Controllers\ProductController@download')->defaults('_config', [
'view' => 'shop.products.index'
])->name('shop.product.file.download');
//customer routes starts here
Route::prefix('customer')->group(function () {
// forgot Password Routes

View File

@ -21,13 +21,13 @@
@endif
@if ($attribute['type'] == 'file' && $attribute['value'])
<td>
<a href="{{ Storage::url($attribute['value']) }}" target="_blank">
<a href="{{ route('shop.product.file.download', [$product->product_id, $attribute['id']])}}">
<i class="icon sort-down-icon download"></i>
</a>
</td>
@elseif ($attribute['type'] == 'image' && $attribute['value'])
<td>
<a href="{{ Storage::url($attribute['value']) }}" target="_blank">
<a href="{{ route('shop.product.file.download', [$product->product_id, $attribute['id']])}}">
<img src="{{ Storage::url($attribute['value']) }}" style="height: 20px; width: 20px;"/>
</a>
</td>
@ -35,7 +35,6 @@
<td>{{ $attribute['value'] }}</td>
@endif
</tr>
@endforeach
</table>