Let's say I have a folder like this
resources/views
paths
path1
index.blade.php
registration.blade.php
path2
index.blade.php
registration.blade.php
And my route
Route::get('/paths/{$path}, function(){
return view('paths/{$path}/index);
});
This doesnt work if I do this
localhost.com/paths/path1
Any Idea how make it work? Doing this in controller is more preferred.
Ok I already fixed that in closure before train_fox answered. I preferred that in controller
public function index(Request $request, $path)
{
$paths = [
'CD1',
'CD2',
'CD3',
];
foreach($paths as $path){
if($path === request()->segment()){
return $this->paths = $path;
}
}
return view('paths/'.$this->path.'/index');
}
Any ideas?