cleanup
parent
6c9ca89c3c
commit
3fd32b23e5
|
|
@ -12,10 +12,14 @@ class DocumentController extends Controller
|
||||||
{
|
{
|
||||||
public function show(Document $document)
|
public function show(Document $document)
|
||||||
{
|
{
|
||||||
|
if (file_exists($document->path)) {
|
||||||
header('Content-Disposition: filename="' . $document->name . '"');
|
header('Content-Disposition: filename="' . $document->name . '"');
|
||||||
return response()->file($document->path);
|
return response()->file($document->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
public function store(Request $request, Contract $contract)
|
public function store(Request $request, Contract $contract)
|
||||||
{
|
{
|
||||||
$file = $request->file()['document'];
|
$file = $request->file()['document'];
|
||||||
|
|
@ -24,7 +28,7 @@ class DocumentController extends Controller
|
||||||
'name' => $file->getClientOriginalName(),
|
'name' => $file->getClientOriginalName(),
|
||||||
'internal_name' => $internalName,
|
'internal_name' => $internalName,
|
||||||
'size' => $file->getSize(),
|
'size' => $file->getSize(),
|
||||||
'extension' => $file->extension(),
|
'extension' => $file->extension() ?? '',
|
||||||
'contract_id' => $contract->id,
|
'contract_id' => $contract->id,
|
||||||
]);
|
]);
|
||||||
$file->move(public_path("documents/contracts/{$contract->id}/"), $internalName);
|
$file->move(public_path("documents/contracts/{$contract->id}/"), $internalName);
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,15 @@ class Document extends Model
|
||||||
|
|
||||||
public function getSizeAttribute($size)
|
public function getSizeAttribute($size)
|
||||||
{
|
{
|
||||||
if ($size / 1024 / 1024 < 1) {
|
if ($size / 1024 < 1) {
|
||||||
return (string)floor($size / 1024) . " KB";
|
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()
|
public function getLinkAttribute()
|
||||||
|
|
|
||||||
|
|
@ -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");
|
/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.esm-bundler.js");
|
||||||
|
|
||||||
var _hoisted_1 = {
|
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 = {
|
var _hoisted_2 = {
|
||||||
"class": "col-span-6 xs:col-span-12"
|
"class": "col-span-6 xs:col-span-12"
|
||||||
|
|
@ -29436,12 +29436,13 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||||
, ["document"]);
|
, ["document"]);
|
||||||
}), 128
|
}), 128
|
||||||
/* KEYED_FRAGMENT */
|
/* 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,
|
contract: $props.contract,
|
||||||
documents: $data.documents
|
documents: $data.documents
|
||||||
}, null, 8
|
}, null, 8
|
||||||
/* PROPS */
|
/* 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
|
car: $props.contract.car
|
||||||
}, null, 8
|
}, null, 8
|
||||||
/* PROPS */
|
/* PROPS */
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<template #header>
|
<template #header>
|
||||||
<slot name="header"></slot>
|
<slot name="header"></slot>
|
||||||
</template>
|
</template>
|
||||||
<div class="grid grid-cols-12 gap-12 w-full mb-10">
|
<div class="grid grid-cols-12 gap-12 w-full mb-8">
|
||||||
<div class="col-span-6 xs:col-span-12">
|
<div class="col-span-6 xs:col-span-12">
|
||||||
<slot name="info"></slot>
|
<slot name="info"></slot>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
<template v-for="document in documents" :key="document.id">
|
<template v-for="document in documents" :key="document.id">
|
||||||
<document-item :document="document" />
|
<document-item :document="document" />
|
||||||
</template>
|
</template>
|
||||||
<document-upload :contract="contract" :documents="documents" />
|
<document-upload v-if="!contract.deleted_at" :contract="contract" :documents="documents" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-span-6 xs:col-span-12">
|
<div class="col-span-6 xs:col-span-12">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue