Download the PHP package utyemma/larasetting without Composer
On this page you can find all versions of the php package utyemma/larasetting. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download utyemma/larasetting
More information about utyemma/larasetting
Files in utyemma/larasetting
Package larasetting
Short Description Quick and easy app settings for laravel applications
License MIT
Informations about the package larasetting
LaraSettings
Description
LaraSettings is a Laravel package that simplifies the management of application settings. It provides a structured and extensible way to define, retrieve, and update settings stored in the database. It includes useful commands for generating and seeding settings classes, making it easy to customize for various use cases.
Table of Contents
- Requirements
- Installation
- Usage
- Defining a Settings Class
- Seeding Settings
- Retrieving and Updating Settings
- Strict Mode
- Contributing
- Maintainers
- License
Requirements
- PHP 8.0+
- Laravel 9.0+
Installation
-
Install the package via Composer:
-
Publish the migration file:
- Run the migrations to create the
settingstable:
Usage
Defining a Settings Class
Use the make:setting command to create a new settings class:
This will generate a new settings class in the App\Settings namespace. Define your options, labels, and casts within the class to tailor it to your application's needs.
Seeding Settings
To seed settings into the database, use the settings:seed command:
Replace ExampleSettings with the name of your settings class. This will populate the database with the default attributes and values defined in the class.
Retrieving and Updating Settings
You can interact with settings using dynamic property access or methods:
Retrieving a Setting
Updating a Setting
Bulk Updating Settings
Fetching All Settings
Strict Mode
LaraSettings operates in strict mode by default. Strict mode ensures that only settings defined in the options array of a settings class can be updated or created. This prevents accidental changes to undefined settings. When enabled, attempting to update an undefined setting will throw an exception. Ensure that all valid keys are listed in the options array of your settings class.
Disabling Strict Mode
If you want to allow dynamic creation of settings that are not predefined in the options array, you can set the $strict property to false in your settings class:
Contributing
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch.
- Submit a pull request.
Maintainers
- Utibe-Abasi Emmanuel (GitHub)
License
This package is open-sourced software licensed under the MIT license.