diff --git a/app/Enums/SettingTypes.php b/app/Enums/SettingTypes.php new file mode 100644 index 0000000..f4d6f87 --- /dev/null +++ b/app/Enums/SettingTypes.php @@ -0,0 +1,33 @@ + 1, + 'numeric' => 2, + 'picture' => 3, + ]; + } + + protected static function labels(): array + { + return [ + 'string' => 'String (Hexa)', + 'numeric' => 'Numeric', + 'picture' => 'Picture', + ]; + } +} diff --git a/app/Http/Controllers/API/SyncController.php b/app/Http/Controllers/API/SyncController.php index 23b9e89..6ce894c 100644 --- a/app/Http/Controllers/API/SyncController.php +++ b/app/Http/Controllers/API/SyncController.php @@ -6,7 +6,7 @@ use App\Http\Controllers\Controller; use App\Mail\SendFlyerFailed; use App\Models\AppUsers; use App\Models\Contacts; -use App\Models\Data; +use App\Models\Setting; use GuzzleHttp\Exception\ClientException; use Illuminate\Http\Request; use Illuminate\Support\Facades\Mail; @@ -38,8 +38,8 @@ class SyncController extends Controller public function getVersion(Request $request) { $app_uuid = $request->app_uuid; $app_version = $request->app_version; - $version = Data::select('value AS version')->where('key', 'version')->first(); - $ShowIsActive = Data::select('value AS ShowIsActive')->where('key', 'ShowIsActive')->first(); + $version = Setting::select('value AS version')->where('key', 'version')->first(); + $ShowIsActive = Setting::select('value AS ShowIsActive')->where('key', 'ShowIsActive')->first(); try { $client = new \GuzzleHttp\Client(); diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 4f1a966..e0190a6 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -3,7 +3,7 @@ namespace App\Http\Controllers; use App\Models\Contacts; -use App\Models\Data; +use App\Models\Setting; use Illuminate\Http\Request; use Illuminate\Support\Facades\Storage; @@ -26,12 +26,12 @@ class HomeController extends Controller */ public function index() { - $version = Data::where('key', 'version')->first(); + $version = Setting::where('key', 'version')->first(); return view('home', ['version' => $version->value]); } public function newVersion(Request $request) { - $version = Data::where('key', 'version')->first(); + $version = Setting::where('key', 'version')->first(); $version->value = $version->value + 1; $version->save(); return redirect()->route('home'); diff --git a/app/Http/Controllers/SettingController.php b/app/Http/Controllers/SettingController.php new file mode 100644 index 0000000..3f94fbd --- /dev/null +++ b/app/Http/Controllers/SettingController.php @@ -0,0 +1,43 @@ +first(); + $ShowIsActive = Setting::where('key', '=', 'ShowIsActive')->first(); return view('show.index', ['isActive' => $ShowIsActive->value]); } public function updateStatus(Request $request) { $status = $request->status; - $d = Data::where('key', '=', 'ShowIsActive')->first(); + $d = Setting::where('key', '=', 'ShowIsActive')->first(); $d->value = $status; $d->save(); - $version = Data::where('key', 'version')->first(); + $version = Setting::where('key', 'version')->first(); $version->value = $version->value + 1; $version->save(); diff --git a/app/Http/Requests/Setting/StoreRequest.php b/app/Http/Requests/Setting/StoreRequest.php new file mode 100644 index 0000000..7f4224d --- /dev/null +++ b/app/Http/Requests/Setting/StoreRequest.php @@ -0,0 +1,30 @@ + SettingTypes::class + ]; +} diff --git a/composer.json b/composer.json index 5c4a1fe..af23b88 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "ext-json": "*", "fideloper/proxy": "^4.0", "google/cloud-vision": "^0.25.0", + "kwaadpepper/enum": "^2.1", "laravel/framework": "^8.0", "laravel/tinker": "^2.0", "laravel/ui": "^3.0", diff --git a/composer.lock b/composer.lock index b00fe5d..7c25233 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f1a1ec757ebd7a6f0b2ec06767f78a82", + "content-hash": "788ccec969d3e50c1708f733bd96c886", "packages": [ { "name": "brick/math", @@ -1240,6 +1240,66 @@ }, "time": "2021-04-26T09:17:50+00:00" }, + { + "name": "kwaadpepper/enum", + "version": "2.1.2", + "source": { + "type": "git", + "url": "https://github.com/Kwaadpepper/enum.git", + "reference": "bbd08723895cad5a41bc0d57e565fe64fa13ca41" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Kwaadpepper/enum/zipball/bbd08723895cad5a41bc0d57e565fe64fa13ca41", + "reference": "bbd08723895cad5a41bc0d57e565fe64fa13ca41", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "require-dev": { + "orchestra/testbench": "^5", + "phpunit/php-code-coverage": "^9.2", + "phpunit/phpunit": "~9.0", + "slevomat/coding-standard": "^7.0", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Kwaadpepper\\Enum\\EnumServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Kwaadpepper\\Enum\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jérémy Munsch", + "email": "github@jeremydev.ovh", + "homepage": "https://jeremydev.ovh" + } + ], + "description": "Enums to use for any project", + "homepage": "https://github.com/kwaadpepper/enum", + "keywords": [ + "enum", + "laravel" + ], + "support": { + "issues": "https://github.com/Kwaadpepper/enum/issues", + "source": "https://github.com/Kwaadpepper/enum/tree/2.1.2" + }, + "time": "2021-11-18T16:52:08+00:00" + }, { "name": "laravel/framework", "version": "v8.54.0", @@ -8636,5 +8696,5 @@ "ext-json": "*" }, "platform-dev": [], - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.3.0" } diff --git a/config/app.php b/config/app.php index a48bd6a..d49b6b9 100644 --- a/config/app.php +++ b/config/app.php @@ -231,6 +231,7 @@ return [ 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, 'Excel' => Maatwebsite\Excel\Facades\Excel::class, + 'SettingTypesEnum' => App\Enums\SettingTypes::class, ], ]; diff --git a/database/migrations/2022_05_09_160419_update_datas_table.php b/database/migrations/2022_05_09_160419_update_datas_table.php new file mode 100644 index 0000000..75ea1d7 --- /dev/null +++ b/database/migrations/2022_05_09_160419_update_datas_table.php @@ -0,0 +1,34 @@ +integer('type')->after('value'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('settings', function (Blueprint $table) { + $table->dropColumn('type'); + }); + Schema::rename('settings', 'data'); + } +} diff --git a/database/seeders/DataTableSeeder.php b/database/seeders/DataTableSeeder.php deleted file mode 100644 index 921ba94..0000000 --- a/database/seeders/DataTableSeeder.php +++ /dev/null @@ -1,27 +0,0 @@ -insert([ - 'key' => 'version', - 'value' => '1' - ]); - - DB::table('data')->insert([ - 'key' => 'ShowIsActive', - 'value' => '0' - ]); - } -} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 8901e38..27a0a6c 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -13,7 +13,7 @@ class DatabaseSeeder extends Seeder */ public function run() { - $this->call(DataTableSeeder::class); + $this->call(SettingTableSeeder::class); $this->call(DirectoriesSeeder::class); } } diff --git a/database/seeders/SettingTableSeeder.php b/database/seeders/SettingTableSeeder.php new file mode 100644 index 0000000..83a02bb --- /dev/null +++ b/database/seeders/SettingTableSeeder.php @@ -0,0 +1,28 @@ +insert([ + ['key' => 'version', 'value' => '1', 'type' => SettingTypes::numeric()->value], + ['key' => 'ShowIsActive', 'value' => '0', 'type' => SettingTypes::numeric()->value], + ['key' => 'MainColor', 'value' => '#DE0017', 'type' => SettingTypes::string()->value], + ['key' => 'SquaredLogo', 'value' => 'assets/img/default.png', 'type' => SettingTypes::picture()->value], + ['key' => 'RectangleLogo', 'value' => 'assets/img/default.png', 'type' => SettingTypes::picture()->value], + ['key' => 'BackgroundImage', 'value' => 'assets/img/default.png', 'type' => SettingTypes::picture()->value], + ['key' => 'HomeButtonImage', 'value' => 'assets/img/default.png', 'type' => SettingTypes::picture()->value], + ]); + } +} diff --git a/public/assets/img/default.png b/public/assets/img/default.png new file mode 100644 index 0000000..38e9d6f Binary files /dev/null and b/public/assets/img/default.png differ diff --git a/readme.md b/readme.md index 81f2f62..42f41ea 100644 --- a/readme.md +++ b/readme.md @@ -1,78 +1,19 @@ -
+ SquaredLogo : 187 x 187px
+ RectangleLogo: 187 x 100px
+ BackgroundImage : 1920 x 1200px
+ HomeButtonImage : 100 x 100px
+
| {{ __('Clé') }} | +{{ __('Type') }} | +{{ __('Valeur') }} | ++ | |
|---|---|---|---|---|
| {{$setting->key}} | +{{ $setting->type->label }} | + @if ($setting->type->value != SettingTypesEnum::picture()->value) +{{$setting->value}} | + @else ++ Ouvrir + | + @endif ++ {{ __('Éditer') }} + | +