I have a problem with the project I'm working on, so I have 3 relation tables ie ms_customers, ms_sim_rs, and ms_cus_sim_rs where the final input goes to the ms_cus_sim_rs table with each of the captured data is ID.
Then, how to edit data when it can display all data from ms_sim_rs but the ID of ms_sim_rs that has entered into table ms_cus_sim_rs still appear in table but with checkbox condition checked, and if id not in table ms_cus_sim_rs checkbox not checked.
Sorry my English is not good.
above is the blade view of edit.blade.php. And for controller take data in table as follows:
$result = DB::table('ms_sim_rs')
->leftjoin('ms_cus_sim_rs','ms_cus_sim_rs.sim_rs_id','=','ms_sim_rs.id')
->leftjoin('ms_customers','ms_customers.id','=','ms_cus_sim_rs.customer_id')
->select('ms_sim_rs.id as sim_rs_id','ms_sim_rs.rs_no','ms_sim_rs.rs_name','ms_cus_sim_rs.customer_id','ms_customers.customer_name')
->get();
my blade code to edit:
<table class="table table-striped"
id="table"
data-toggle="table"
data-click-to-select="true"
data-toolbar="#toolbar">
<thead>
<tr>
<th data-field="delete" data-checkbox="true" class="col-sm-1"></th>
<th data-field="sim_rs_id" data-visible="true" class="text-center" style="display:none;" id="cek">ID</th>
<th data-field="rs_name" data-sortable="true" class="text-center col-sm-5">Name</th>
<th data-field="rs_no" data-sortable="true" class="text-center col-sm-5">RS.Number</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<script>
$.ajax({
type: "GET",
url:"/api/get-all-sim",
dataType : "text",
headers: {
"Accept": "application/json",
"Cache-Control": "no-cache",
"Authorization": "Bearer " + window.user_token
},
success: function( data ){
var sim_data = JSON.parse(data);
$('#table').bootstrapTable('load', sim_data);
},
error: function( data ){
var result = JSON.parse(data);
console.log( result );
}
});
</script>
this is the data that already exists in the table ms_cus_sim_rs, how to sim_rs_id existing order based on the customer still appear on blade view but with checkbox checkbox.
Help me please ... and thanks for the help
Aucun commentaire:
Enregistrer un commentaire