Download the PHP package geniusts/preferences without Composer
On this page you can find all versions of the php package geniusts/preferences. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download geniusts/preferences
More information about geniusts/preferences
Files in geniusts/preferences
Package preferences
Short Description Very easy way to generate a preferences page for applications that have multiple components and packages.
License MIT
Informations about the package preferences
Preferences page for Laravel
This package to generate a preferences page to the application, specially if you have many component that have a different settings and you want to store it in the database and use it by default config functions of laravel.
- Installation
- Usage
- License
Installation
-
Download the package
- command line:
composer require geniusts/preferences
- or add it to composer file:
and run:
composer update
- Service Provider
- If you are using Laravel >=5.5 and the
auto-discover
is enabled, no need to do anything. - If your Laravel <5.5 or you disabled
auto-discover
add the ServiceProvider to the providers array inconfig/app.php
Note: If you are using Laravel 5.5 or greater no need to add it, It will auto discove
- Controller And Migrations
Publish the package Controller file to your application. Run these commands:
php artisan vendor:publish --provider="GeniusTS\Preferences\PreferencesServiceProvider" --tag=controller
You can also publish views and migrations by the following commands:
php artisan vendor:publish --provider="GeniusTS\Preferences\PreferencesServiceProvider" --tag=views
php artisan vendor:publish --provider="GeniusTS\Preferences\PreferencesServiceProvider" --tag=migrations
No need to publish the migrations files just run migrate command to execute the migrations.
php artisan migrate
If you want to use
DB
transaction while saving the data, addprotected $transactions = true;
toSettingsController
.
- Routes and views
Add two routes to you routes file:
Route::get('/settings/{preferences_domain?}', 'SettingsController@edit')
->midllware(//Apply your middleware)
Route::patch('/settings/{preferences_domain?}/{preferences_element?}', 'SettingsController@update')
->midllware(//Apply your middleware)
Now you have to create a preferences.settings
view with your app layout
and include the geniusts_preferences::settings
view.
@include('geniusts_preferences::settings');
Usage
Creating settings tab
-
create a view of the settings: Ex.:
settings/general.blade.php
- Register the tab to PreferencesManager
You can register the
domains
in theboot
function of your package service provider.
Access saved settings
Use the default config
function or Config
class to get the values of
your settings: config('preferences.{domain}.{element}')
Migration from version 1
-
update inputs name inside preferences views. Ex: You have a
general
domain that haveproject_name
element, then the input name should begeneral[project_name]
. - Update declaration of
edit
andhandleSuccessResponse
methods ofSettingsController
inside your project.
License
This package is free software distributed under the terms of the MIT license.
All versions of preferences with dependencies
illuminate/database Version >=5.2
illuminate/routing Version >=5.2
illuminate/view Version >=5.2
doctrine/dbal Version ^2.5|3.*