We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -7,63 +7,63 @@ |
||
7 | 7 | |
8 | 8 | class SettingsTableSeeder extends Seeder |
9 | 9 | { |
10 | - /** |
|
11 | - * The settings to add. |
|
12 | - */ |
|
13 | - protected $settings = [ |
|
14 | - [ |
|
15 | - 'key' => 'contact_email', |
|
16 | - 'name' => 'Contact form email address', |
|
17 | - 'description' => 'The email address that all emails from the contact form will go to.', |
|
18 | - 'value' => '[email protected]', |
|
19 | - 'field' => '{"name":"value","label":"Value","type":"email"}', |
|
20 | - 'active' => 1, |
|
21 | - ], |
|
22 | - [ |
|
23 | - 'key' => 'contact_cc', |
|
24 | - 'name' => 'Contact form CC field', |
|
25 | - 'description' => 'Email addresses separated by comma, to be included as CC in the email sent by the contact form.', |
|
26 | - 'value' => '', |
|
27 | - 'field' => '{"name":"value","label":"Value","type":"text"}', |
|
28 | - 'active' => 1, |
|
10 | + /** |
|
11 | + * The settings to add. |
|
12 | + */ |
|
13 | + protected $settings = [ |
|
14 | + [ |
|
15 | + 'key' => 'contact_email', |
|
16 | + 'name' => 'Contact form email address', |
|
17 | + 'description' => 'The email address that all emails from the contact form will go to.', |
|
18 | + 'value' => '[email protected]', |
|
19 | + 'field' => '{"name":"value","label":"Value","type":"email"}', |
|
20 | + 'active' => 1, |
|
21 | + ], |
|
22 | + [ |
|
23 | + 'key' => 'contact_cc', |
|
24 | + 'name' => 'Contact form CC field', |
|
25 | + 'description' => 'Email addresses separated by comma, to be included as CC in the email sent by the contact form.', |
|
26 | + 'value' => '', |
|
27 | + 'field' => '{"name":"value","label":"Value","type":"text"}', |
|
28 | + 'active' => 1, |
|
29 | 29 | |
30 | - ], |
|
31 | - [ |
|
32 | - 'key' => 'contact_bcc', |
|
33 | - 'name' => 'Contact form BCC field', |
|
34 | - 'description' => 'Email addresses separated by comma, to be included as BCC in the email sent by the contact form.', |
|
35 | - 'value' => '', |
|
36 | - 'field' => '{"name":"value","label":"Value","type":"email"}', |
|
37 | - 'active' => 1, |
|
38 | - ], |
|
39 | - [ |
|
40 | - 'key' => 'motto', |
|
41 | - 'name' => 'Motto', |
|
42 | - 'description' => 'Website motto', |
|
43 | - 'value' => 'this is the value', |
|
44 | - 'field' => '{"name":"value","label":"Value","type":"textarea"}', |
|
45 | - 'active' => 1, |
|
30 | + ], |
|
31 | + [ |
|
32 | + 'key' => 'contact_bcc', |
|
33 | + 'name' => 'Contact form BCC field', |
|
34 | + 'description' => 'Email addresses separated by comma, to be included as BCC in the email sent by the contact form.', |
|
35 | + 'value' => '', |
|
36 | + 'field' => '{"name":"value","label":"Value","type":"email"}', |
|
37 | + 'active' => 1, |
|
38 | + ], |
|
39 | + [ |
|
40 | + 'key' => 'motto', |
|
41 | + 'name' => 'Motto', |
|
42 | + 'description' => 'Website motto', |
|
43 | + 'value' => 'this is the value', |
|
44 | + 'field' => '{"name":"value","label":"Value","type":"textarea"}', |
|
45 | + 'active' => 1, |
|
46 | 46 | |
47 | - ], |
|
48 | - ]; |
|
47 | + ], |
|
48 | + ]; |
|
49 | 49 | |
50 | - /** |
|
51 | - * Run the database seeds. |
|
52 | - * |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function run() |
|
56 | - { |
|
57 | - foreach ($this->settings as $index => $setting) { |
|
58 | - $result = DB::table(config('backpack.settings.table_name'))->insert($setting); |
|
50 | + /** |
|
51 | + * Run the database seeds. |
|
52 | + * |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function run() |
|
56 | + { |
|
57 | + foreach ($this->settings as $index => $setting) { |
|
58 | + $result = DB::table(config('backpack.settings.table_name'))->insert($setting); |
|
59 | 59 | |
60 | - if (!$result) { |
|
61 | - $this->command->info("Insert failed at record $index."); |
|
60 | + if (!$result) { |
|
61 | + $this->command->info("Insert failed at record $index."); |
|
62 | 62 | |
63 | - return; |
|
64 | - } |
|
65 | - } |
|
63 | + return; |
|
64 | + } |
|
65 | + } |
|
66 | 66 | |
67 | - $this->command->info('Inserted '.count($this->settings).' records.'); |
|
68 | - } |
|
67 | + $this->command->info('Inserted '.count($this->settings).' records.'); |
|
68 | + } |
|
69 | 69 | } |
@@ -11,91 +11,91 @@ |
||
11 | 11 | |
12 | 12 | class SettingsServiceProvider extends ServiceProvider |
13 | 13 | { |
14 | - /** |
|
15 | - * Indicates if loading of the provider is deferred. |
|
16 | - * |
|
17 | - * @var bool |
|
18 | - */ |
|
19 | - protected $defer = false; |
|
14 | + /** |
|
15 | + * Indicates if loading of the provider is deferred. |
|
16 | + * |
|
17 | + * @var bool |
|
18 | + */ |
|
19 | + protected $defer = false; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Where the route file lives, both inside the package and in the app (if overwritten). |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - public $routeFilePath = '/routes/backpack/settings.php'; |
|
21 | + /** |
|
22 | + * Where the route file lives, both inside the package and in the app (if overwritten). |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + public $routeFilePath = '/routes/backpack/settings.php'; |
|
27 | 27 | |
28 | - /** |
|
29 | - * Perform post-registration booting of services. |
|
30 | - * |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public function boot() |
|
34 | - { |
|
35 | - // use the vendor configuration file as fallback |
|
36 | - $this->mergeConfigFrom( |
|
37 | - __DIR__.'/config/backpack/settings.php', |
|
38 | - 'backpack.settings' |
|
39 | - ); |
|
28 | + /** |
|
29 | + * Perform post-registration booting of services. |
|
30 | + * |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public function boot() |
|
34 | + { |
|
35 | + // use the vendor configuration file as fallback |
|
36 | + $this->mergeConfigFrom( |
|
37 | + __DIR__.'/config/backpack/settings.php', |
|
38 | + 'backpack.settings' |
|
39 | + ); |
|
40 | 40 | |
41 | - // define the routes for the application |
|
42 | - $this->setupRoutes($this->app->router); |
|
41 | + // define the routes for the application |
|
42 | + $this->setupRoutes($this->app->router); |
|
43 | 43 | |
44 | - // only use the Settings package if the Settings table is present in the database |
|
45 | - if (!\App::runningInConsole() && Schema::hasTable(config('backpack.settings.table_name'))) { |
|
46 | - // get all settings from the database |
|
47 | - $settings = Setting::all(); |
|
44 | + // only use the Settings package if the Settings table is present in the database |
|
45 | + if (!\App::runningInConsole() && Schema::hasTable(config('backpack.settings.table_name'))) { |
|
46 | + // get all settings from the database |
|
47 | + $settings = Setting::all(); |
|
48 | 48 | |
49 | - $config_prefix = config('backpack.settings.config_prefix'); |
|
49 | + $config_prefix = config('backpack.settings.config_prefix'); |
|
50 | 50 | |
51 | - // bind all settings to the Laravel config, so you can call them like |
|
52 | - // Config::get('settings.contact_email') |
|
53 | - foreach ($settings as $key => $setting) { |
|
54 | - $prefixed_key = !empty($config_prefix) ? $config_prefix.'.'.$setting->key : $setting->key; |
|
55 | - Config::set($prefixed_key, $setting->value); |
|
56 | - } |
|
57 | - } |
|
58 | - // publish the migrations and seeds |
|
59 | - $this->publishes([ |
|
60 | - __DIR__.'/database/migrations/create_settings_table.php.stub' => database_path('migrations/'.config('backpack.settings.migration_name').'.php'), |
|
61 | - ], 'migrations'); |
|
51 | + // bind all settings to the Laravel config, so you can call them like |
|
52 | + // Config::get('settings.contact_email') |
|
53 | + foreach ($settings as $key => $setting) { |
|
54 | + $prefixed_key = !empty($config_prefix) ? $config_prefix.'.'.$setting->key : $setting->key; |
|
55 | + Config::set($prefixed_key, $setting->value); |
|
56 | + } |
|
57 | + } |
|
58 | + // publish the migrations and seeds |
|
59 | + $this->publishes([ |
|
60 | + __DIR__.'/database/migrations/create_settings_table.php.stub' => database_path('migrations/'.config('backpack.settings.migration_name').'.php'), |
|
61 | + ], 'migrations'); |
|
62 | 62 | |
63 | - // publish translation files |
|
64 | - $this->publishes([__DIR__.'/resources/lang' => app()->langPath().'/vendor/backpack'], 'lang'); |
|
63 | + // publish translation files |
|
64 | + $this->publishes([__DIR__.'/resources/lang' => app()->langPath().'/vendor/backpack'], 'lang'); |
|
65 | 65 | |
66 | - // publish setting files |
|
67 | - $this->publishes([__DIR__.'/config' => config_path()], 'config'); |
|
68 | - } |
|
66 | + // publish setting files |
|
67 | + $this->publishes([__DIR__.'/config' => config_path()], 'config'); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Define the routes for the application. |
|
72 | - * |
|
73 | - * @param \Illuminate\Routing\Router $router |
|
74 | - * |
|
75 | - * @return void |
|
76 | - */ |
|
77 | - public function setupRoutes(Router $router) |
|
78 | - { |
|
79 | - // by default, use the routes file provided in vendor |
|
80 | - $routeFilePathInUse = __DIR__.$this->routeFilePath; |
|
70 | + /** |
|
71 | + * Define the routes for the application. |
|
72 | + * |
|
73 | + * @param \Illuminate\Routing\Router $router |
|
74 | + * |
|
75 | + * @return void |
|
76 | + */ |
|
77 | + public function setupRoutes(Router $router) |
|
78 | + { |
|
79 | + // by default, use the routes file provided in vendor |
|
80 | + $routeFilePathInUse = __DIR__.$this->routeFilePath; |
|
81 | 81 | |
82 | - // but if there's a file with the same name in routes/backpack, use that one |
|
83 | - if (file_exists(base_path().$this->routeFilePath)) { |
|
84 | - $routeFilePathInUse = base_path().$this->routeFilePath; |
|
85 | - } |
|
82 | + // but if there's a file with the same name in routes/backpack, use that one |
|
83 | + if (file_exists(base_path().$this->routeFilePath)) { |
|
84 | + $routeFilePathInUse = base_path().$this->routeFilePath; |
|
85 | + } |
|
86 | 86 | |
87 | - $this->loadRoutesFrom($routeFilePathInUse); |
|
88 | - } |
|
87 | + $this->loadRoutesFrom($routeFilePathInUse); |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * Register any package services. |
|
92 | - * |
|
93 | - * @return void |
|
94 | - */ |
|
95 | - public function register() |
|
96 | - { |
|
97 | - // register their aliases |
|
98 | - $loader = \Illuminate\Foundation\AliasLoader::getInstance(); |
|
99 | - $loader->alias('Setting', \Backpack\Settings\app\Models\Setting::class); |
|
100 | - } |
|
90 | + /** |
|
91 | + * Register any package services. |
|
92 | + * |
|
93 | + * @return void |
|
94 | + */ |
|
95 | + public function register() |
|
96 | + { |
|
97 | + // register their aliases |
|
98 | + $loader = \Illuminate\Foundation\AliasLoader::getInstance(); |
|
99 | + $loader->alias('Setting', \Backpack\Settings\app\Models\Setting::class); |
|
100 | + } |
|
101 | 101 | } |
@@ -8,61 +8,61 @@ |
||
8 | 8 | |
9 | 9 | class Setting extends Model |
10 | 10 | { |
11 | - use CrudTrait; |
|
11 | + use CrudTrait; |
|
12 | 12 | |
13 | - protected $fillable = ['value']; |
|
13 | + protected $fillable = ['value']; |
|
14 | 14 | |
15 | - public function __construct(array $attributes = []) |
|
16 | - { |
|
17 | - parent::__construct($attributes); |
|
15 | + public function __construct(array $attributes = []) |
|
16 | + { |
|
17 | + parent::__construct($attributes); |
|
18 | 18 | |
19 | - $this->table = config('backpack.settings.table_name'); |
|
20 | - } |
|
19 | + $this->table = config('backpack.settings.table_name'); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * Grab a setting value from the database. |
|
24 | - * |
|
25 | - * @param string $key The setting key, as defined in the key db column |
|
26 | - * |
|
27 | - * @return string The setting value. |
|
28 | - */ |
|
29 | - public static function get($key) |
|
30 | - { |
|
31 | - $setting = new self(); |
|
32 | - $entry = $setting->where('key', $key)->first(); |
|
22 | + /** |
|
23 | + * Grab a setting value from the database. |
|
24 | + * |
|
25 | + * @param string $key The setting key, as defined in the key db column |
|
26 | + * |
|
27 | + * @return string The setting value. |
|
28 | + */ |
|
29 | + public static function get($key) |
|
30 | + { |
|
31 | + $setting = new self(); |
|
32 | + $entry = $setting->where('key', $key)->first(); |
|
33 | 33 | |
34 | - if (!$entry) { |
|
35 | - return; |
|
36 | - } |
|
34 | + if (!$entry) { |
|
35 | + return; |
|
36 | + } |
|
37 | 37 | |
38 | - return $entry->value; |
|
39 | - } |
|
38 | + return $entry->value; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * Update a setting's value. |
|
43 | - * |
|
44 | - * @param string $key The setting key, as defined in the key db column |
|
45 | - * @param string $value The new value. |
|
46 | - */ |
|
47 | - public static function set($key, $value = null) |
|
48 | - { |
|
49 | - $database_prefix = config('backpack.settings.database_prefix'); |
|
41 | + /** |
|
42 | + * Update a setting's value. |
|
43 | + * |
|
44 | + * @param string $key The setting key, as defined in the key db column |
|
45 | + * @param string $value The new value. |
|
46 | + */ |
|
47 | + public static function set($key, $value = null) |
|
48 | + { |
|
49 | + $database_prefix = config('backpack.settings.database_prefix'); |
|
50 | 50 | |
51 | - $prefixed_key = !empty($database_prefix) ? $database_prefix.'.'.$key : $key; |
|
52 | - $setting = new self(); |
|
53 | - $entry = $setting->where('key', $key)->firstOrFail(); |
|
51 | + $prefixed_key = !empty($database_prefix) ? $database_prefix.'.'.$key : $key; |
|
52 | + $setting = new self(); |
|
53 | + $entry = $setting->where('key', $key)->firstOrFail(); |
|
54 | 54 | |
55 | - // update the value in the database |
|
56 | - $entry->value = $value; |
|
57 | - $entry->saveOrFail(); |
|
55 | + // update the value in the database |
|
56 | + $entry->value = $value; |
|
57 | + $entry->saveOrFail(); |
|
58 | 58 | |
59 | - // update the value in the session |
|
60 | - Config::set($prefixed_key, $value); |
|
59 | + // update the value in the session |
|
60 | + Config::set($prefixed_key, $value); |
|
61 | 61 | |
62 | - if (Config::get($prefixed_key) == $value) { |
|
63 | - return true; |
|
64 | - } |
|
62 | + if (Config::get($prefixed_key) == $value) { |
|
63 | + return true; |
|
64 | + } |
|
65 | 65 | |
66 | - return false; |
|
67 | - } |
|
66 | + return false; |
|
67 | + } |
|
68 | 68 | } |
@@ -7,49 +7,49 @@ |
||
7 | 7 | |
8 | 8 | class SettingCrudController extends CrudController |
9 | 9 | { |
10 | - use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation; |
|
11 | - use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation; |
|
12 | - |
|
13 | - public function setup() |
|
14 | - { |
|
15 | - CRUD::setModel("Backpack\Settings\app\Models\Setting"); |
|
16 | - CRUD::setEntityNameStrings(trans('backpack::settings.setting_singular'), trans('backpack::settings.setting_plural')); |
|
17 | - CRUD::setRoute(backpack_url(config('backpack.settings.route'))); |
|
18 | - } |
|
19 | - |
|
20 | - public function setupListOperation() |
|
21 | - { |
|
22 | - // only show settings which are marked as active |
|
23 | - CRUD::addClause('where', 'active', 1); |
|
24 | - |
|
25 | - // columns to show in the table view |
|
26 | - CRUD::setColumns([ |
|
27 | - [ |
|
28 | - 'name' => 'name', |
|
29 | - 'label' => trans('backpack::settings.name'), |
|
30 | - ], |
|
31 | - [ |
|
32 | - 'name' => 'value', |
|
33 | - 'label' => trans('backpack::settings.value'), |
|
34 | - ], |
|
35 | - [ |
|
36 | - 'name' => 'description', |
|
37 | - 'label' => trans('backpack::settings.description'), |
|
38 | - ], |
|
39 | - ]); |
|
40 | - } |
|
41 | - |
|
42 | - public function setupUpdateOperation() |
|
43 | - { |
|
44 | - CRUD::addField([ |
|
45 | - 'name' => 'name', |
|
46 | - 'label' => trans('backpack::settings.name'), |
|
47 | - 'type' => 'text', |
|
48 | - 'attributes' => [ |
|
49 | - 'disabled' => 'disabled', |
|
50 | - ], |
|
51 | - ]); |
|
52 | - |
|
53 | - CRUD::addField(json_decode(CRUD::getCurrentEntry()->field, true)); |
|
54 | - } |
|
10 | + use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation; |
|
11 | + use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation; |
|
12 | + |
|
13 | + public function setup() |
|
14 | + { |
|
15 | + CRUD::setModel("Backpack\Settings\app\Models\Setting"); |
|
16 | + CRUD::setEntityNameStrings(trans('backpack::settings.setting_singular'), trans('backpack::settings.setting_plural')); |
|
17 | + CRUD::setRoute(backpack_url(config('backpack.settings.route'))); |
|
18 | + } |
|
19 | + |
|
20 | + public function setupListOperation() |
|
21 | + { |
|
22 | + // only show settings which are marked as active |
|
23 | + CRUD::addClause('where', 'active', 1); |
|
24 | + |
|
25 | + // columns to show in the table view |
|
26 | + CRUD::setColumns([ |
|
27 | + [ |
|
28 | + 'name' => 'name', |
|
29 | + 'label' => trans('backpack::settings.name'), |
|
30 | + ], |
|
31 | + [ |
|
32 | + 'name' => 'value', |
|
33 | + 'label' => trans('backpack::settings.value'), |
|
34 | + ], |
|
35 | + [ |
|
36 | + 'name' => 'description', |
|
37 | + 'label' => trans('backpack::settings.description'), |
|
38 | + ], |
|
39 | + ]); |
|
40 | + } |
|
41 | + |
|
42 | + public function setupUpdateOperation() |
|
43 | + { |
|
44 | + CRUD::addField([ |
|
45 | + 'name' => 'name', |
|
46 | + 'label' => trans('backpack::settings.name'), |
|
47 | + 'type' => 'text', |
|
48 | + 'attributes' => [ |
|
49 | + 'disabled' => 'disabled', |
|
50 | + ], |
|
51 | + ]); |
|
52 | + |
|
53 | + CRUD::addField(json_decode(CRUD::getCurrentEntry()->field, true)); |
|
54 | + } |
|
55 | 55 | } |
@@ -6,28 +6,28 @@ |
||
6 | 6 | |
7 | 7 | class SettingRequest extends FormRequest |
8 | 8 | { |
9 | - /** |
|
10 | - * Determine if the user is authorized to make this request. |
|
11 | - * |
|
12 | - * @return bool |
|
13 | - */ |
|
14 | - public function authorize() |
|
15 | - { |
|
16 | - // only allow updates if the user is logged in |
|
17 | - return backpack_auth()->check(); |
|
18 | - } |
|
9 | + /** |
|
10 | + * Determine if the user is authorized to make this request. |
|
11 | + * |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | + public function authorize() |
|
15 | + { |
|
16 | + // only allow updates if the user is logged in |
|
17 | + return backpack_auth()->check(); |
|
18 | + } |
|
19 | 19 | |
20 | - /** |
|
21 | - * Get the validation rules that apply to the request. |
|
22 | - * |
|
23 | - * @return array |
|
24 | - */ |
|
25 | - public function rules() |
|
26 | - { |
|
27 | - return [ |
|
28 | - // 'key' => 'required|min:3|max:255', |
|
29 | - // 'name' => 'required|min:3|max:255', |
|
30 | - // 'field' => 'required' |
|
31 | - ]; |
|
32 | - } |
|
20 | + /** |
|
21 | + * Get the validation rules that apply to the request. |
|
22 | + * |
|
23 | + * @return array |
|
24 | + */ |
|
25 | + public function rules() |
|
26 | + { |
|
27 | + return [ |
|
28 | + // 'key' => 'required|min:3|max:255', |
|
29 | + // 'name' => 'required|min:3|max:255', |
|
30 | + // 'field' => 'required' |
|
31 | + ]; |
|
32 | + } |
|
33 | 33 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - /* |
|
4 | + /* |
|
5 | 5 | |-------------------------------------------------------------------------- |
6 | 6 | | Settings Language Lines |
7 | 7 | |-------------------------------------------------------------------------- |
@@ -9,10 +9,10 @@ discard block |
||
9 | 9 | | The following language lines are used for Laravel Backpack - Settings |
10 | 10 | | |
11 | 11 | */ |
12 | - 'name' => 'Nome', |
|
13 | - 'value' => 'Valor', |
|
14 | - 'description' => 'Descrição', |
|
15 | - 'setting_singular' => 'configuração', |
|
16 | - 'setting_plural' => 'configurações', |
|
12 | + 'name' => 'Nome', |
|
13 | + 'value' => 'Valor', |
|
14 | + 'description' => 'Descrição', |
|
15 | + 'setting_singular' => 'configuração', |
|
16 | + 'setting_plural' => 'configurações', |
|
17 | 17 | |
18 | 18 | ]; |