I suggest you read the manual https://laravel.com/docs/5.6/eloquent The part on relationships is key.
Jul 10, 2018
3
Level 1
Laravel show customer_name by using customer_id
I am using laravel and vue js. I have two tables: customers and projects. I have a form - a dropdown form which user can select a customer_name. However, in the projects table, I want to store customer_id from the form selected by the user. I want to use id in customers table to show customer_name in the form. How this can be done?
Thanks,
Level 40
Assuming you are submitting formdata from your POST as payload. Then your select logic might be like:
<select class="form-control" id="customer_id" v-model="formdata.customer_id">
<option v-for="customer in customers" :value="customer.id" v-text="customer.name"/>
</select>
Assuming you have an array of JS customers objects being set from props, or somehow.
Please or to participate in this conversation.