Hi, yes you can solve this using a recursive method call, so you can split your $n variable
$value = Auth::user();
$n = 'settings->notifications->comments'
foreach (explode('->',$n) as $property) {
$value = get_nested_property($property, $value);
}
function get_nested_property($property, $object) {
return $object->{$property};
}
you should get exactly what you want, but you can improve the logic, as a start i would not use -> to separate the properties, maybe a dot.
and then you should look up the php array dot notation it is used in laravel to access the config, it should give a good idea how you need to build your app.