1. Go to this page and download the library: Download samchentw/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/ */
samchentw / settings example snippets
// routes/web.php
use Samchentw\Settings\Helpers\RouterHelper;
RouterHelper::loadWebRoutes();
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Samchentw\Settings\Contracts\SettingManager;
class SettingController extends Controller
{
private $settingManager;
public function __construct(SettingManager $SettingManager)
{
$this->settingManager = $SettingManager;
}
function getSettings(Request $request)
{
return $this->settingManager->getByKey('example.title');
}
}
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Samchentw\Settings\Contracts\SettingManager;
class SettingController extends Controller
{
private $settingManager;
public function __construct(SettingManager $SettingManager)
{
$this->settingManager = $SettingManager;
}
function getSettings(Request $request)
{
return $this->settingManager->getByKey('test.boolean');
}
}
use App\YourNameSpace\MySetting;
use Samchentw\Settings\Contracts\SettingManager;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
app()->singleton(
SettingManager::class,
MySetting::class
);
use Samchentw\Settings\Contracts\SettingManager;
use Samchentw\Settings\Models\Setting;
class MySetting implements SettingManager
{
public function getByKey(string $key, $provider_name = '', $provider_key = null)
{
//your code....
}
//your code....
sh
$ php artisan migrate
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.