diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index 9371726..a537af2 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -82,6 +82,24 @@ class CustomerController extends Controller return redirect('customer/' . $customer->id); } + /** + * Update the specified resource in storage. + */ + public function updateComment(Request $request) + { + $request->validate([ + 'customer_id' => 'required', + 'comment' => 'required', + ]); + + $customer = Customer::findOrFail($request->customer_id); + + $customer->comment = $request->comment; + $customer->save(); + + return redirect('customer/' . $customer->id); + } + /** * Remove the specified resource from storage. */ diff --git a/app/Models/Customer.php b/app/Models/Customer.php index 4f51bfe..469299b 100644 --- a/app/Models/Customer.php +++ b/app/Models/Customer.php @@ -20,6 +20,7 @@ class Customer extends Model 'amount used', 'deposit', 'give_leftover', + 'comment' ]; /** diff --git a/database/migrations/2025_09_20_164540_add_comment_to_customer_table.php b/database/migrations/2025_09_20_164540_add_comment_to_customer_table.php new file mode 100644 index 0000000..ac73f79 --- /dev/null +++ b/database/migrations/2025_09_20_164540_add_comment_to_customer_table.php @@ -0,0 +1,28 @@ +mediumText('comment'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('customers', function (Blueprint $table) { + $table->dropColumn('comment'); + }); + } +}; diff --git a/resources/css/app.scss b/resources/css/app.scss index 24075e7..23b9c82 100644 --- a/resources/css/app.scss +++ b/resources/css/app.scss @@ -11,6 +11,15 @@ color: var(--button-link-color); } +.button.is-info { + border: 1px solid var(--button-link-background-color); + color: var(--button-link-background-color); + + &:hover { + border: 2px solid var(--button-link-background-color); + } +} + .button.letter { background-color: #fff; color: #000; diff --git a/resources/js/Pages/Customer.tsx b/resources/js/Pages/Customer.tsx index 0c6d6c5..f9b045f 100644 --- a/resources/js/Pages/Customer.tsx +++ b/resources/js/Pages/Customer.tsx @@ -1,5 +1,6 @@ import TextInput from '@/Components/TextInput'; import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'; +import { Textarea } from '@headlessui/react'; import { Head, useForm } from '@inertiajs/react'; import axios from 'axios'; import { FormEventHandler } from 'react'; @@ -12,6 +13,7 @@ interface CustomerProps { amount_left: number give_leftover: number guardian_name: string + comment: string; purchases: [{ id: number amount: number @@ -29,7 +31,8 @@ export default function Customer({customer}: CustomerProps) { amount: "", customer_id: customer.id, deposit: "", - id: customer.id + id: customer.id, + comment: "" }); const submit: FormEventHandler = (e) => { @@ -46,6 +49,12 @@ export default function Customer({customer}: CustomerProps) { }); } + const updateComment: FormEventHandler = (e) => { + e.preventDefault() + post(route('update_comment'), { + }); + } + const deleteCustomer = (id: string | number) => { axios.delete('/api/customer/' + id) .then(response => { @@ -119,6 +128,30 @@ export default function Customer({customer}: CustomerProps) { +
+

Kommentar

+
+
+
+