Download the PHP package surya/laravel-settings without Composer
On this page you can find all versions of the php package surya/laravel-settings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download surya/laravel-settings
More information about surya/laravel-settings
Files in surya/laravel-settings
Package laravel-settings
Short Description A laravel package for manage your app settings
License MIT
Informations about the package laravel-settings
Laravel Settings
A laravel package for manage your app settings
Installation
This package require laravel 5.5 or higher, if your current version of laravel is below 5.5 you could install this package but it isn't tested at all.
Register the ServiceProvider in config/app.php
Also register the Facade Alias
Publish migration table
Migrate
Usage
By default the folder that use for store our setting is located in resources/settings
, so you must create settings
folder by your self.
Creating Setting File
Let's create setting file call general.php
the filename of setting also refer to group, used for getting setting value and prop the setting file only containts an array of setting properties. the
site_name
is the key of the setting.
available setting properties:
- type => the type of the setting, basically the input tag e.g: text, textarea, select, number, etc.
- default => the default value of the setting.
- label => the setting label.
- options => this specific for type select and radio only.
Rendering Setting File
After the setting file was created. You can render the setting file by using blade directive
the
@rendersettings
directive doesn't include the form tag, so you should render your setting between form tag
All the setting type are bootstrap friendly so it will adapt to your bootstrap theme.
Saving Your Setting
You can simply use facade to saving settings
Play With Value
Getting Setting Value
There's three diffrent ways to getting setting value. use the directive
use the helper function
use the facade class
getting setting propperty
or
checking if setting exists
or
Modify Setting Type
You still has control for modify each of setting type or adding new setting type.
publish setting types view
as you can see in resources/view/vendor/setting/settings
each setting type
view has exact name of type
property, so if you want additional setting type just add another view file.
for example if you want create setting that accept email
all properties for each setting key are automatically passed. save as
email.blade.php
and it's automatically recognized as email setting type.
New In 1.2.+
You can now add resource key for select setting type
for example, if you want select a primary user from database
There are 3 new keys, source
is the model source show_label
model property key
if your model primary key is id
just leave it empty.
currently the source key only work for
select
setting type
New in 1.2.1
New switch
setting type.
in order to use switch use must include bootstrap otherwise you will get normal checkbox input
Now the setting type check
can use options
key
All versions of laravel-settings with dependencies
illuminate/container Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0|~6.0.0
illuminate/database Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0|~6.0.0