From afb4340964fd2b04764213144469f8b89b956982 Mon Sep 17 00:00:00 2001
From: Vincent BRIDIER
Date: Mon, 9 May 2022 18:18:01 +0200
Subject: [PATCH] TMP Setting : Rename Data to Setting model + CRUD + Update
Readme + Add Enum
---
app/Enums/SettingTypes.php | 33 ++++++
app/Http/Controllers/API/SyncController.php | 6 +-
app/Http/Controllers/HomeController.php | 6 +-
app/Http/Controllers/SettingController.php | 43 ++++++++
app/Http/Controllers/ShowController.php | 8 +-
app/Http/Requests/Setting/StoreRequest.php | 30 ++++++
app/Http/Requests/Setting/UpdateRequest.php | 30 ++++++
app/Models/Data.php | 10 --
app/Models/Setting.php | 16 +++
composer.json | 1 +
composer.lock | 64 +++++++++++-
config/app.php | 1 +
.../2022_05_09_160419_update_datas_table.php | 34 ++++++
database/seeders/DataTableSeeder.php | 27 -----
database/seeders/DatabaseSeeder.php | 2 +-
database/seeders/SettingTableSeeder.php | 28 +++++
public/assets/img/default.png | Bin 0 -> 2505 bytes
readme.md | 97 ++++--------------
resources/views/layouts/app.blade.php | 4 +
resources/views/setting/index.blade.php | 43 ++++++++
routes/web.php | 4 +
21 files changed, 359 insertions(+), 128 deletions(-)
create mode 100644 app/Enums/SettingTypes.php
create mode 100644 app/Http/Controllers/SettingController.php
create mode 100644 app/Http/Requests/Setting/StoreRequest.php
create mode 100644 app/Http/Requests/Setting/UpdateRequest.php
delete mode 100644 app/Models/Data.php
create mode 100644 app/Models/Setting.php
create mode 100644 database/migrations/2022_05_09_160419_update_datas_table.php
delete mode 100644 database/seeders/DataTableSeeder.php
create mode 100644 database/seeders/SettingTableSeeder.php
create mode 100644 public/assets/img/default.png
create mode 100644 resources/views/setting/index.blade.php
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 0000000000000000000000000000000000000000..38e9d6f71c88720ecf0adf2104c40bd5dad71342
GIT binary patch
literal 2505
zcmc&$X;c$g7LMJ68ybg3XcdJ_GNXc!)ik6Kn2>}JASi2MV+%!6K*Xf7VU~f=je>%T
z(~V+}D9nHyktLvlqO>wCauge)f<+j&48%T&fQqsxvP{JmXMVKvx9gl&@7;U8@4NTC
zd+VLb-4f1Sx_H%M3
zn=qJ9{~(DLs)hV8Km<#PpbbORO64dU4IH4AgQ8SOjZ1`*B{Dz!^QLAzP9pZh3+Q|@
zU(SM3B*A(m6r~T37U@$(3^6{yAGb*hpaN1z4dS%YoiY`m^~1l@1<!
z_+OF|^0(kvuoA-2iF7X!nX(b*%^*_fl#M{QnP?NPYCn`TnY~Dq1IpNRf~VPE(4|!X*)Gq2vHd34v-@84bfb=T31;3ao}zDX<*JV&T>c
zBr-9qQMtc^^Z5Wzrc#445yWHr;ZXsiL?Q;r-gF;2nI1$XdvByrI5Y;6N)Fn%k-}ut
zSgasAdydP7MQKt-9KXAVwf0S$M1gRX2%!ZVbU643P2}^PBb__^9o(ube3VN9$_22VYs9qm|~Q9q09k|@bwg<*j$m8oW7~}
zR?K*l3wFWDkH|TOX>o`k$T;o+c-oE5JZ!2H
z@b@%iBdZUUc9{@C?e^CDr5SnHP*vqEWNrEcrD!-WRU{(hr<_{TpnT+aTh^LW9^BpC
zo#?a9uI&Dk^A?xb$t&(bS3Yh3ax*Vt;N;S85CnPA_vY2mGOq^K8Bjvk_Fm22eWLvO
z9jW?$fz0g5DfbG?sLh(3981;C3~e2@dg!lp1|C|VI;2~fSK8@ZI^L5RD(r}mqN$&<@32ebSPCUylx**H$E%LTjEikya?2l7iy5dw5
zbmT6>*w+$LUm3OhC@CH*FmB6bN=A1~1S8c(1+uo99Z|n3>gDB#KcyY0+6B_PZj`6w
zEALf&cd0eTQdcRguX78~FYh*+t#6Ws^E`M8N%D>X1w!-W#Bg4!mDKPDv)VUQ*G|T2
zK~q`CD6O7T*%;zK71dma<&-bF>|DRg_lNY6J{(aHoomQ3#I`+k>ds_0WGc+eZThaN
zKqco$Kz(<*_A>jX_;bZ%c{7%;_(J{2`nW=@Re9gFW(=PetI
zD-C?Rd`)4HYboG@)~%vDR$%ofluph%1te190hgaQKT@nkzje;u@)O7P9WkehLkg$+
zMFX_*q@*P5_Qr|99^sScgZm=}*4!>apc6i~I)8lbW-1X(ziqyLHSl{$x=HZr`L|_L
zEt8|}?d>Mli+=`mFN>dvazUusW2d2~;jf+D38!EO*DEEnlkLW^-63b)&W!%!d{Bh6O@;Ke=e>2metl~F$
z8;UBhcfz-2ACAq?b0bWSQ$sDCpWHb&ed~~$^`{Kqj4{n>PC3D@`9QwmmG3!Uz5}5!
z>sZbCCH?*V)^q;X8zb2S0s%~rlU*(CTOGjMAY#q@qgA?){HnkXhcN@!uFyIS$A$@c
z_io-im~~T!n5!G>Zm;x-UHDsGhQD?#
-
-
-
-
-
-
-
-
-## About Laravel
-
-Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
-
-- [Simple, fast routing engine](https://laravel.com/docs/routing).
-- [Powerful dependency injection container](https://laravel.com/docs/container).
-- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
-- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
-- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
-- [Robust background job processing](https://laravel.com/docs/queues).
-- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
-
-Laravel is accessible, powerful, and provides tools required for large, robust applications.
-
-## Learning Laravel
-
-Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
-
-If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
-
-## Laravel Sponsors
-
-We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell).
-
-- **[Vehikl](https://vehikl.com/)**
-- **[Tighten Co.](https://tighten.co)**
-- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
-- **[64 Robots](https://64robots.com)**
-- **[Cubet Techno Labs](https://cubettech.com)**
-- **[Cyber-Duck](https://cyber-duck.co.uk)**
-- **[British Software Development](https://www.britishsoftware.co)**
-- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
-- **[DevSquad](https://devsquad.com)**
-- [UserInsights](https://userinsights.com)
-- [Fragrantica](https://www.fragrantica.com)
-- [SOFTonSOFA](https://softonsofa.com/)
-- [User10](https://user10.com)
-- [Soumettre.fr](https://soumettre.fr/)
-- [CodeBrisk](https://codebrisk.com)
-- [1Forge](https://1forge.com)
-- [TECPRESSO](https://tecpresso.co.jp/)
-- [Runtime Converter](http://runtimeconverter.com/)
-- [WebL'Agence](https://weblagence.com/)
-- [Invoice Ninja](https://www.invoiceninja.com)
-- [iMi digital](https://www.imi-digital.de/)
-- [Earthlink](https://www.earthlink.ro/)
-- [Steadfast Collective](https://steadfastcollective.com/)
-- [We Are The Robots Inc.](https://watr.mx/)
-- [Understand.io](https://www.understand.io/)
-- [Abdel Elrafa](https://abdelelrafa.com)
-- [Hyper Host](https://hyper.host)
-- [Appoly](https://www.appoly.co.uk)
-- [OP.GG](https://op.gg)
-
-## Contributing
-
-Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
-
-## Code of Conduct
-
-In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
-
-## Security Vulnerabilities
-
-If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
-
-## License
-
-The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
+# BO Application Commerciaux
+## Installation
+```
+cp .env.example .env
+php artisan key:generate
+```
+- éditer le .env
+```
+php artisan migrate --seed
+```
+## Création d'un user BO
+```
+php artisan user:create
+```
+# TODO
+- Setting edit + update
+- Ajouter un Enum Role sur users + Gate
+## API V2
+- Call pour récupérer la config
\ No newline at end of file
diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php
index f4697a0..d0f4f8f 100644
--- a/resources/views/layouts/app.blade.php
+++ b/resources/views/layouts/app.blade.php
@@ -65,6 +65,10 @@
Salon
+ {{-- TODO : Mettre des roles et restreindre data à ADMIN --}}
+
+ {{ __('Paramètres') }}
+
{{ Auth::user()->name }}
diff --git a/resources/views/setting/index.blade.php b/resources/views/setting/index.blade.php
new file mode 100644
index 0000000..9717876
--- /dev/null
+++ b/resources/views/setting/index.blade.php
@@ -0,0 +1,43 @@
+@extends('layouts.app')
+@section('content')
+
+
+
+
+ SquaredLogo : 187 x 187px
+ RectangleLogo: 187 x 100px
+ BackgroundImage : 1920 x 1200px
+ HomeButtonImage : 100 x 100px
+
+
+
+
+ | {{ __('Clé') }} |
+ {{ __('Type') }} |
+ {{ __('Valeur') }} |
+ |
+
+
+
+ @foreach($settings as $setting)
+
+ | {{$setting->key}} |
+ {{ $setting->type->label }} |
+ @if ($setting->type->value != SettingTypesEnum::picture()->value)
+ {{$setting->value}} |
+ @else
+
+ Ouvrir
+ |
+ @endif
+
+ {{ __('Éditer') }}
+ |
+
+ @endforeach
+
+
+
+
+
+@endsection
diff --git a/routes/web.php b/routes/web.php
index 33afda8..86f0db2 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -47,3 +47,7 @@ Route::post('/show/updateStatus', 'ShowController@updateStatus');
Route::get('/docs/{uuid}/download', 'DocumentsController@download')
->name('docs.download')
->middleware('signed');
+
+Route::middleware('auth')->group(function () {
+ Route::resource('setting', SettingController::class)->except(['create', 'store', 'show', 'destroy']);
+});
\ No newline at end of file