php - laravel route any page in a folder -
i trying route blade file inside folder called "pages" (application/views/pages/page.blade.php)
$path = '/pages/'.$anyname.'.blade.php'; route::get('file/(:all)', function($path){}); how should change $anyname enable retrieve blade file?
i got working using scandir method.
$dir = path('app').'/views/pages/'; $pages = scandir($dir); unset($pages[array_search('.', $pages)]); unset($pages[array_search('..', $pages)]); for($i = 2; $i <count($pages)+2; $i++){ //print_r($pages[$i]); $temp = str_replace('.blade.php', '', $pages[$i]); route::get($temp, function(){ //return view::('index'); return 'asd'; }); }
Comments
Post a Comment