@lbecket [UPDATED], Now i can fetch all headers data dynamically from db like this.
<tr>
<th><input type="checkbox" class="form-check-input" v-model="selectAll" title="Select All"></th>
<th v-for="(header, index) in visibleHeaders" :key="index" scope="col">
{{ header }}
</th>
</tr>
return {
headers: [],
field: ' ',
leads: [],
selected: [],
}
computed: {
visibleHeaders() {
return this.headers.map(h => {
return h.Field.replace("_", " ").toUpperCase()
});
},
methods: {
getData() {
axios.get('/leads/getleads')
.then(response => {
this.leads = response.data.leads
this.headers = response.data.fields
// console.log(response.data.leads)
})
},
addField() {
axios({
method: 'POST',
url: '/leads/addfield',
data: {
field: this.field,
}
})
.then(response => {
console.log(response)
})
}
}
Laravel controller
$query = "SHOW COLUMNS FROM $table_name";
$data = DB::select($query);
dd($data);
//Response
array::11 [
0 => {#1331
+"Field": "id"
+"Type": "bigint unsigned"
+"Null": "NO"
+"Key": "PRI"
+"Default": null
+"Extra": "auto_increment"
}
]
And this solution comes with anoter questions. If i will have an edit method , how can i display body content in same way as header?