Welcome Guest, Not a member yet? Register   Sign In
Preferences Library
#1

Hi all- With the advent of the official "CodeIgniter Settings" library (https://github.com/codeigniter4/settings) I've decided to deprecate my popular Settings library (https://github.com/tattersoftware/codeigniter4-settings) due to the significant overlap in name, features, and functionality. The biggest feature gap this leaves, however, is providing user-specific settings handling (e.g. allowing authenticated users to change their profile picture or set a theme). To fill this gap, I give you:
Tatter\Preferences
Persistent user-specific settings for CodeIgniter 4
https://github.com/tattersoftware/codeig...references
https://packagist.org/packages/tatter/preferences
"Preferences" builds on "CodeIgniter Settings" and your authentication-library-of-choice to provide contextual settings for the authenticated user. Similar to Settings, there is a convenient helper function to turn this into a very easy set/get call. Here's a simplistic example of using dynamic themes for your users:
PHP Code:
class Home extends Controller
{
    public function index()
    {
        return view('welcome', [
            'theme' => preference('theme'),
        ];
    }

    public function update_theme()
    {
        if ($theme $this->request->getPost('theme')) {
            prefernece('theme'$theme);
        }

        return redirect()->back();
    }

As always, drop a comment here or stop by the repo with feature requests or feedback of any kind! Thanks for reading.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB