Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4a81c08

Browse files
committedDec 28, 2023
Remove Route and controller
1 parent f27a498 commit 4a81c08

22 files changed

+527
-1090
lines changed
 

‎.DS_Store

6 KB
Binary file not shown.

‎README.md

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
- [Update Settings](#update-settings)
1818
- [Update or Create Settings](#update-or-create-settings)
1919
- [Delete Settings](#delete-settings)
20-
- [Settings Table CRUD](#settings-table-crud)
2120
- [Contribution Guide](#contribution-guide)
2221
- [License](#license)
2322

@@ -49,7 +48,7 @@ php artisan migrate
4948
Seed the settings table with initial data:
5049

5150
```shell
52-
php artisan db:seed --class=AnisAronno\\LaravelSettings\\Database\\Seeders\\LaravelSettingsSeeder
51+
php artisan db:seed --class=LaravelSettingsSeeder::class
5352
```
5453

5554
## Usage
@@ -104,35 +103,8 @@ Update an existing setting:
104103
deleteSettings(string $key);
105104
```
106105

107-
## Settings Table CRUD
108-
To manage your settings table, you can use the following routes:
109-
110-
- Get all settings: `api/v1/settings` (GET) (name: `settings.index`) - No middleware required
111-
- Get a single setting: `api/v1/settings/{setting_key}` (GET) (name: `settings.show`) - No middleware required
112-
- Store a new setting: `api/v1/settings` (POST) (name: `settings.store`)
113-
- Update a setting: `api/v1/settings/update/{setting_key}` (POST) (name: `settings.update`)
114-
- Delete a setting: `api/v1/settings/{setting_key}` (DELETE) (name: `settings.destroy`)
115-
116-
You can customize the authentication guard for the routes by publishing the config file and changing the 'guard' key to your desired authentication guard:
117-
118-
```php
119-
'guard' => ['auth'],
120-
```
121-
122-
Make sure to publish the config file using the following command:
123-
124-
```shell
125-
php artisan vendor:publish --tag=laravel-settings
126-
```
127-
128-
To view the complete route list, run:
129-
130-
```shell
131-
php artisan route:list
132-
```
133-
134106
## Contribution Guide
135107
Please follow our [Contribution Guide](https://github.com/anisAronno/multipurpose-admin-panel-boilerplate/blob/develop/CONTRIBUTING.md) if you'd like to contribute to this package.
136108

137109
## License
138-
This package is open-source software licensed under the [MIT License](https://opensource.org/licenses/MIT).
110+
This package is open-source software licensed under the [MIT License](https://opensource.org/licenses/MIT).

‎composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "anisaronno/laravel-settings",
33
"description": "A Laravel package for managing application settings, similar to WordPress options.",
4-
"version": "0.1.6",
4+
"version": "1.0.0",
55
"license": "MIT",
66
"keywords": [
77
"laravel-settings",
@@ -21,7 +21,6 @@
2121
"homepage": "https://github.com/anisAronno/laravel-settings",
2222
"require": {
2323
"php": "^7.4|^8.0",
24-
"anisaronno/laravel-cache-control": "^0.0.1",
2524
"illuminate/support": "^8.0|^9.0|^10.0"
2625
},
2726
"require-dev": {

‎composer.lock

Lines changed: 513 additions & 483 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

‎src/Database/Seeders/LaravelSettingsSeeder.php renamed to ‎database/seeders/LaravelSettingsSeeder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace AnisAronno\LaravelSettings\Database\Seeders;
3+
namespace Database\Seeders;
44

55
use AnisAronno\LaravelSettings\Models\SettingsProperty;
66
use Illuminate\Database\Seeder;

‎src/Config/laravel-settings.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎src/Helpers/CacheKey.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

‎src/Helpers/SettingsHelper.php

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace AnisAronno\LaravelSettings\Helpers;
44

5-
use AnisAronno\LaravelCacheMaster\CacheControl;
65
use AnisAronno\LaravelSettings\Models\SettingsProperty;
76
use Exception;
87
use Illuminate\Support\Collection;
@@ -18,15 +17,8 @@ class SettingsHelper
1817
*/
1918
public static function hasSettings(string $settingsKey): bool
2019
{
21-
$tagKey = CacheKey::getLaravelSettingsCacheKey();
22-
$cacheKey = $settingsKey.'_'.'isExist';
23-
2420
try {
25-
$settings = CacheControl::init($tagKey)->remember($cacheKey, now()->addDay(), function () use ($settingsKey) {
26-
return SettingsProperty::where('settings_key', $settingsKey)->exists();
27-
});
28-
29-
return !!$settings;
21+
return SettingsProperty::where('settings_key', $settingsKey)->exists();
3022
} catch (\Throwable $th) {
3123
return false;
3224
}
@@ -42,13 +34,8 @@ public static function hasSettings(string $settingsKey): bool
4234
*/
4335
public static function getSettings(string $settingsKey): string
4436
{
45-
$key = CacheKey::getLaravelSettingsCacheKey();
46-
47-
4837
try {
49-
$settings = CacheControl::init($key)->remember($settingsKey, now()->addDay(), function () use ($settingsKey) {
50-
return SettingsProperty::select('settings_value')->find($settingsKey);
51-
});
38+
$settings = SettingsProperty::select('settings_value')->find($settingsKey);
5239

5340
if(isset($settings['settings_value'])) {
5441
return $settings['settings_value'];
@@ -136,15 +123,11 @@ public static function upsertSettings(string $key, string $value): SettingsPrope
136123
*/
137124
public static function getAllSettings(): Collection
138125
{
139-
$key = CacheKey::getLaravelSettingsCacheKey();
140-
$cacheKey = $key.md5(serialize(['getAllSettings']));
141-
142126
try {
143-
return CacheControl::init($key)->remember($cacheKey, 10, function () {
144-
return SettingsProperty::select('settings_value', 'settings_key')->orderBy('settings_key', 'asc')->get()->flatMap(function ($name) {
145-
return [$name->settings_key => $name->settings_value];
146-
});
127+
return SettingsProperty::select('settings_value', 'settings_key')->orderBy('settings_key', 'asc')->get()->flatMap(function ($name) {
128+
return [$name->settings_key => $name->settings_value];
147129
});
130+
148131
} catch (\Throwable $th) {
149132
throw new Exception($th->getMessage(), 400);
150133
}

‎src/Http/Controllers/LaravelSettingsController.php

Lines changed: 0 additions & 136 deletions
This file was deleted.

‎src/Http/Requests/StoreLaravelSettingsRequest.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

‎src/Http/Requests/UpdateLaravelSettingsRequest.php

Lines changed: 0 additions & 45 deletions
This file was deleted.

‎src/Http/Resources/ImageResources.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎src/Http/Resources/SettingsResources.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

‎src/LaravelSettingsServiceProvider.php

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
namespace AnisAronno\LaravelSettings;
44

5-
use AnisAronno\LaravelSettings\Models\SettingsProperty;
6-
use AnisAronno\LaravelSettings\Observers\LaravelSettingsObserver;
7-
use AnisAronno\LaravelSettings\RouteServiceProvider;
85
use Illuminate\Support\ServiceProvider;
96

107
class LaravelSettingsServiceProvider extends ServiceProvider
@@ -14,7 +11,6 @@ class LaravelSettingsServiceProvider extends ServiceProvider
1411
*/
1512
public function register(): void
1613
{
17-
$this->app->register(RouteServiceProvider::class);
1814
}
1915

2016
/**
@@ -23,34 +19,16 @@ public function register(): void
2319
public function boot(): void
2420
{
2521
$this->registerMigration();
26-
$this->registerConfig();
27-
SettingsProperty::observe(LaravelSettingsObserver::class);
2822
}
2923

30-
3124
protected function registerMigration()
32-
{
33-
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
34-
25+
{
3526
$this->publishes([
36-
__DIR__ . '/Database/Migrations/2023_01_10_072911_create_settings_table.php' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_settings_table.php'),
37-
], 'settings-migration');
38-
}
3927

40-
/**
41-
* Register config.
42-
*
43-
* @return void
44-
*/
45-
protected function registerConfig()
46-
{
47-
$this->publishes([
48-
__DIR__.'/Config/laravel-settings.php' => config_path('laravel-settings.php'),
49-
], 'laravel-settings');
28+
__DIR__ . '/../database/migrations/2023_01_10_072911_create_settings_table.php' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_settings_table.php'),
5029

51-
$this->mergeConfigFrom(
52-
__DIR__.'/Config/laravel-settings.php',
53-
'laravel-settings'
54-
);
30+
__DIR__ . '/../database/Seeders/LaravelSettingsSeeder.php' => database_path('seeders/LaravelSettingsSeeder.php'),
31+
32+
], 'settings-migration');
5533
}
5634
}

‎src/Observers/LaravelSettingsObserver.php

Lines changed: 0 additions & 72 deletions
This file was deleted.

‎src/RouteServiceProvider.php

Lines changed: 0 additions & 68 deletions
This file was deleted.

‎src/Routes/api.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

‎src/Routes/web.php

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎src/Rules/SettingsKeyUniqueRule.php

Lines changed: 0 additions & 47 deletions
This file was deleted.

‎src/Traits/EnumToArray.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.