I'm trying to build routes from a model below is the code.
$data = \App\Models\ModelName::all();
if(!empty($data) && $data->count() >= 1)
{
foreach($data as $d)
{
Route::prefix('/'.$d['data_field'])->name($d['data_field'])->group(function(){
Route::get('/', ucfirst($d['data_field']).'Controller@index');
});
}
}
I kept getting the error message that $d is not defined. Is there a way to build the routes dynamically?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire