Private Disk Added
This commit is contained in:
parent
20cd22fd1b
commit
da7cb3a16b
|
|
@ -48,6 +48,12 @@ return [
|
|||
'root' => storage_path('app'),
|
||||
],
|
||||
|
||||
'private' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/private'),
|
||||
'url' => env('APP_URL') . '/storage',
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
|
|
|
|||
|
|
@ -3,22 +3,24 @@
|
|||
namespace Webkul\Product\Repositories;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
use Illuminate\Support\Str;
|
||||
use Webkul\Core\Eloquent\Repository;
|
||||
|
||||
class ProductDownloadableLinkRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* Specify Model class name
|
||||
* Specify model class name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function model()
|
||||
public function model()
|
||||
{
|
||||
return 'Webkul\Product\Contracts\ProductDownloadableLink';
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload.
|
||||
*
|
||||
* @param array $data
|
||||
* @param integer $productId
|
||||
* @return array
|
||||
|
|
@ -28,7 +30,7 @@ class ProductDownloadableLinkRepository extends Repository
|
|||
foreach ($data as $type => $file) {
|
||||
if (request()->hasFile($type)) {
|
||||
return [
|
||||
$type => $path = request()->file($type)->store('product_downloadable_links/' . $productId),
|
||||
$type => $path = request()->file($type)->store('product_downloadable_links/' . $productId, 'private'),
|
||||
$type . '_name' => $file->getClientOriginalName(),
|
||||
$type . '_url' => Storage::url($path),
|
||||
];
|
||||
|
|
@ -39,8 +41,10 @@ class ProductDownloadableLinkRepository extends Repository
|
|||
}
|
||||
|
||||
/**
|
||||
* Save links.
|
||||
*
|
||||
* @param array $data
|
||||
* @param \Webkul\Product\Contracts\Product $product
|
||||
* @param \Webkul\Product\Models\Product $product
|
||||
* @return void
|
||||
*/
|
||||
public function saveLinks(array $data, $product)
|
||||
|
|
@ -67,4 +71,4 @@ class ProductDownloadableLinkRepository extends Repository
|
|||
$this->delete($linkId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,11 @@ class DownloadableProductController extends Controller
|
|||
}
|
||||
|
||||
if ($downloadableLinkPurchased->type == 'file') {
|
||||
return Storage::download($downloadableLinkPurchased->file);
|
||||
$privateDisk = Storage::disk('private');
|
||||
|
||||
return $privateDisk->exists($downloadableLinkPurchased->file)
|
||||
? $privateDisk->download($downloadableLinkPurchased->file)
|
||||
: abort(404);
|
||||
} else {
|
||||
$fileName = $name = substr($downloadableLinkPurchased->url, strrpos($downloadableLinkPurchased->url, '/') + 1);;
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,11 @@ class ProductController extends Controller
|
|||
$productDownloadableLink = $this->productDownloadableLinkRepository->findOrFail(request('id'));
|
||||
|
||||
if ($productDownloadableLink->sample_type == 'file') {
|
||||
return Storage::download($productDownloadableLink->sample_file);
|
||||
$privateDisk = Storage::disk('private');
|
||||
|
||||
return $privateDisk->exists($productDownloadableLink->sample_file)
|
||||
? $privateDisk->download($productDownloadableLink->sample_file)
|
||||
: abort(404);
|
||||
} else {
|
||||
$fileName = $name = substr($productDownloadableLink->sample_url, strrpos($productDownloadableLink->sample_url, '/') + 1);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue