Welcome Guest, Not a member yet? Register   Sign In
return value of settings helper call?
#9

The forum search capability was removed from the Settings helper because it was not being used very often, and it was difficult to maintain. If you need to search the forum, you can use the search bar at the top of the page.

The set() method in the Settings helper does not return a boolean on success/fail. This is because it is not always possible to determine if the setting was successfully updated. For example, if the setting is already set to the value that you are trying to set it to, the method will not return an error, but it will also not return a success message.

Whether or not this is a problem depends on how you are using the Settings helper. If you are using it to set settings that are critical to the operation of your application, then you may want to add your own code to check if the setting was successfully updated. However, if you are using it to set settings that are not critical, then you may not need to worry about it.

If you think that this would be a useful feature, then you can create a feature request on the Laravel GitHub repository.

Here is an example of how to check if the setting was successfully updated:

PHP
$setting = $settings->get('my_setting');

if ($settings->set('my_setting', 'new_value') !== $setting) {
// The setting was not successfully updated.
}

This code will check if the value of the my_setting setting has changed after calling the set() method. If it has not changed, then the setting was not successfully updated.
Reply


Messages In This Thread
RE: return value of settings helper call? - by [email protected] - 10-25-2023, 09:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB