I have a dependent dropdown, based on a previous selection, but the actual request doesn't appear to be sending any ID to the controller (to return data for the dependent dropdown).
When I select an option from the first dropdown, the Ajax request is triggered (I can see that the network request for the Ajax is correct):
http://ift.tt/2kU7a99
But it returns [].
Route:
Route::get('sites', 'AdminController@getSites')->name('getSites');
Method that returns the data:
public function getSites(Request $request)
{
$this->validate($request, [
'trust_id' => 'required|numeric',
]);
$trust_id = $request->get('$trust_id');
$sites = Site::where('trust_id', $trust_id)->get(['id', 'name']);
return $sites;
}
If I hard code trust_id, it returns the correct data, but if I request the data, I always get null - http://ift.tt/2kU7a99
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lCmpn0
via IFTTT
Aucun commentaire:
Enregistrer un commentaire