And here is the script:
import { Head, Link } from '@inertiajs/vue3' import Icon from '@/Shared/Icon.vue' import Layout from '@/Shared/Layout.vue' import TextInput from '@/Shared/TextInput.vue' import SelectInput from '@/Shared/SelectInput.vue' import LoadingButton from '@/Shared/LoadingButton.vue'
export default { components: { Head, Icon, Link, LoadingButton, SelectInput, TextInput, }, layout: Layout, props: { contacts: Array, orderItems: Array, }, remember: 'form', data() { return { form: this.$inertia.form({ contact_id: null, address: null, type: 'Dine In', status: 'New', menu_items: [{ menu_id:'', quantity:'', sale_price:'', },], }), } }, methods: { store() { this.form.post('/orders') }, add_more_items() { this.form.menu_items.push({'menu_id':'','quantity':'','sale_price':'',}); console.log(this.form.menu_items); }, remove_items(index) { // alert(index) console.log(this.form.menu_items) console.log(index) this.form.menu_items.splice(index, 1); console.log(this.form.menu_items) }, onMenuChange(event) { console.log(event.target.value) } }, }