Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 6 |
| PurchaseOrderController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 6 |
| download | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 6 |
|||
| 1 | <?php |
| 2 | |
| 3 | namespace Qmp\Laravel\ApiGateway\Controllers\PurchaseOrder; |
| 4 | |
| 5 | use Illuminate\Http\Response; |
| 6 | use Illuminate\Support\Facades\Storage; |
| 7 | use Illuminate\Http\Request; |
| 8 | use Illuminate\Support\Facades\Log; |
| 9 | use Qmp\Laravel\ApiGateway\Controllers\AbstractApiController; |
| 10 | |
| 11 | class PurchaseOrderController extends AbstractApiController |
| 12 | { |
| 13 | const STORAGE_DISK = 'temp'; |
| 14 | |
| 15 | protected $serviceName = 'service_purchase_order'; |
| 16 | |
| 17 | protected $resourceName = 'purchase-order'; |
| 18 | |
| 19 | protected $methodsWithoutJsonMiddleware = ['download']; |
| 20 | |
| 21 | public function download(Request $request, $id) |
| 22 | { |
| 23 | $response = $this->getResponseFromService( |
| 24 | $this->serviceName, |
| 25 | "{$this->resourceName}/$id/download" |
| 26 | ); |
| 27 | |
| 28 | if (isset($response->content['path'])) { |
| 29 | return $this->fileResponse($response->content['path']); |
| 30 | } else { |
| 31 | return $this->response(['error' => 'Unauthorized'], 422); |
| 32 | } |
| 33 | |
| 34 | |
| 35 | } |
| 36 | } |