thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.75k stars 2.67k forks source link

Settings cache works incorrect when more than one dot in key #4614

Open nixprosoft opened 4 years ago

nixprosoft commented 4 years ago

Version information

Description

A clear and concise description of what the bug is.

Steps To Reproduce

Steps to reproduce the behavior:

  1. If settings key have more than one dot like this: image You will get this in <?php dump(settings('site')); ?> image And you cannot access <?php dump(settings('site.yandex.metrika')); ?> for example.

Expected behavior

<?php dump(settings('site.yandex.metrika')); ?> must return value of site.yandex.metrika key.

MrCrayon commented 4 years ago

There should be a check that doesn't let you use dots in key names.

Using dots is a problem because when you send: <input name="site.contacts.phone"> this gets automatically changed from Laravel => Symfony => PHP to: site_contacts_phone since dots are not allowed in variable names.

This would lead to unespected behaviour if you have both site.contacts.phone and site.contacts_phone.

Solution Use underscore notation for key names.

P.S. You can dd($request->all()) after sending something with a dot in name and see the result.