Add stock items, groups and movements at a moving average cost
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Inventory\Presentation\Http\Controllers;
|
||||
|
||||
use App\Modules\Inventory\Application\Contracts\StockQueries;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* A stock item's image or its thumbnail from the private disk, to those who
|
||||
* see the stock.
|
||||
*/
|
||||
class ShowStockItemImage
|
||||
{
|
||||
public function __invoke(int $item, string $size, StockQueries $stock): Response
|
||||
{
|
||||
Gate::authorize('inventory.view');
|
||||
|
||||
$path = $stock->imagePathOf($item, $size === 'thumbnail') ?? abort(404);
|
||||
$disk = Storage::disk('local');
|
||||
|
||||
abort_unless($disk->exists($path), 404);
|
||||
|
||||
return $disk->response($path, basename($path), ['Content-Type' => 'image/jpeg', 'Cache-Control' => 'private, max-age=86400']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user