Hi, I'm trying to pass a PHP variables from controller to modal direct. First I have the blade view (index) which have datatable inside it, (index) blade lunched by function index() method.
Once I click on one user of DataTable, A modal will shown with the PHP variables about this user, and I want to get the data by PHP as well.
all_data.blade.php
<button id="create_new_lead" data-toggle="modal" data-target="#exampleModal" class="btn btn-info btn-lg">New Lead </button>
Controller:
function index ()
{
$id = 222;
$info = Info::find($id);
$details = Detail::find($id);
$others = Other::find($id);
return view('all_data')->with('info', $info)->with('details', $details)->with('others', $others);
}
My model:
<div id="exampleModal" class="modal fade exampleModal-xl modal-lead" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
@foreach($info as $info_in)
{{$info->name}}
@endforeach
@foreach($details as $details_in)
{{$details_in->description}}
@endforeach
@foreach($others as $others_in)
{{$others_in->age}}
@endforeach
</div>
</div>
</div>
So, once I click on the button, I want to change the ID value in controller or by any other way, so I can ensure that the modal will show the new values. Is there another way to pass values from controller to modal, but the PHP values in modal should be in PHP, not JS to handle some operations on them later inside the modal. Any suggestion.
Another question, Is there away to open the modal by ajax, and get the values inside the modal from controller and pass them as PHP values, but sure not handle them inside modal as JS. ??