diff --git a/app/Http/Controllers/DocumentController.php b/app/Http/Controllers/DocumentController.php
index 3227c2a..ae4ab8e 100644
--- a/app/Http/Controllers/DocumentController.php
+++ b/app/Http/Controllers/DocumentController.php
@@ -12,8 +12,12 @@ class DocumentController extends Controller
{
public function show(Document $document)
{
- header('Content-Disposition: filename="' . $document->name . '"');
- return response()->file($document->path);
+ if (file_exists($document->path)) {
+ header('Content-Disposition: filename="' . $document->name . '"');
+ return response()->file($document->path);
+ }
+
+ abort(404);
}
public function store(Request $request, Contract $contract)
@@ -24,7 +28,7 @@ class DocumentController extends Controller
'name' => $file->getClientOriginalName(),
'internal_name' => $internalName,
'size' => $file->getSize(),
- 'extension' => $file->extension(),
+ 'extension' => $file->extension() ?? '',
'contract_id' => $contract->id,
]);
$file->move(public_path("documents/contracts/{$contract->id}/"), $internalName);
diff --git a/app/Models/Document.php b/app/Models/Document.php
index 1543713..9ac6489 100644
--- a/app/Models/Document.php
+++ b/app/Models/Document.php
@@ -30,10 +30,15 @@ class Document extends Model
public function getSizeAttribute($size)
{
- if ($size / 1024 / 1024 < 1) {
- return (string)floor($size / 1024) . " KB";
+ if ($size / 1024 < 1) {
+ return $size . " B";
}
- return (string)floor($size / 1024 / 1024) . " MB";
+
+ if ($size / 1024 / 1024 < 1) {
+ return floor($size / 1024) . " KB";
+ }
+
+ return floor($size / 1024 / 1024) . " MB";
}
public function getLinkAttribute()
diff --git a/public/js/app.js b/public/js/app.js
index 2af4e95..01f545a 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -23120,7 +23120,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
var _hoisted_1 = {
- "class": "grid grid-cols-12 gap-12 w-full mb-10"
+ "class": "grid grid-cols-12 gap-12 w-full mb-8"
};
var _hoisted_2 = {
"class": "col-span-6 xs:col-span-12"
@@ -29436,12 +29436,13 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
, ["document"]);
}), 128
/* KEYED_FRAGMENT */
- )), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_document_upload, {
+ )), !$props.contract.deleted_at ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)(_component_document_upload, {
+ key: 0,
contract: $props.contract,
documents: $data.documents
}, null, 8
/* PROPS */
- , ["contract", "documents"])])]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_14, [_hoisted_15, (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_car_card, {
+ , ["contract", "documents"])) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true)])]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_14, [_hoisted_15, (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_car_card, {
car: $props.contract.car
}, null, 8
/* PROPS */
diff --git a/resources/js/Components/ShowPage.vue b/resources/js/Components/ShowPage.vue
index 70a732f..f786609 100644
--- a/resources/js/Components/ShowPage.vue
+++ b/resources/js/Components/ShowPage.vue
@@ -3,7 +3,7 @@