I am trying to save my data from a dynamic selected dropdown into my database but I'm having errors doing so.
This is the error I am getting.
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'county_id' cannot be null (SQL: insert into `properties` (`National_id`, `Plot_No`, `Property_Ad`, `Property_Photo`, `Property_features`, `county_id`, `sc_id`, `town_id`, `type`, `updated_at`, `created_at`) values (63636, 424545, Duplex Apartments, test.jpg, Free parking, ?, ?, ?, ?, 2023-02-18 09:42:30, 2023-02-18 09:42:30))
I need help on how to save a selected drop down to a database which is a foreign key referencing another table (county_id references id on the county table, sc_id references id on the subcounty table and town_id references id on the town table).
This is my livewire page.
<form id="add-property-form" method="POST" action="{{URL::to('saveProperty')}}">
#csrf
<div class="col-md-8">
<div class="card">
<div class="card-body">
#if ($errors->any())
<div class="alert alert-danger">
<ul>
#foreach ($errors->all() as $error)
<li class="text-white">{{ $error }}</li>
#endforeach
</ul>
</div>
#endif
<div class= "form-group">
<!--input pattern= "[a-zA-Z]{2,10}$" required-->
<p>National id</p><input type="number" required name="National_id" value="{{old('National_id')}}" class="form-control #error('National_id') is-invalid #enderror"
placeholder="Confirm your National id number">
<div class="invalid-feedback">
#error('National_id') {{$message}} #enderror
</div>
<p>Plot No</p><input type="number" required name="plot_no" value="{{old('plot_no')}}" class="form-control #error('plot_no') is-invalid #enderror"
placeholder="Please enter plot number">
<div class="invalid-feedback">
#error('plot_no') {{$message}} #enderror
</div>
<p>Property Description</p><input type="text" required name="Property_Ad" value="{{old('Property_Ad')}}" class="form-control #error('Property_Ad') is-invalid #enderror"
placeholder="Please enter property description">
<div class="invalid-feedback">
#error('Property_Ad') {{$message}} #enderror
</div>
<p>Property Features</p><input type="text" required name="Property features" value="{{old('Property_features')}}" class="form-control #error('Property_features') is-invalid #enderror"
placeholder="Please enter property features">
<div class="invalid-feedback">
#error('Property_features') {{$message}} #enderror
</div>
<p>Property Images</p><input type="file" required name="Property_Photo" value="{{old('Property_Photo')}}" class="form-control"
>
<p>Location</p>
<div class="row align-items-start">
<div class="col">
<select id="County" class="form-select-lg mb-3 form-control" wire:model = "selectedCounty" name="County">
<option value="" >County</option>
#foreach ($counties as $co)
<option value="{{$co->id}}">{{$co->name}}</option>
#endforeach
</select>
</div>
#if (!is_null($subcounty))
<div class="col">
<select id="subCounty" class="form-select-lg mb-3 form-control" wire:model = "selectedSubCounty" name="subCounty">
<option value="">SubCounty</option>
#foreach ($subcounty as $su)
<option value="{{$su->id}}">{{$su->name}}</option>
#endforeach
</select>
</div>
#endif
#if (!is_null($town))
<div class="col">
<select id="Town" class="form-select-lg mb-3 form-control" wire:model = "selectedTown" name="Town">
<option value="">Town</option>
#foreach ($town as $to)
<option value="{{$to->id}}">{{$to->name}}</option>
#endforeach
</select>
</div>
#endif
</div>
<p>Property Type</p><input type="text" required name="property_type" value="{{old('type')}}" title="2-10 characters" class="form-control #error('type') is-invalid #enderror"
placeholder="Please enter your property type">
<div class="invalid-feedback">
#error('type') {{$message}} #enderror
</div>
</div>
<input type="submit" name="submit" class="form-control btn btn-success" >
</div>
</div>
</div>
</div>
</form>
This is my view page
#extends('layout')
#section('headTitle', 'Your Properties / Add Property')
#section('pageTitle', 'Your Properties / Add Property')
#section('content')
<livewire:subcounty />
#endsection
This is my controller page.
<?php
namespace App\Http\Controllers;
use App\Models\home_owners;
use App\Models\property;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
class ProController extends Controller
{
public function viewProperties(){
$allPros = property::paginate(7);
//dd is the laravel version of var_dump() & die();
//dd($allRoles);
return view('HO.properties', ['properties'=>$allPros]);
}
public function addProperty(){
return view('HO.addproperty');
}
public function saveProperty(Request $request){
$prop = new property();
$prop->National_id=$request->National_id;
$prop->Plot_No=$request->plot_no;
$prop->Property_Ad=$request->Property_Ad;
$prop->Property_Photo=$request->Property_Photo;
$prop->Property_features=$request->Property_features;
$prop->county_id=$request->county_id;
$prop->sc_id=$request->sc_id;
$prop->town_id=$request->town_id;
$prop->type=$request->type;
if($request->hasFile('Property_photo')){
$file = $request->file('Property_photo');
$extension = $file->getClientOriginalExtension();
$filename = time().'.'.$extension;
$file->move('uploads/properties', $filename);
$prop->Property_Photo = $filename;
}
$prop->save();
return redirect('properties')->with('status',"New Property added.");
}
public function editProperty(){
}
}
basically it is indicating that the county_id field is being sent empty or null to the database, in your form the county_id field is called County, you need to change it:
<select id="County" class="form-select-lg mb-3 form-control" wire:model = "selectedCounty" name="County">
to
<select id="County" class="form-select-lg mb-3 form-control" wire:model = "selectedCounty" name="county_id">
Related
I have four inputs in the same row and one of the input is conditionally visible by clicking "Click" button.
So if all four inputs are visible, the inputs datepicker1 and datepicker2 are sticked on the inputs above.
What is the correct bootstrap way to arrange and beautify the distances between the inputs?.
Gutters are not available on bootstrap 3.
<div class="col-md-3">
<select class="lookup-type-select form-control" name="created_lookup_type_1">
<option value="range">Range</option>
<option value="range__exclude">Exclude Range</option>
</select>
</div>
<div class="lookup-value">
<div class="col-md-3">
<select name="created__1_0" class="filter-input shortcut form-control" id="id_created__1_0">
</select>
</div>
<div class="col-md-8 row custom" style="display: inline;">
<div class="col-md-6">
<div class="datetimepicker input-group start-date date" data-date-format="YYYY-MM-DD HH:mm:ss">
<input class="filter-input form-control" name="created__1_1" value="" type="text" id="datepicker1" placeholder="From">
<span class="input-group-addon">
<span class="glyphicon-calendar glyphicon"></span>
</span>
</div>
</div>
<div class="col-md-6">
<div class="datetimepicker input-group end-date date" data-date-format="YYYY-MM-DD HH:mm:ss">
<input class="filter-input form-control" name="created__1_2" value="" type="text" id="datepicker2" placeholder="To">
<span class="input-group-addon">
<span class="glyphicon-calendar glyphicon"></span>
</span>
</div>
</div>
</div>
<div class="col-md-3 row month_only" style="display: none;">
<div>
<div class="datetimepicker input-group start-date date month_only" style="display: none;">
<input class="filter-input form-control" name="created__1_3" value="" type="text" id="id_created__1_3" placeholder="Month">
<span class="input-group-addon">
<span class="glyphicon-calendar glyphicon"></span>
</span>
</div>
</div>
</div>
</div>
<button type="button" class="btn remove-button">
<span class="glyphicon glyphicon-remove"></span>
</button>
<button onclick="myFunction()">Ckick</button>
<script>
function myFunction() {
if (document.getElementById('id_created__1_0').style.display != "none") {
document.getElementById("id_created__1_0").style.display = "none";
} else {
document.getElementById("id_created__1_0").style.display = "inline";
}
}
</script>
Jsfiddle example
Should be like the following pic
I'm trying out Livewire for the first time. The drop-down is populated from the database. Similar codes works for text fields, but fails with drop-down select fields.
Edit: The form is inside a bootstrap modal
Code is as below: The livewire component (leads-form.blade)
<div class="modal-content">
<form wire:submit.prevent="submit">
#csrf
<div class="input-field col s12">
<label for="role">Client</label>
<select class="error validate" wire:ignore id="client_id" wire:model="client_id">
<option disabled value=" ">Client</option>
#foreach($clients as $client)
<option value="{{$client->id}}"> {{$client->clientname}}</option>
#endforeach
</select>
</div>
<div class="input-field col m12 s12">
<input id="contactperson" type="text" name="contactperson" wire:model="contactperson" />
#error('contactperson') <span class="error"><small>{{ $message }}</small></span> #enderror
<label for="contactperson">Contact Person</label>
</div>
<div class="row">
<div class="row">
<div class="input-field col s12">
<button class="btn cyan waves-effect waves-light right" type="submit">Add
<i class="material-icons right">send</i>
</button>
</div>
</div>
</div>
</form>
</div>
Next Livewire leads class is as a below:
class LeadsForm extends Component
{
public $contactperson;
public $client_id;
public function submit()
{
Lead::create([
'client_id' => $this->client_id,
'contactperson' => $this->contactperson,
]);
Alert::toast('Client created successfully', 'success');
return $this->redirectRoute('leads.index');
}
public function render()
{
$clients = Client::all();
return view('livewire.leads-form',[
'clients'=>$clients,
]);
}
}
I'm using the laravel debugbar, and it shows the array client_id field as null.
Remove the wire:ignore in the select element, that avoid produce any Livewire event that can be wrapped to backend
<select class="error validate" wire:ignore id="client_id" wire:model="client_id">
<option disabled value=" ">Client</option>
#foreach($clients as $client)
<option value="{{$client->id}}"> {{$client->clientname}}</option>
#endforeach
</select>
i have failed to save update data, the notification error message is SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'status_member' cannot be null (SQL: update daftar_pelanggans set alamat = gdsgzddgrrse, status_member = ?, daftar_pelanggans.updated_at = 2020-12-06 03:36:35 where id = 6)
this is the button edit
<button data-toggle="modal" data-target="#editModal-{{ $pelanggan->id }}" class="btn btn-sm btn-primary"><i class="fa fa-edit"></i></button>
this is the modal view
#foreach($daftar_pelanggan as $pelanggan)
<div class="modal fade" id="editModal-{{ $pelanggan->id }}" tabindex="-1" role="dialog" aria-labelledby="editModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title mb-0" id="editModalLabel">Update Data Pelanggan</h5>
</div>
<div class="modal-body">
<!-- Card body -->
<form role="form" action="{{ route('daftar_pelanggan.update', $pelanggan->id) }}" method="POST" id="editForm">
#csrf
#method('PUT')
<!-- Input groups with icon -->
<div class="form-group row">
<label for="updateNamaPelanggan" class="col-md-2 col-form-label form-control-label">Nama</label>
<div class="col-md-10">
<input type="hidden" name="id" value="{{ $pelanggan->id }}">
<input class="form-control" type="nama" value="{{ $pelanggan->nama_pelanggan }}" name="updateNamaPelanggan" required >
</div>
</div>
<div class="form-group row">
<label for="updateAlamat" class="col-md-2 col-form-label form-control-label">Alamat</label>
<div class="col-md-10">
<input class="form-control" type="alamat" value="{{ $pelanggan->alamat }}" name="updateAlamat" required>
</div>
</div>
<div class="form-group row">
<label for="updateNoTelp" class="col-md-2 col-form-label form-control-label">No.Telp</label>
<div class="col-md-10">
<input class="form-control" type="notelp" value="{{ $pelanggan->no_telp }}" name="updateNoTelp" required>
</div>
</div>
<div class="form-group row">
<div class="col-md-6">
<div class="form-group">
<label class="form-control-label" for="updatePoin">POIN</label>
<input type="text" class="form-control" value="{{ $pelanggan->poin }}" name="updatePoin">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="form-control-label" for="status_member">Kategori</label>
<!-- <h3>{{ $pelanggan->status_member }}</h3>-->
<select class="form-control" name="status_member" required="required">
<option value="silver" {{ $pelanggan->status_member === 'Silver' ? 'selected' : '' }} >Silver</option>
<option value="gold" {{ $pelanggan->status_member === 'Gold' ? 'selected' : '' }} >Gold</option>
<option value="diamond" {{ $pelanggan->status_member === 'Diamond' ? 'selected' : '' }} >Diamond</option>
</select>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="reset" class="btn btn-secondary" data-dismiss="modal">Reset</button>
<button type="submit" class="btn btn-primary">Update Data</button>
</div>
</form>
</div>
</div>
</div>
#endforeach
this is the route
Route::put('daftar_pelanggan/update/{id}', '\App\Http\Controllers\DaftarPelangganController#update')->name('daftar_pelanggan.update');
and this is the controller
public function update(Request $request, $id)
{
$update_pelanggan = DaftarPelanggan::find($id);
$update_pelanggan->nama_pelanggan = $request->updateNamaPelanggan;
$update_pelanggan->alamat = $request->updateAlamat;
$update_pelanggan->no_telp = $request->updateNoTelp;
$update_pelanggan->poin = $request->updatePoin;
$update_pelanggan->status_member = $request->updateKategori;
$update_pelanggan->save();
if($simpan){
Alert::success(' Berhasil Tambah data ', ' Silahkan dicek kembali');
}else{
Alert::error('data gagal disimpan ', ' Silahkan coba lagi');
}
return redirect()->back();}
what's wrong with this code ?
You have named the select control as status_member in the form while you are using $request->updateKategori in controller method/action while saving update data.
You can cross check by dd($request->all()) as first line of the update method and check which key value pairs are available as request data.
Change the update method like
public function update(Request $request, $id)
{
$update_pelanggan = DaftarPelanggan::findOrFail($id);
$update_pelanggan->nama_pelanggan = $request->updateNamaPelanggan;
$update_pelanggan->alamat = $request->updateAlamat;
$update_pelanggan->no_telp = $request->updateNoTelp;
$update_pelanggan->poin = $request->updatePoin;
//name of key $request->status_member must match name=status_member on select control in the form
$update_pelanggan->status_member = $request->status_member;
$update_pelanggan->save();
//------------- OR you can simply do ---------------------------//
//$update_pelanggam = DaftarPelanggan::findOrFail($id);
//$update_pelaggan->update($request->all();
//-------------------------------------------------------------//
if($simpan){
Alert::success(' Berhasil Tambah data ', ' Silahkan dicek kembali');
}else{
Alert::error('data gagal disimpan ', ' Silahkan coba lagi');
}
return redirect()->back();
}
I'm trying to bind multiple single select lists to one list of strings in my view model I have the property: public List<string> Items {get; set;} and in my view I have 3 select lists with single select option, but when I try to model bind my select list to Items property using asp-for="#Model.Items" all my single select lists converts to multi select lists. Why?
My view:
<form asp-controller="Admin" asp-action="Index" method="post">
<div class="col-12">
<div class="row">
<div class="form-group col-4">
<div class="d-inline-block">
<label>Order By Price:</label>
</div>
<div class="d-inline-block">
<select class="form-control" asp-for="#Model.Items" style="width:150px">
<option value="Ascending">Ascending</option>
<option value="Descending">Descending</option>
</select>
</div>
</div>
<div class="form-group col-4">
<div class="d-inline-block">
<label>Order By Name:</label>
</div>
<div class="d-inline-block">
<select class="form-control" asp-for="#Model.Items" style="width:150px">
<option value="A-Z">A-Z</option>
<option value="Z-A">Z-A</option>
</select>
</div>
</div>
<div class="form-group">
<div class="d-inline-block">
<button type="submit" class="btn btn-secondary">Confirm</button>
</div>
</div>
</div>
</div>
</form>
Controller:
[HttpPost]
public IActionResult Index(MangeProductsViewModel vm)
{
return View(new MangeProductsViewModel
{
Products = productRepository.Products.ToList().SortProducts(vm)
});
}
My viewmodel
public IEnumerable<Product> Products { get; set; }
public List<string> Items { get; set; }
And when I select items from lists it adds them correctly the problem is dat user can select multiple options from one list
That's because asp-for invokes a tag helper, and for a prop of type List<string>, the HTML that is generated is going to be a select multiple. However, this wouldn't work for you anyways as it would give all the selects the same name. As a result, they'll simply overwrite each other, not add to each other.
For this, you're going to have to handle things manually via:
<select name="Items[]">
#foreach (var option in Model.SelectList1Options)
{
<option value="#option.Value">#option.Text</option>
}
</select>
For each drop down.
Try this!
In your HttpGet method create a new list with length 3 and assign it to Items property of model and pass the model to view.
And in view write asp-for as follows
asp-for=“#Model.Items[0]”
asp-for=“#Model.Items[1]”
asp-for=“#Model.Items[2]”
The reason is that you have used asp-for="#Model.Items", sicne your item is type of List<string>, so the dropdown list is set as multiple select.
Just use name="Items" instead:
<form asp-controller="Managers" asp-action="SelectTest" method="post">
<div class="col-12">
<div class="row">
<div class="form-group col-4">
<div class="d-inline-block">
<label>Order By Price:</label>
</div>
<div class="d-inline-block">
<select class="form-control" name="Items" style="width:150px">
<option value="Ascending">Ascending</option>
<option value="Descending">Descending</option>
</select>
</div>
</div>
<div class="form-group col-4">
<div class="d-inline-block">
<label>Order By Name:</label>
</div>
<div class="d-inline-block">
<select class="form-control" name="Items" style="width:150px">
<option value="A-Z">A-Z</option>
<option value="Z-A">Z-A</option>
</select>
</div>
</div>
<div class="form-group">
<div class="d-inline-block">
<button type="submit" class="btn btn-secondary">Confirm</button>
</div>
</div>
</div>
</div>
</form>
Result:
I have a VueJS component which populates a table via ajax, than I have a modal form inside component which creates new entries in table.
On modal hide I want to update the table to show new entries.
export default {
created() {
axios.get('/api/v1/customers')
.then(response => {
this.customers = response.data;
});
},
methods: {
store() {
this.form.errors = [];
axios.post('/api/v1/customers', this.form)
.then(response => {
this.form.name = '';
this.form.scopes = [];
this.form.errors = [];
$('#modal-edit-client').modal('hide');
this.$forceUpdate();
})
.catch(error => {
console.log(error)
/*if (typeof error.response.data === 'object') {
this.form.errors = _.flatten(_.toArray(error.response.data));
} else {
this.form.errors = ['Something went wrong. Please try again.'];
}*/
});
},
newUser: function () {
$('#modal-edit-client').modal('show');
},
edit: function () {
alert('edit modal')
}
},
data() {
return {
customers: {},
alert: {
show: false,
type: null,
title: null,
message: null,
},
form: {
scopes: [],
errors: []
}
};
}
}
I tried to use $forceUpdate() but does not seems to work
output template
<template>
<div class="row" v-cloak>
<div class="col-md-12 ">
<div class="panel panel-default custom-panel">
<div class="panel-heading">
<strong>Customers</strong>
<div id="custom-search-input">
<div class="input-group col-md-12">
<input v-on:keyup.enter="filter" type="text" class="form-control input-sm" placeholder="Search Customer" />
<span class="input-group-btn">
<button class="btn btn-info btn-lg" type="button">
<i class="glyphicon glyphicon-search"></i>
</button>
</span>
</div>
</div>
<a class="btn icon-btn btn-success" id="new__item" href="#" #click="newUser">
<span class="glyphicon btn-glyphicon glyphicon-plus img-circle text-success"></span> Add Customer
</a>
</div>
<div class="panel-body">
<table class="table table-condensed">
<tbody>
<tr>
<th style="width: 10px">#</th>
<th>Firma</th>
<th>Strasse</th>
<th>PLZ</th>
<th>Ort</th>
<th>Tel</th>
<th>Status</th>
<th>Actions</th>
</tr>
<tr v-for="customer in customers">
<td>{{ customer.id }}</td>
<td>{{ customer.customer_name }}</td>
<td>{{ customer.customer_street }}</td>
<td>{{ customer.customer_plz }}</td>
<td>{{ customer.customer_city }}</td>
<td>{{ customer.customer_telephone }}</td>
<td><span class="badge bg-green"><i class="fa fa-check"></i></span></td>
<td class="actions">
<i class="fa fa-pencil"></i>
<i class="fa fa-trash"></i>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- Edit Client Modal -->
<div class="modal fade" id="modal-edit-client" tabindex="-1" role="dialog">
<div class="spinner"></div>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button " class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">
Add Customer
</h4>
</div>
<div class="modal-body">
<!-- Form Errors -->
<!--<div class="alert alert-danger" v-if="alert" >
<p><strong>Whoops!</strong> Something went wrong!</p>
<br>
</div>-->
<!-- Edit Client Form -->
<form class="form-horizontal" id="modal-create-customer" role="form" method="POST" action="">
<div class="row">
<div class="col-xs-12">
<label for="customer_name" class="control-label">Firmenbezeichnung</label>
<input id="customer_name" type="text" class="form-control" v-model="form.customer_name" name="customer_name" value="" required autofocus>
<span class="help-block">
<strong></strong>
</span>
</div>
<div class="col-xs-6">
<label for="sex" class="control-label">Anrede</label>
<select v-model="form.customer_contact_sex" name="title" id="sex" class="form-control">
<option value="Herr">Herr</option>
<option value="Frau">Frau</option>
</select>
<span class="help-block">
<strong></strong>
</span>
</div>
<div class="col-xs-6">
<label for="title" class="control-label">Title</label>
<select v-model="form.customer_contact_title" name="title" id="title" class="form-control">
<option value="">No title</option>
<option value="Dr.">Dr.</option>
<option value="Prof.">Prof.</option>
</select>
<span class="help-block">
<strong></strong>
</span>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<label for="name" class="control-label">First Name</label>
<input id="name" type="text" class="form-control" v-model="form.customer_first_name" name="customer_name" value="" required autofocus>
<span class="help-block">
<strong></strong>
</span>
</div>
<div class="col-xs-6">
<label for="email" class="control-label">Last Name</label>
<input id="email" type="text" class="form-control" v-model="form.customer_last_name" name="customer_last_name" value="" required>
<span class="help-block">
<strong></strong>
</span>
</div>
<div class="col-xs-6">
<label for="street" class="control-label">Street</label>
<input id="street" type="text" class="form-control" v-model="form.customer_street" name="customer_street" value="" required>
<span class="help-block">
<strong></strong>
</span>
</div>
<div class="col-xs-2">
<label for="plz" class="control-label">PLZ</label>
<input id="plz" type="text" class="form-control" v-model="form.customer_plz" name="customer_plz" value="" required>
<span class="help-block">
<strong></strong>
</span>
</div>
<div class="col-xs-4">
<label for="city" class="control-label">City</label>
<input id="city" type="text" class="form-control" v-model="form.customer_city" name="customer_city" value="" required>
<span class="help-block">
<strong></strong>
</span>
</div>
<div class="col-xs-6">
<label for="customer_telephone" class="control-label">Tel.</label>
<input id="customer_telephone" type="text" class="form-control" v-model="form.customer_telephone" name="customer_telephone" value="" required>
<span class="help-block">
<strong></strong>
</span>
</div>
<div class="col-xs-6">
<label for="customer_fax" class="control-label">Fax.</label>
<input id="customer_fax" type="text" class="form-control" name="customer_fax" value="" required>
<span class="help-block">
<strong></strong>
</span>
</div>
<div class="col-xs-6">
<label for="customer_mobile" class="control-label">Mobil</label>
<input id="customer_mobile" type="text" class="form-control" name="customer_mobile" value="" required>
<span class="help-block">
<strong></strong>
</span>
</div>
<div class="col-xs-6">
<label for="customer_email" class="control-label">E-Mail.</label>
<input id="customer_email" type="text" class="form-control" name="customer_email" value="" required>
<span class="help-block">
<strong></strong>
</span>
</div>
<div class="col-xs-12">
<label for="customer_note" class="control-label">Notiz</label>
<textarea name="csutomer_note" id="customer_note" class="form-control"></textarea>
<span class="help-block">
<strong></strong>
</span>
</div>
</div>
</form>
</div>
<!-- Modal Actions -->
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" #click="store">
Register
</button>
</div>
</div>
</div>
</div>
</div>
</template>
As said in the comments, your code looks fine except that you're not actually updating the customers property with anything.
When you're performing the XHR request with Axios, you need to use the response to populate the component, which will automatically update the relevant DOM.
Here is the relevant part of your code that you should modify:
axios.post('/api/v1/customers', this.form)
.then(response => {
this.form.name = '';
this.form.scopes = [];
this.form.errors = [];
// Set the component's customers property to what you get
// in the response
this.customers = response.data.customers;
$('#modal-edit-client').modal('hide');
// You don't need to forceUpdate as Vue will take care of
// rerendering the relevant parts of the DOM
// this.$forceUpdate();
})
Also, considering you're expecting an array of customers to render the table, you should set the customers default value accordingly:
data() {
return {
customers: []
// ...
};
}