code cleanup

shift-build-2464
Nadim Salloum 2021-06-14 13:34:06 +03:00
parent bcb383b3b2
commit 34b6c23ab2
13 changed files with 91 additions and 172 deletions

View File

@ -148,6 +148,7 @@ class ContactController extends Controller
'lastname' => $contact->lastname, 'lastname' => $contact->lastname,
'company' => $contact->company, 'company' => $contact->company,
'title' => $contact->title, 'title' => $contact->title,
'name' => $contact->name,
'email' => $contact->email, 'email' => $contact->email,
'notes' => $contact->notes, 'notes' => $contact->notes,
'phone' => $contact->phone, 'phone' => $contact->phone,

View File

@ -17,35 +17,39 @@ use Illuminate\Support\Facades\Redirect;
class ContractController extends Controller class ContractController extends Controller
{ {
public function create(Request $request, int $type, Car $car, Contact $contact) public function create(Request $request, string $type, Car $car, Contact $contact)
{ {
return Inertia::render('Contracts/Create', [ return Inertia::render('Contracts/Create', [
'car' => $this->getCarFields($car), 'car' => $this->getCarFields($car),
'contact' => $this->getContactFields($contact), 'contact' => $this->getContactFields($contact),
'type' => ContractType::coerce($type)->key, 'is_sell_contract' => ContractType::coerce($type) == ContractType::SellContract,
'type' => $type,
'car_first' => (bool)$request->query('carFirst'), 'car_first' => (bool)$request->query('carFirst'),
'insurance_types' => InsuranceType::asSelectArray(),
]); ]);
} }
public function createFromCar(Request $request, int $type, Car $car) public function createFromCar(Request $request, string $type, Car $car)
{ {
return Inertia::render('Contracts/CreateFromCar', [ return Inertia::render('Contracts/CreateFromCar', [
'car' => $this->getCarFields($car), 'car' => $this->getCarFields($car),
'type' => ContractType::coerce($type)->key, 'is_sell_contract' => ContractType::coerce($type) == ContractType::SellContract,
'type' => $type,
'contacts' => Contact::all()->map(function ($contact) { 'contacts' => Contact::all()->map(function ($contact) {
return $this->getContactFields($contact); return $this->getContactFields($contact);
}), }),
]); ]);
} }
public function createFromContact(Request $request, int $type, Contact $contact) public function createFromContact(Request $request, string $type, Contact $contact)
{ {
$contractType = ContractType::coerce($type); $contractType = ContractType::coerce($type);
$cars = $contractType->value == ContractType::SellContract ? Car::unsoldOnly() : Car::soldOnly(); $cars = $contractType->value == ContractType::SellContract ? Car::unsoldOnly() : Car::soldOnly();
return Inertia::render('Contracts/CreateFromContact', [ return Inertia::render('Contracts/CreateFromContact', [
'contact' => $this->getContactFields($contact), 'contact' => $this->getContactFields($contact),
'type' => $contractType->key, 'is_sell_contract' => $contractType == ContractType::SellContract,
'type' => $type,
'cars' => $cars->get()->map(function ($car) { 'cars' => $cars->get()->map(function ($car) {
return $this->getCarFields($car); return $this->getCarFields($car);
}), }),
@ -133,6 +137,8 @@ class ContractController extends Controller
'date' => $contract->date, 'date' => $contract->date,
'date_formatted' => $contract->date_formatted, 'date_formatted' => $contract->date_formatted,
'is_sell_contract' => $contract->isSellContract(), 'is_sell_contract' => $contract->isSellContract(),
'type' => $contract->type,
'type_formatted' => $contract->type_formatted,
'price' => $contract->price->getAmount(), 'price' => $contract->price->getAmount(),
'insurance_type' => (string)$contract->insurance_type, 'insurance_type' => (string)$contract->insurance_type,
'car' => [ 'car' => [
@ -140,7 +146,7 @@ class ContractController extends Controller
'name' => $contract->car->name, 'name' => $contract->car->name,
], ],
], ],
'insurance_types' => InsuranceType::asArray(), 'insurance_types' => InsuranceType::asSelectArray(),
]); ]);
} }
@ -172,6 +178,7 @@ class ContractController extends Controller
'date' => $contract->date_formatted, 'date' => $contract->date_formatted,
'price' => $contract->price->format(), 'price' => $contract->price->format(),
'type' => $contract->type, 'type' => $contract->type,
'type_formatted' => $contract->type_formatted,
'paid' => $contract->paid->format(), 'paid' => $contract->paid->format(),
'left_to_pay' => $contract->left_to_pay->format(), 'left_to_pay' => $contract->left_to_pay->format(),
'is_sell_contract' => $contract->isSellContract(), 'is_sell_contract' => $contract->isSellContract(),

View File

@ -2,6 +2,7 @@
namespace App\Models; namespace App\Models;
use Carbon\Carbon;
use App\Enums\ContractType; use App\Enums\ContractType;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
@ -26,7 +27,7 @@ class Contact extends Model
public function getNameAttribute() public function getNameAttribute()
{ {
return $this->lastname . ' ' . $this->firstname; return implode(' ', array_filter([$this->lastname, $this->firstname]));
} }
public function getTitleAttribute() public function getTitleAttribute()
@ -38,6 +39,15 @@ class Contact extends Model
return $this->name; return $this->name;
} }
public function getDeletedAtAttribute($deleted_at)
{
if ($deleted_at) {
return Carbon::parse($deleted_at)->format('d.m.Y');
}
return null;
}
public function getFullTitleAttribute() public function getFullTitleAttribute()
{ {
return implode(', ', array_filter([$this->company, $this->name])); return implode(', ', array_filter([$this->company, $this->name]));

12
composer.lock generated
View File

@ -8316,16 +8316,16 @@
}, },
{ {
"name": "sebastian/global-state", "name": "sebastian/global-state",
"version": "5.0.2", "version": "5.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git", "url": "https://github.com/sebastianbergmann/global-state.git",
"reference": "a90ccbddffa067b51f574dea6eb25d5680839455" "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/a90ccbddffa067b51f574dea6eb25d5680839455", "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49",
"reference": "a90ccbddffa067b51f574dea6eb25d5680839455", "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -8368,7 +8368,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues", "issues": "https://github.com/sebastianbergmann/global-state/issues",
"source": "https://github.com/sebastianbergmann/global-state/tree/5.0.2" "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3"
}, },
"funding": [ "funding": [
{ {
@ -8376,7 +8376,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2020-10-26T15:55:19+00:00" "time": "2021-06-11T13:31:12+00:00"
}, },
{ {
"name": "sebastian/lines-of-code", "name": "sebastian/lines-of-code",

132
public/js/app.js vendored
View File

@ -20733,15 +20733,6 @@ __webpack_require__.r(__webpack_exports__);
notes: this.contact.notes notes: this.contact.notes
} }
}; };
},
computed: {
title: function title() {
if (this.data.company) {
return this.data.company;
}
return this.data.lastname + ' ' + this.data.firstname;
}
} }
}); });
@ -20906,15 +20897,6 @@ __webpack_require__.r(__webpack_exports__);
return { return {
currentRoute: 'contacts.show' currentRoute: 'contacts.show'
}; };
},
computed: {
title: function title() {
if (this.contact.company) {
return this.contact.company;
}
return this.contact.lastname + ' ' + this.contact.firstname;
}
} }
}); });
@ -20937,10 +20919,8 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var _Jetstream_ActionMessage__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/Jetstream/ActionMessage */ "./resources/js/Jetstream/ActionMessage.vue"); /* harmony import */ var _Jetstream_ActionMessage__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/Jetstream/ActionMessage */ "./resources/js/Jetstream/ActionMessage.vue");
/* harmony import */ var _Jetstream_InputError__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/Jetstream/InputError */ "./resources/js/Jetstream/InputError.vue"); /* harmony import */ var _Jetstream_InputError__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/Jetstream/InputError */ "./resources/js/Jetstream/InputError.vue");
/* harmony import */ var _Jetstream_FormSection__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/Jetstream/FormSection */ "./resources/js/Jetstream/FormSection.vue"); /* harmony import */ var _Jetstream_FormSection__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/Jetstream/FormSection */ "./resources/js/Jetstream/FormSection.vue");
/* harmony import */ var vue_multiselect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! vue-multiselect */ "./node_modules/vue-multiselect/dist/vue-multiselect.esm.js"); /* harmony import */ var vue3_datepicker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! vue3-datepicker */ "./node_modules/vue3-datepicker/dist/vue3-datepicker.esm.js");
/* harmony import */ var vue3_datepicker__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! vue3-datepicker */ "./node_modules/vue3-datepicker/dist/vue3-datepicker.esm.js"); /* harmony import */ var _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @inertiajs/inertia-vue3 */ "./node_modules/@inertiajs/inertia-vue3/dist/index.js");
/* harmony import */ var _inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @inertiajs/inertia-vue3 */ "./node_modules/@inertiajs/inertia-vue3/dist/index.js");
@ -20957,54 +20937,22 @@ __webpack_require__.r(__webpack_exports__);
JetInput: _Jetstream_Input_vue__WEBPACK_IMPORTED_MODULE_2__.default, JetInput: _Jetstream_Input_vue__WEBPACK_IMPORTED_MODULE_2__.default,
JetInputError: _Jetstream_InputError__WEBPACK_IMPORTED_MODULE_4__.default, JetInputError: _Jetstream_InputError__WEBPACK_IMPORTED_MODULE_4__.default,
JetActionMessage: _Jetstream_ActionMessage__WEBPACK_IMPORTED_MODULE_3__.default, JetActionMessage: _Jetstream_ActionMessage__WEBPACK_IMPORTED_MODULE_3__.default,
Multiselect: vue_multiselect__WEBPACK_IMPORTED_MODULE_6__.default, Datepicker: vue3_datepicker__WEBPACK_IMPORTED_MODULE_6__.default
Datepicker: vue3_datepicker__WEBPACK_IMPORTED_MODULE_7__.default
}, },
props: { props: {
data: Object, data: Object,
meta: Object, meta: Object,
insurance_types: Object insurance_types: Array
}, },
data: function data() { data: function data() {
return { return {
form: (0,_inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_8__.useForm)(this.meta.form_name, this.data), form: (0,_inertiajs_inertia_vue3__WEBPACK_IMPORTED_MODULE_7__.useForm)(this.meta.form_name, this.data)
insuranceSelection: {
key: this.data.insurance_type,
label: 'asd'
}
}; };
}, },
computed: {
insurances: function insurances() {
var insurances = [];
for (var label in this.insurance_types) {
insurances.push({
key: this.insurance_types[label],
label: label
});
}
return insurances;
}
},
methods: { methods: {
submitForm: function submitForm() { submitForm: function submitForm() {
this.form.date = this.form.date.toISOString().split("T")[0];
this.form.submit(this.meta.method, this.meta.route); this.form.submit(this.meta.method, this.meta.route);
},
updateInsuranceSelection: function updateInsuranceSelection(selection) {
this.form.insurance_type = selection.key.toString();
} }
},
mounted: function mounted() {
this.$nextTick(function () {
var _this = this;
this.insuranceSelection = this.insurances.find(function (x) {
return x.key === parseInt(_this.data.insurance_type);
});
});
} }
}); });
@ -21048,7 +20996,8 @@ __webpack_require__.r(__webpack_exports__);
car: Object, car: Object,
contact: Object, contact: Object,
type: String, type: String,
car_first: Boolean car_first: Boolean,
insurance_types: Array
}, },
data: function data() { data: function data() {
return { return {
@ -21063,7 +21012,7 @@ __webpack_require__.r(__webpack_exports__);
id: null, id: null,
date: (0,vue__WEBPACK_IMPORTED_MODULE_6__.ref)(new Date()), date: (0,vue__WEBPACK_IMPORTED_MODULE_6__.ref)(new Date()),
price: null, price: null,
type: this.type == "SellContract" ? '0' : '1', type: this.type,
insurance_type: '0', insurance_type: '0',
car_id: this.car.id, car_id: this.car.id,
contact_id: this.contact.id, contact_id: this.contact.id,
@ -21389,7 +21338,7 @@ __webpack_require__.r(__webpack_exports__);
}, },
props: { props: {
contract: Object, contract: Object,
insurance_types: Object insurance_types: Array
}, },
data: function data() { data: function data() {
return { return {
@ -21466,11 +21415,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
contract: Object contract: Object
}, },
computed: { computed: {
contractType: function contractType() {
return this.contract.type == 0 ? 'Ankaufsvertrag' : 'Verkaufsvertrag';
},
contactTitle: function contactTitle() { contactTitle: function contactTitle() {
return this.contract.type == 0 ? 'Verkäufer' : 'Käufer'; return this.contract.is_sell_contract ? 'Käufer' : 'Verkäufer';
} }
}, },
data: function data() { data: function data() {
@ -22768,7 +22714,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_1, [$props.contact.company ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_2, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contact.company), 1 return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_1, [$props.contact.company ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_2, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contact.company), 1
/* TEXT */ /* TEXT */
)) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), $props.contact.lastname && $props.contact.firstname ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_3, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contact.lastname + ' ' + $props.contact.firstname), 1 )) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), $props.contact.name ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_3, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contact.name), 1
/* TEXT */ /* TEXT */
)) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), $props.contact.address ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_4, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contact.address), 1 )) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), $props.contact.address ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_4, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contact.address), 1
/* TEXT */ /* TEXT */
@ -28650,7 +28596,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
}, null, 8 }, null, 8
/* PROPS */ /* PROPS */
, ["href"]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_bread_crumb, { , ["href"]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_bread_crumb, {
text: $options.title, text: $props.contact.title,
href: _ctx.route('contacts.show', $props.contact.id) href: _ctx.route('contacts.show', $props.contact.id)
}, null, 8 }, null, 8
/* PROPS */ /* PROPS */
@ -28875,7 +28821,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
href: _ctx.route('contacts') href: _ctx.route('contacts')
}, null, 8 }, null, 8
/* PROPS */ /* PROPS */
, ["href"]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($options.title), 1 , ["href"]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contact.title), 1
/* TEXT */ /* TEXT */
)])]; )])];
}), }),
@ -29015,8 +28961,6 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
var _component_jet_input = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("jet-input"); var _component_jet_input = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("jet-input");
var _component_multiselect = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("multiselect");
var _component_jet_action_message = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("jet-action-message"); var _component_jet_action_message = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("jet-action-message");
var _component_jet_button = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("jet-button"); var _component_jet_button = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("jet-button");
@ -29075,23 +29019,23 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
, ["message"])]), $data.form.is_sell_contract ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_5, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_jet_label, { , ["message"])]), $data.form.is_sell_contract ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("div", _hoisted_5, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_jet_label, {
"for": "insurance_type", "for": "insurance_type",
value: "Versicherung" value: "Versicherung"
}), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_multiselect, { }), (0,vue__WEBPACK_IMPORTED_MODULE_0__.withDirectives)((0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("select", {
"class": "mt-1 block w-full",
onSelect: $options.updateInsuranceSelection,
modelValue: $data.insuranceSelection,
"onUpdate:modelValue": _cache[3] || (_cache[3] = function ($event) { "onUpdate:modelValue": _cache[3] || (_cache[3] = function ($event) {
return $data.insuranceSelection = $event; return $data.form.insurance_type = $event;
}), }),
"deselect-label": "Kann nicht entfernt werden", "class": "mt-1 block w-full border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 rounded-md shadow-sm"
"track-by": "key", }, [((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(true), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)(vue__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,vue__WEBPACK_IMPORTED_MODULE_0__.renderList)($props.insurance_types, function (insurance, index) {
label: "label", return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createBlock)("option", {
placeholder: "Versicherung auswählen", value: index,
options: $options.insurances, selected: $data.form.insurance_type == index
searchable: false, }, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)(insurance), 9
"allow-empty": false /* TEXT, PROPS */
}, null, 8 , ["value", "selected"]);
/* PROPS */ }), 256
, ["onSelect", "modelValue", "options"]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_jet_input_error, { /* UNKEYED_FRAGMENT */
))], 512
/* NEED_PATCH */
), [[vue__WEBPACK_IMPORTED_MODULE_0__.vModelSelect, $data.form.insurance_type]]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_jet_input_error, {
message: $data.form.errors.insurance_type, message: $data.form.errors.insurance_type,
"class": "mt-2" "class": "mt-2"
}, null, 8 }, null, 8
@ -29291,7 +29235,8 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
})) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_contract_form, { })) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)("v-if", true), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_contract_form, {
"class": "mt-5", "class": "mt-5",
data: $data.data, data: $data.data,
meta: $data.meta meta: $data.meta,
insurance_types: $props.insurance_types
}, { }, {
title: (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () { title: (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
return [_hoisted_3]; return [_hoisted_3];
@ -29304,7 +29249,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
}, 8 }, 8
/* PROPS */ /* PROPS */
, ["data", "meta"])])]; , ["data", "meta", "insurance_types"])])];
}), }),
_: 1 _: 1
/* STABLE */ /* STABLE */
@ -29750,8 +29695,6 @@ var _hoisted_2 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNod
var _hoisted_3 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)("Vertragsangaben"); var _hoisted_3 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)("Vertragsangaben");
var _hoisted_4 = /*#__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" Vertrag & anpassen. ");
function render(_ctx, _cache, $props, $setup, $data, $options) { function render(_ctx, _cache, $props, $setup, $data, $options) {
var _component_bread_crumb = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("bread-crumb"); var _component_bread_crumb = (0,vue__WEBPACK_IMPORTED_MODULE_0__.resolveComponent)("bread-crumb");
@ -29772,7 +29715,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
}, null, 8 }, null, 8
/* PROPS */ /* PROPS */
, ["text", "href"]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_bread_crumb, { , ["text", "href"]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)(_component_bread_crumb, {
text: 'Vertrag vom ' + $props.contract.date_formatted, text: $props.contract.type_formatted + ' vom ' + $props.contract.date_formatted,
href: _ctx.route('contracts.show', $props.contract.id) href: _ctx.route('contracts.show', $props.contract.id)
}, null, 8 }, null, 8
/* PROPS */ /* PROPS */
@ -29788,7 +29731,9 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
return [_hoisted_3]; return [_hoisted_3];
}), }),
description: (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () { description: (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
return [_hoisted_4]; return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)((0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contract.type_formatted) + " & anpassen. ", 1
/* TEXT */
)];
}), }),
_: 1 _: 1
/* STABLE */ /* STABLE */
@ -29933,12 +29878,12 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
href: _ctx.route('cars.show', $props.contract.car.id) href: _ctx.route('cars.show', $props.contract.car.id)
}, null, 8 }, null, 8
/* PROPS */ /* PROPS */
, ["text", "href"]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($options.contractType) + " vom " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contract.date), 1 , ["text", "href"]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createTextVNode)(" " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contract.type_formatted) + " vom " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contract.date), 1
/* TEXT */ /* TEXT */
)]; )];
}), }),
info: (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () { info: (0,vue__WEBPACK_IMPORTED_MODULE_0__.withCtx)(function () {
return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_1, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_2, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($options.contractType) + " vom " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contract.date), 1 return [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_1, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_2, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contract.type_formatted) + " vom " + (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contract.date), 1
/* TEXT */ /* TEXT */
), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_3, [_hoisted_4, (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_5, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contract.date), 1 ), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_3, [_hoisted_4, (0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)("div", _hoisted_5, (0,vue__WEBPACK_IMPORTED_MODULE_0__.toDisplayString)($props.contract.date), 1
/* TEXT */ /* TEXT */
@ -63135,12 +63080,9 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ }); /* harmony export */ });
/* harmony import */ var _ContractForm_vue_vue_type_template_id_6782cc08__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ContractForm.vue?vue&type=template&id=6782cc08 */ "./resources/js/Pages/Contracts/Components/ContractForm.vue?vue&type=template&id=6782cc08"); /* harmony import */ var _ContractForm_vue_vue_type_template_id_6782cc08__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ContractForm.vue?vue&type=template&id=6782cc08 */ "./resources/js/Pages/Contracts/Components/ContractForm.vue?vue&type=template&id=6782cc08");
/* harmony import */ var _ContractForm_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ContractForm.vue?vue&type=script&lang=js */ "./resources/js/Pages/Contracts/Components/ContractForm.vue?vue&type=script&lang=js"); /* harmony import */ var _ContractForm_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ContractForm.vue?vue&type=script&lang=js */ "./resources/js/Pages/Contracts/Components/ContractForm.vue?vue&type=script&lang=js");
/* harmony import */ var vue_multiselect_dist_vue_multiselect_css_vue_type_style_index_0_lang_css__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! vue-multiselect/dist/vue-multiselect.css?vue&type=style&index=0&lang=css */ "./node_modules/vue-multiselect/dist/vue-multiselect.css?vue&type=style&index=0&lang=css");
;
_ContractForm_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__.default.render = _ContractForm_vue_vue_type_template_id_6782cc08__WEBPACK_IMPORTED_MODULE_0__.render _ContractForm_vue_vue_type_script_lang_js__WEBPACK_IMPORTED_MODULE_1__.default.render = _ContractForm_vue_vue_type_template_id_6782cc08__WEBPACK_IMPORTED_MODULE_0__.render
/* hot reload */ /* hot reload */
if (false) {} if (false) {}

View File

@ -3,8 +3,8 @@
<div v-if="contact.company" class="font-bold"> <div v-if="contact.company" class="font-bold">
{{ contact.company }} {{ contact.company }}
</div> </div>
<div v-if="contact.lastname && contact.firstname"> <div v-if="contact.name">
{{ contact.lastname + ' ' + contact.firstname }} {{ contact.name }}
</div> </div>
<div v-if="contact.address"> <div v-if="contact.address">
{{ contact.address }} {{ contact.address }}

View File

@ -3,7 +3,7 @@
<template #header> <template #header>
<h2 class="font-semibold text-xl text-gray-800 leading-tight"> <h2 class="font-semibold text-xl text-gray-800 leading-tight">
<bread-crumb text="Kontakte" :href="route('contacts')" /> <bread-crumb text="Kontakte" :href="route('contacts')" />
<bread-crumb :text="title" :href="route('contacts.show', contact.id)" /> <bread-crumb :text="contact.title" :href="route('contacts.show', contact.id)" />
bearbeiten bearbeiten
</h2> </h2>
</template> </template>
@ -58,14 +58,5 @@ export default {
}, },
} }
}, },
computed: {
title: function () {
if (this.data.company) {
return this.data.company;
}
return this.data.lastname + ' ' + this.data.firstname;
},
},
} }
</script> </script>

View File

@ -3,7 +3,7 @@
<template #header> <template #header>
<h2 class="font-semibold text-xl text-gray-800 leading-tight"> <h2 class="font-semibold text-xl text-gray-800 leading-tight">
<bread-crumb text="Kontakte" :href="route('contacts')" /> <bread-crumb text="Kontakte" :href="route('contacts')" />
{{ title }} {{ contact.title }}
</h2> </h2>
</template> </template>
@ -83,14 +83,5 @@ export default {
currentRoute: 'contacts.show', currentRoute: 'contacts.show',
} }
}, },
computed: {
title: function () {
if (this.contact.company) {
return this.contact.company;
}
return this.contact.lastname + ' ' + this.contact.firstname;
},
},
} }
</script> </script>

View File

@ -25,11 +25,12 @@
<div v-if="form.is_sell_contract" class="col-span-6 sm:col-span-4"> <div v-if="form.is_sell_contract" class="col-span-6 sm:col-span-4">
<jet-label for="insurance_type" value="Versicherung" /> <jet-label for="insurance_type" value="Versicherung" />
<multiselect class="mt-1 block w-full" @select="updateInsuranceSelection" v-model="insuranceSelection" deselect-label="Kann nicht entfernt werden" track-by="key" label="label" placeholder="Versicherung auswählen" :options="insurances" :searchable="false" :allow-empty="false" /> <select v-model="form.insurance_type" class="mt-1 block w-full border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 rounded-md shadow-sm">
<option v-for="(insurance, index) in insurance_types" :value="index" :selected="form.insurance_type == index">{{ insurance }}</option>
</select>
<jet-input-error :message="form.errors.insurance_type" class="mt-2" /> <jet-input-error :message="form.errors.insurance_type" class="mt-2" />
</div> </div>
</div> </div>
</template> </template>
<template #actions> <template #actions>
@ -52,7 +53,6 @@ import JetInput from '@/Jetstream/Input.vue'
import JetActionMessage from '@/Jetstream/ActionMessage' import JetActionMessage from '@/Jetstream/ActionMessage'
import JetInputError from '@/Jetstream/InputError' import JetInputError from '@/Jetstream/InputError'
import JetFormSection from '@/Jetstream/FormSection' import JetFormSection from '@/Jetstream/FormSection'
import Multiselect from 'vue-multiselect'
import Datepicker from 'vue3-datepicker' import Datepicker from 'vue3-datepicker'
import { useForm } from '@inertiajs/inertia-vue3' import { useForm } from '@inertiajs/inertia-vue3'
@ -64,43 +64,22 @@ export default {
JetInput, JetInput,
JetInputError, JetInputError,
JetActionMessage, JetActionMessage,
Multiselect,
Datepicker, Datepicker,
}, },
props: { props: {
data: Object, data: Object,
meta: Object, meta: Object,
insurance_types: Object, insurance_types: Array,
}, },
data() { data() {
return { return {
form: useForm(this.meta.form_name, this.data), form: useForm(this.meta.form_name, this.data),
insuranceSelection: {key: this.data.insurance_type, label: 'asd'},
} }
}, },
computed: {
insurances: function() {
let insurances = [];
for (const label in this.insurance_types) {
insurances.push({key: this.insurance_types[label], label: label});
}
return insurances;
},
},
methods: { methods: {
submitForm() { submitForm() {
this.form.date = this.form.date.toISOString().split("T")[0];
this.form.submit(this.meta.method, this.meta.route); this.form.submit(this.meta.method, this.meta.route);
}, },
updateInsuranceSelection(selection) {
this.form.insurance_type = (selection.key).toString();
},
},
mounted: function () {
this.$nextTick(function () {
this.insuranceSelection = this.insurances.find(x => x.key === parseInt(this.data.insurance_type));
})
}, },
} }
</script> </script>
<style src="vue-multiselect/dist/vue-multiselect.css"></style>

View File

@ -45,7 +45,7 @@
<contact-card class="col-span-12" :contact="contact" /> <contact-card class="col-span-12" :contact="contact" />
</template> </template>
</jet-form-section> </jet-form-section>
<contract-form class="mt-5" :data="data" :meta="meta"> <contract-form class="mt-5" :data="data" :meta="meta" :insurance_types="insurance_types">
<template #title>Vertragsinformationen erfassen</template> <template #title>Vertragsinformationen erfassen</template>
<template #description>Der Vertrag kann anschliessend gespeichert werden.</template> <template #description>Der Vertrag kann anschliessend gespeichert werden.</template>
</contract-form> </contract-form>
@ -76,6 +76,7 @@ export default {
contact: Object, contact: Object,
type: String, type: String,
car_first: Boolean, car_first: Boolean,
insurance_types: Array,
}, },
data() { data() {
return { return {
@ -90,7 +91,7 @@ export default {
id: null, id: null,
date: ref(new Date()), date: ref(new Date()),
price: null, price: null,
type: this.type == "SellContract" ? '0' : '1', type: this.type,
insurance_type: '0', insurance_type: '0',
car_id: this.car.id, car_id: this.car.id,
contact_id: this.contact.id, contact_id: this.contact.id,

View File

@ -4,7 +4,7 @@
<h2 class="font-semibold text-xl text-gray-800 leading-tight"> <h2 class="font-semibold text-xl text-gray-800 leading-tight">
<bread-crumb text="Autos" :href="route('cars')" /> <bread-crumb text="Autos" :href="route('cars')" />
<bread-crumb :text="contract.car.name" :href="route('cars.show', contract.car.id)" /> <bread-crumb :text="contract.car.name" :href="route('cars.show', contract.car.id)" />
<bread-crumb :text="'Vertrag vom ' + contract.date_formatted" :href="route('contracts.show', contract.id)" /> <bread-crumb :text="contract.type_formatted + ' vom ' + contract.date_formatted" :href="route('contracts.show', contract.id)" />
bearbeiten bearbeiten
</h2> </h2>
</template> </template>
@ -12,7 +12,7 @@
<contract-form :data="data" :insurance_types="insurance_types" :meta="meta"> <contract-form :data="data" :insurance_types="insurance_types" :meta="meta">
<template #title>Vertragsangaben</template> <template #title>Vertragsangaben</template>
<template #description> <template #description>
Vertrag &amp; anpassen. {{ contract.type_formatted }} &amp; anpassen.
</template> </template>
</contract-form> </contract-form>
</div> </div>
@ -33,7 +33,7 @@ export default {
}, },
props: { props: {
contract: Object, contract: Object,
insurance_types: Object, insurance_types: Array,
}, },
data() { data() {
return { return {

View File

@ -3,12 +3,12 @@
<template #header> <template #header>
<bread-crumb text="Autos" :href="route('cars')" /> <bread-crumb text="Autos" :href="route('cars')" />
<bread-crumb :text="contract.car.name" :href="route('cars.show', contract.car.id)" /> <bread-crumb :text="contract.car.name" :href="route('cars.show', contract.car.id)" />
{{ contractType}} vom {{ contract.date }} {{ contract.type_formatted }} vom {{ contract.date }}
</template> </template>
<template #info> <template #info>
<div class="p-5 bg-white shadow rounded-md font-medium"> <div class="p-5 bg-white shadow rounded-md font-medium">
<div class="font-bold pb-1 mb-1 text-2xl border-b"> <div class="font-bold pb-1 mb-1 text-2xl border-b">
{{ contractType}} vom {{ contract.date }} {{ contract.type_formatted }} vom {{ contract.date }}
</div> </div>
<div class="grid grid-cols-4 gap-2 w-full"> <div class="grid grid-cols-4 gap-2 w-full">
<div class="col-span-1 xs:col-span-2"> <div class="col-span-1 xs:col-span-2">
@ -105,11 +105,8 @@ export default {
contract: Object, contract: Object,
}, },
computed: { computed: {
contractType: function() {
return this.contract.type == 0 ? 'Ankaufsvertrag' : 'Verkaufsvertrag';
},
contactTitle: function() { contactTitle: function() {
return this.contract.type == 0 ? 'Verkäufer' : 'Käufer'; return this.contract.is_sell_contract ? 'Käufer' : 'Verkäufer';
} }
}, },
data() { data() {

View File

@ -52,10 +52,10 @@ Route::middleware(['auth:sanctum', 'verified'])->group(function () {
Route::prefix('contracts')->group(function () { Route::prefix('contracts')->group(function () {
Route::post('/', [ContractController::class, 'store'])->name('contracts.store'); Route::post('/', [ContractController::class, 'store'])->name('contracts.store');
Route::prefix('create/{0|1}/')->group(function () { Route::prefix('create/{type}')->group(function () {
Route::get('car/{car}/contact/{contact}', [ContractController::class, 'create'])->name('contracts.create'); Route::get('car/{car}/contact/{contact}', [ContractController::class, 'create'])->where('type', '0|1')->name('contracts.create');
Route::get('car/{car}', [ContractController::class, 'createFromCar'])->name('contracts.create_from_car'); Route::get('car/{car}', [ContractController::class, 'createFromCar'])->where('type', '0|1')->name('contracts.create_from_car');
Route::get('contact/{contact}', [ContractController::class, 'createFromContact'])->name('contracts.create_from_contact'); Route::get('contact/{contact}', [ContractController::class, 'createFromContact'])->where('type', '0|1')->name('contracts.create_from_contact');
}); });
Route::prefix('{contract}')->group(function () { Route::prefix('{contract}')->group(function () {