1. Go to this page and download the library: Download poseso/laravel-settings library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
poseso / laravel-settings example snippets
settings(['foo' => 'bar']);
settings('foo');
// the same:
settings()->set('foo', 'bar');
settings()->get('foo');
namespace App\Http\Controllers;
use Poseso\Settings\Contracts\RepositoryContract as Settings;
class MyController extends Controller
{
public function index(Settings $settings)
{
$value = $settings->get('foo');
}
}
Settings::has('foo');
Settings::get('foo');
// You can specify a default value when an property is null or not found:
Settings::get('foo', 'default');
$user->settings()->set('lang', 'en');
$user->settings()->get('lang');
// the same:
$user->settings(['lang' => 'en']);
$user->settings('lang');
use Poseso\Settings\Trait\HasSettings;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use HasSettings;
protected $settingsConfig = [
'default' => [
'timezone' => 'UTC'
]
];
// ...
}