Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| LegacySettingProxy | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| __get | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| __isset | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Support; |
| 4 | |
| 5 | /** |
| 6 | * Backward-compat for `setting()->name`, `setting()->logo`, `setting()->phone1`… |
| 7 | * used by older blades. Maps the legacy column names onto the unified |
| 8 | * settings() store. Remove once every call site uses settings('group.key'). |
| 9 | */ |
| 10 | class LegacySettingProxy |
| 11 | { |
| 12 | private const MAP = [ |
| 13 | 'name' => 'general.site_name', |
| 14 | 'logo' => 'general.logo', |
| 15 | 'favicon' => 'general.favicon', |
| 16 | 'phone1' => 'contact.phone_primary', |
| 17 | 'phone2' => 'contact.phone_secondary', |
| 18 | 'email' => 'contact.email', |
| 19 | 'address' => 'contact.address', |
| 20 | 'wp' => 'contact.whatsapp', |
| 21 | 'fb' => 'social.facebook', |
| 22 | 'instagram' => 'social.instagram', |
| 23 | 'youtube' => 'social.youtube', |
| 24 | 'twitter' => 'social.twitter', |
| 25 | ]; |
| 26 | |
| 27 | public function __get(string $name): mixed |
| 28 | { |
| 29 | return isset(self::MAP[$name]) ? settings(self::MAP[$name]) : null; |
| 30 | } |
| 31 | |
| 32 | public function __isset(string $name): bool |
| 33 | { |
| 34 | return isset(self::MAP[$name]) && settings(self::MAP[$name]) !== null; |
| 35 | } |
| 36 | } |