add setting() helper; fix invalid defaults for mysql in table
This commit is contained in:
parent
3a22062cd2
commit
f2add8908b
@ -35,10 +35,10 @@ class SettingsController extends BaseController
|
||||
*/
|
||||
public function update(Setting $setting, Request $request)
|
||||
{
|
||||
$/*this->validate($request, Setting::$rules, Setting::$messages);
|
||||
/*$this->validate($request, Setting::$rules, Setting::$messages);
|
||||
$this->updateEntry($setting, $request->all());*/
|
||||
|
||||
return redirect("/admin/settings");
|
||||
return redirect('/admin/settings');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class Migration extends MigrationBase
|
||||
try {
|
||||
DB::table($table)->insert($row);
|
||||
} catch (Exception $e) {
|
||||
# setting already exists
|
||||
# setting already exists, just ignore it
|
||||
if ($e->getCode() === 23000) {
|
||||
continue;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use App\Repositories\SettingRepository;
|
||||
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
@ -15,6 +16,8 @@ class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
Schema::defaultStringLength(191);
|
||||
|
||||
$this->app->bind('setting', SettingRepository::class);
|
||||
|
||||
//\VaCentral\VaCentral::setVaCentralUrl(config('phpvms.vacentral_api_url'));
|
||||
if(!empty(config('phpvms.vacentral_api_key'))) {
|
||||
\VaCentral\VaCentral::setApiKey(config('phpvms.vacentral_api_key'));
|
||||
|
32
app/Repositories/SettingRepository.php
Normal file
32
app/Repositories/SettingRepository.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Repositories\Traits\CacheableRepository;
|
||||
use Prettus\Repository\Contracts\CacheableInterface;
|
||||
|
||||
class SettingRepository extends BaseRepository implements CacheableInterface
|
||||
{
|
||||
use CacheableRepository;
|
||||
|
||||
public function model()
|
||||
{
|
||||
return Setting::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a setting, reading it from the cache
|
||||
* @param array $key
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function set($key, $value)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
16
app/Support/helpers.php
Normal file
16
app/Support/helpers.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Shortcut for retrieving a setting value
|
||||
*/
|
||||
if (!function_exists('setting')) {
|
||||
function setting($key, $value = null)
|
||||
{
|
||||
$settingRepo = app('setting');
|
||||
if($value === null) {
|
||||
return $settingRepo->get($key);
|
||||
} else {
|
||||
$settingRepo->set($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
@ -63,6 +63,9 @@
|
||||
"bpocallaghan/generators": "5.0.1"
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"app/Support/helpers.php"
|
||||
],
|
||||
"classmap": [
|
||||
"database"
|
||||
],
|
||||
|
@ -15,11 +15,11 @@ class CreateSettingsTable extends Migration
|
||||
Schema::create('settings', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('order')->default(1);
|
||||
$table->string('name')->default('');
|
||||
$table->string('name');
|
||||
$table->string('key');
|
||||
$table->string('value');
|
||||
$table->string('group')->default('general');
|
||||
$table->text('type')->default('text');
|
||||
$table->string('group')->nullable();
|
||||
$table->text('type')->nullable();
|
||||
$table->text('options')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
|
Loading…
Reference in New Issue
Block a user