From 72a5b739029cec8af78acd85a54c4d5b999fc8fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Wed, 8 Sep 2021 16:43:44 +0200 Subject: [PATCH] overhaull UI upgrade using crud policies --- .gitignore | 1 + app/Http/Controllers/BrandController.php | 33 +- app/Http/Controllers/CustomerController.php | 29 +- app/Http/Controllers/LoginController.php | 2 +- app/Http/Controllers/ServiceController.php | 43 +- .../Controllers/SingleOptinController.php | 38 ++ .../Controllers/SingleOptinsController.php | 37 -- app/Models/Brand.php | 37 ++ app/Models/CustomerInfo.php | 10 + app/Models/Service.php | 34 ++ app/Models/SingleOptin.php | 61 +++ app/Policies/BrandPolicy.php | 28 ++ app/Policies/CustomerPolicy.php | 23 +- app/Policies/Rules/UserStaticRules.php | 17 + app/Policies/ServicePolicy.php | 29 ++ app/Policies/SingleOptinPolicy.php | 27 ++ app/Providers/AppServiceProvider.php | 13 + app/Providers/RouteServiceProvider.php | 7 + clients/V2 | 2 +- composer.json | 6 +- composer.lock | 369 ++++++++++++------ config/app.php | 4 +- package.json | 37 +- public/js/app.js.LICENSE.txt | 18 - public/mix-manifest.json | 4 +- .../assets}/images/logo_ldc.png | Bin resources/js/Components/SearchOptin.vue | 101 ----- resources/js/Components/SearchUser.vue | 87 ----- resources/js/app.js | 17 - resources/js/back.js | 5 + resources/js/pages/customer.delete.js | 34 ++ resources/js/pages/service.index.js | 36 ++ resources/js/pages/single_optin.index.js | 10 + resources/lang/en/models.php | 20 + resources/lang/fr/models.php | 20 + resources/sass/_dashboard.scss | 103 ----- resources/sass/_layout.scss | 17 + resources/sass/_variables.scss | 4 + resources/sass/app.scss | 10 - resources/sass/back.scss | 5 + resources/sass/pages/login.scss | 54 +++ resources/views/brand/index.blade.php | 158 ++++++++ resources/views/brands/index.blade.php | 28 -- resources/views/brands/manage.blade.php | 30 -- .../customer/index-tableHeaders.blade.php | 63 +++ resources/views/customer/index.blade.php | 104 +++++ resources/views/customer/show.blade.php | 113 ++++++ resources/views/customers/index.blade.php | 23 -- resources/views/customers/show.blade.php | 98 ----- resources/views/layout/app.blade.php | 68 ---- resources/views/layouts/app.blade.php | 35 ++ .../views/layouts/backend/footer.blade.php | 10 + .../views/layouts/backend/head.blade.php | 32 ++ .../views/layouts/backend/navbar.blade.php | 15 + .../views/layouts/backend/sidenav.blade.php | 90 +++++ resources/views/login.blade.php | 84 +--- resources/views/service/index.blade.php | 158 ++++++++ resources/views/services/index.blade.php | 36 -- resources/views/services/manage.blade.php | 42 -- resources/views/single-optins/index.blade.php | 5 - resources/views/single_optin/index.blade.php | 121 ++++++ routes/web.php | 36 +- webpack.mix.js | 58 ++- 63 files changed, 1838 insertions(+), 1001 deletions(-) create mode 100644 app/Http/Controllers/SingleOptinController.php delete mode 100644 app/Http/Controllers/SingleOptinsController.php create mode 100644 app/Policies/BrandPolicy.php create mode 100644 app/Policies/Rules/UserStaticRules.php create mode 100644 app/Policies/ServicePolicy.php create mode 100644 app/Policies/SingleOptinPolicy.php delete mode 100644 public/js/app.js.LICENSE.txt rename {public => resources/assets}/images/logo_ldc.png (100%) delete mode 100644 resources/js/Components/SearchOptin.vue delete mode 100644 resources/js/Components/SearchUser.vue delete mode 100644 resources/js/app.js create mode 100644 resources/js/back.js create mode 100644 resources/js/pages/customer.delete.js create mode 100644 resources/js/pages/service.index.js create mode 100644 resources/js/pages/single_optin.index.js create mode 100644 resources/lang/en/models.php create mode 100644 resources/lang/fr/models.php delete mode 100644 resources/sass/_dashboard.scss create mode 100644 resources/sass/_layout.scss delete mode 100644 resources/sass/app.scss create mode 100644 resources/sass/back.scss create mode 100644 resources/sass/pages/login.scss create mode 100644 resources/views/brand/index.blade.php delete mode 100644 resources/views/brands/index.blade.php delete mode 100644 resources/views/brands/manage.blade.php create mode 100644 resources/views/customer/index-tableHeaders.blade.php create mode 100644 resources/views/customer/index.blade.php create mode 100644 resources/views/customer/show.blade.php delete mode 100644 resources/views/customers/index.blade.php delete mode 100644 resources/views/customers/show.blade.php delete mode 100644 resources/views/layout/app.blade.php create mode 100644 resources/views/layouts/app.blade.php create mode 100644 resources/views/layouts/backend/footer.blade.php create mode 100644 resources/views/layouts/backend/head.blade.php create mode 100644 resources/views/layouts/backend/navbar.blade.php create mode 100644 resources/views/layouts/backend/sidenav.blade.php create mode 100644 resources/views/service/index.blade.php delete mode 100644 resources/views/services/index.blade.php delete mode 100644 resources/views/services/manage.blade.php delete mode 100644 resources/views/single-optins/index.blade.php create mode 100644 resources/views/single_optin/index.blade.php diff --git a/.gitignore b/.gitignore index d430557..de543e8 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ storage/crm_migration.csv MIG/errors_sql.txt public/js public/css +public/assets diff --git a/app/Http/Controllers/BrandController.php b/app/Http/Controllers/BrandController.php index 482f5d9..0be8700 100644 --- a/app/Http/Controllers/BrandController.php +++ b/app/Http/Controllers/BrandController.php @@ -3,29 +3,28 @@ namespace App\Http\Controllers; use App\Http\Controllers\Controller; -use App\Http\Requests\ManageBrandRequest; use App\Models\Brand; +use Kwaadpepper\CrudPolicies\Http\Requests\CrudIndexRequest; +use Kwaadpepper\CrudPolicies\Traits\CrudController; class BrandController extends Controller { - public function index() - { - $brands = Brand::all(); - return view('brands.index', compact('brands')); + use CrudController { + index as crudIndex; } - public function manage(ManageBrandRequest $request, Brand $brand) - { - if ($request->isMethod('post')) { - if (!$brand) { - $brand = new Brand($request->validated()); - } else { - $brand->fill($request->validated()); - } - $brand->save(); - return redirect()->route('brands')->with('success', trans('Modifications enregistrées !')); - } + /** @var Brand */ + public static $modelClass = Brand::class; - return view('brands.manage', compact('brand')); + public static $layout = 'layouts.app'; + + public function index(CrudIndexRequest $request) + { + /** @var \Illuminate\View\View */ + $view = $this->crudIndex($request); + if ($request->ajax()) { + return $view; + } + return view('brand.index', $view->getData()); } } diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index 22e5f26..837a3ea 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -12,7 +12,23 @@ class CustomerController extends Controller public function index() { $brands = Brand::select('id', 'name')->get(); - return view('customers.index', compact('brands')); + $query = CustomerInfo::with(['customer']); + if (request()->brand) { + $query = $query->where('brand_id', request()->brand); + } + $customers = $query->paginate(); + $modelTable = (new Customer())->getTable(); + $modelClass = Customer::class; + + // use a crud controller (any) to gather crudModels + $modelsClasses = (new BrandController())->getCrudModels(); + return view('customer.index', compact( + 'modelsClasses', + 'modelClass', + 'modelTable', + 'customers', + 'brands' + )); } public function show(Customer $customer, Brand $brand) @@ -21,7 +37,14 @@ class CustomerController extends Controller ->where('brand_id', $brand->id)->firstOrFail(); $customerLogin = CustomerLogin::where('customer_id', $customer->id) ->where('brand_id', $brand->id)->first(); - return view('customers.show', compact('customerInfos', 'customerLogin')); + + // use a crud controller (any) to gather crudModels + $modelsClasses = (new BrandController())->getCrudModels(); + return view('customer.show', compact( + 'modelsClasses', + 'customerInfos', + 'customerLogin' + )); } public function filter($texte, Brand $brand = null) @@ -77,6 +100,6 @@ class CustomerController extends Controller $customer->delete(); } - return redirect()->route('customers')->with('success', "Compte supprimé."); + return redirect()->route('customers.index')->with('success', "Compte supprimé."); } } diff --git a/app/Http/Controllers/LoginController.php b/app/Http/Controllers/LoginController.php index f7033f7..c1e18aa 100644 --- a/app/Http/Controllers/LoginController.php +++ b/app/Http/Controllers/LoginController.php @@ -21,7 +21,7 @@ class LoginController extends Controller $request->remember !== null ? true : false ) ) { - return redirect()->route('customers'); + return redirect()->route('customers.index'); } else { return back()->withInput($request->except("password")) ->withErrors("Les identifiants entrés sont incorrects, veuillez réessayer."); diff --git a/app/Http/Controllers/ServiceController.php b/app/Http/Controllers/ServiceController.php index 2d45863..ac752ed 100644 --- a/app/Http/Controllers/ServiceController.php +++ b/app/Http/Controllers/ServiceController.php @@ -2,40 +2,29 @@ namespace App\Http\Controllers; -use App\Http\Requests\ManageServiceRequest; -use App\Models\Brand; use App\Models\Service; +use Kwaadpepper\CrudPolicies\Http\Requests\CrudIndexRequest; +use Kwaadpepper\CrudPolicies\Traits\CrudController; class ServiceController extends Controller { - public function index() - { - $services = Service::all(); - return view('services.index', compact('services')); + use CrudController { + index as crudIndex; } - public function manage(ManageServiceRequest $request, Service $service = null) + /** @var Service */ + public static $modelClass = Service::class; + + public static $layout = 'layouts.app'; + + public function index(CrudIndexRequest $request) { - $brands = Brand::all(); - $edit = $service ? true : false; - - if ($request->isMethod('post')) { - if (!$service) { - $service = new Service($request->validated()); - } else { - $service->fill($request->validated()); - } - $brand = Brand::findOrFail($request->brand_id); - $service->brand()->associate($brand); - $service->save(); - - return redirect()->route('services')->with('success', $edit ? 'Modifications enregistrées !' : sprintf( - 'Token du service : \'%s\'', - $service->bearer_token - )); + /** @var \Illuminate\View\View */ + $view = $this->crudIndex($request); + if ($request->ajax()) { + return $view; } - - return view('services.manage', compact('service', 'brands', 'edit')); + return view('service.index', $view->getData()); } public function generateApiToken(Service $service) @@ -45,6 +34,6 @@ class ServiceController extends Controller $service->saveOrFail(); return back() // phpcs:ignore Generic.Files.LineLength.TooLong - ->with('success', "Nouveau token d'API de $service->name : '$bearerToken' et mot de passe '$bearerPwd'"); + ->with('error', "ATTENTION : METTEZ À JOUR LE SITE ! \nNouveau token d'API de $service->name : '$bearerToken' et mot de passe '$bearerPwd'"); } } diff --git a/app/Http/Controllers/SingleOptinController.php b/app/Http/Controllers/SingleOptinController.php new file mode 100644 index 0000000..7174356 --- /dev/null +++ b/app/Http/Controllers/SingleOptinController.php @@ -0,0 +1,38 @@ +crudIndex($request); + if ($request->ajax()) { + return $view; + } + return view('single_optin.index', $view->getData()); + } + + public function indexQuery(Builder $query): Builder + { + if (request()->brand) { + $query = $query->where('brand_id', request()->brand); + } + return $query; + } +} diff --git a/app/Http/Controllers/SingleOptinsController.php b/app/Http/Controllers/SingleOptinsController.php deleted file mode 100644 index 303585d..0000000 --- a/app/Http/Controllers/SingleOptinsController.php +++ /dev/null @@ -1,37 +0,0 @@ -get(); - return view('single-optins.index', compact('brands')); - } - - public function filter($texte, $brandId = null) - { - if ($brandId !== null) { - $customers = SingleOptin::where([['email', 'like', '%' . $texte . '%'], ['brand_id', $brandId]])->get(); - } else { - $customers = SingleOptin::where('email', 'like', '%' . $texte . '%')->get(); - } - - return response()->json($customers); - } - - public function delete($id) - { - // TODO : Gestion avec les stats - $optin = SingleOptin::find($id); - if ($optin) { - $optin->delete(); - } - return new StatusResource(['status' => "OK"]); - } -} diff --git a/app/Models/Brand.php b/app/Models/Brand.php index d80fae1..9db5006 100644 --- a/app/Models/Brand.php +++ b/app/Models/Brand.php @@ -4,13 +4,22 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Str; +use Kwaadpepper\CrudPolicies\Enums\CrudAction; +use Kwaadpepper\CrudPolicies\Enums\CrudType; +use Kwaadpepper\CrudPolicies\Traits\IsCrudModel; use Rennokki\QueryCache\Traits\QueryCacheable; class Brand extends Model { + use IsCrudModel; use HasFactory; use QueryCacheable; + protected $crudLabelColumn = 'name'; + + protected $crudValueColumn = 'id'; + protected $cacheFor = 0; protected $fillable = [ @@ -20,6 +29,34 @@ class Brand extends Model public function __construct(array $attributes = []) { $this->cacheFor = config('api.servicesDBCache') * 60; + + self::$editableProperties = [ + 'name' => [ + 'label' => Str::ucfirst(trans('models.common.name')), + 'type' => CrudType::string(), + 'validate' => [ + 'min:5', + 'max:255' + ], + 'actions' => [ + CrudAction::viewAny(), + CrudAction::view(), + CrudAction::create(), + CrudAction::update() + ] + ], + 'services' => [ + 'label' => Str::ucfirst(Str::plural(trans('models.models.service'))), + 'type' => CrudType::belongsToMany(), + 'belongsToMany' => Service::class, + 'belongsToManyLabel' => 'name', + 'actions' => [ + CrudAction::view(), + CrudAction::create(), + CrudAction::update(), + ] + ] + ]; parent::__construct($attributes); } diff --git a/app/Models/CustomerInfo.php b/app/Models/CustomerInfo.php index a47f6c0..b5ebb77 100644 --- a/app/Models/CustomerInfo.php +++ b/app/Models/CustomerInfo.php @@ -100,6 +100,16 @@ class CustomerInfo extends Model return $this->belongsTo(Customer::class); } + /** + * CustomerLogin HasOneThrough relation + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function login() + { + return $this->customer->login($this->brand); + } + /** * Brand BelongsTo relation * diff --git a/app/Models/Service.php b/app/Models/Service.php index fc571de..205fc6f 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -8,13 +8,21 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Str; +use Kwaadpepper\CrudPolicies\Enums\CrudAction; +use Kwaadpepper\CrudPolicies\Enums\CrudType; +use Kwaadpepper\CrudPolicies\Traits\IsCrudModel; use Rennokki\QueryCache\Traits\QueryCacheable; class Service extends Model { + use IsCrudModel; use HasFactory; use QueryCacheable; + protected $crudLabelColumn = 'name'; + + protected $crudValueColumn = 'id'; + protected $cacheFor = 0; protected $fillable = [ @@ -24,6 +32,32 @@ class Service extends Model public function __construct(array $attributes = []) { $this->cacheFor = config('api.servicesDBCache') * 60; + + self::$editableProperties = [ + 'name' => [ + 'label' => Str::ucfirst(trans('models.common.name')), + 'type' => CrudType::string(), + 'validate' => [ + 'min:5', + 'max:255' + ], + 'actions' => [ + CrudAction::viewAny(), + CrudAction::view(), + CrudAction::create(), + CrudAction::update() + ] + ], + 'brand_id' => [ + 'label' => Str::ucfirst(trans('models.models.brand')), + 'type' => CrudType::belongsTo(), + 'belongsTo' => Brand::class, + 'actions' => [ + CrudAction::viewAny(), + CrudAction::view() + ] + ], + ]; parent::__construct($attributes); } diff --git a/app/Models/SingleOptin.php b/app/Models/SingleOptin.php index 7776219..f71f82c 100644 --- a/app/Models/SingleOptin.php +++ b/app/Models/SingleOptin.php @@ -4,15 +4,76 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Str; +use Kwaadpepper\CrudPolicies\Enums\CrudAction; +use Kwaadpepper\CrudPolicies\Enums\CrudType; +use Kwaadpepper\CrudPolicies\Traits\IsCrudModel; class SingleOptin extends Model { use HasFactory; + use IsCrudModel; + + protected $crudLabelColumn = 'email'; + + protected $crudValueColumn = 'id'; protected $fillable = [ 'email' ]; + public function __construct(array $attributes = []) + { + self::$editableProperties = [ + 'email' => [ + 'label' => Str::ucfirst(trans('models.common.email')), + 'type' => CrudType::email(), + 'validate' => [ + 'required', + 'email:rfc,dns', + // @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed + function ($attribute, $value, $fail) { + $q = static::query(); + if (request()->user) { + $q = $q->where('id', '!=', $this->id); + } + if ($q->where('email', $value)->exists()) { + $fail(__(':attribute est déjà utilisé', [ + 'attribute' => $attribute + ])); + } + } + ], + 'actions' => [ + CrudAction::viewAny(), + CrudAction::view(), + CrudAction::create(), + CrudAction::update() + ] + ], + 'brand_id' => [ + 'label' => Str::ucfirst(trans('models.models.brand')), + 'type' => CrudType::belongsTo(), + 'belongsTo' => Brand::class, + 'actions' => [ + CrudAction::viewAny(), + CrudAction::view() + ] + ], + 'created_at' => [ + 'label' => Str::ucfirst(trans('models.common.optinDate')), + 'type' => CrudType::string(), + 'readonly' => true, + 'actions' => [ + CrudAction::viewAny(), + CrudAction::view(), + CrudAction::update() + ] + ], + ]; + parent::__construct($attributes); + } + /** * Brand BelongsTo relation * diff --git a/app/Policies/BrandPolicy.php b/app/Policies/BrandPolicy.php new file mode 100644 index 0000000..02579b1 --- /dev/null +++ b/app/Policies/BrandPolicy.php @@ -0,0 +1,28 @@ +policies = [ + 'brand' => [ + 'viewAny' => USR::make('everyOne'), + 'update' => USR::make('everyOne'), + 'create' => USR::make('everyOne') + ] + ]; + } +} diff --git a/app/Policies/CustomerPolicy.php b/app/Policies/CustomerPolicy.php index 32e33ee..3eea775 100644 --- a/app/Policies/CustomerPolicy.php +++ b/app/Policies/CustomerPolicy.php @@ -4,12 +4,33 @@ namespace App\Policies; use App\Models\Customer; use App\Models\Service; +use App\Policies\Rules\UserStaticRules as USR; use Illuminate\Auth\Access\HandlesAuthorization; +use Kwaadpepper\CrudPolicies\Policies\RootPolicy; -class CustomerPolicy +class CustomerPolicy extends RootPolicy { use HandlesAuthorization; + /** + * Init policies on call + * + * @return void + */ + public function setPolicies() + { + /** + * This first rule to return true in a policy action authorises the action + */ + $this->policies = [ + 'customer' => [ + 'viewAny' => USR::make('everyOne'), + 'view' => USR::make('everyOne'), + 'delete' => USR::make('everyOne') + ] + ]; + } + public function customerBelongsToService(Service $service, Customer $customer) { return !\is_null($customer->login($service->brand)); diff --git a/app/Policies/Rules/UserStaticRules.php b/app/Policies/Rules/UserStaticRules.php new file mode 100644 index 0000000..e68624c --- /dev/null +++ b/app/Policies/Rules/UserStaticRules.php @@ -0,0 +1,17 @@ +policies = [ + 'service' => [ + 'viewAny' => USR::make('everyOne'), + 'view' => USR::make('everyOne'), + 'update' => USR::make('everyOne'), + 'create' => USR::make('everyOne') + ] + ]; + } +} diff --git a/app/Policies/SingleOptinPolicy.php b/app/Policies/SingleOptinPolicy.php new file mode 100644 index 0000000..a47161b --- /dev/null +++ b/app/Policies/SingleOptinPolicy.php @@ -0,0 +1,27 @@ +policies = [ + 'singleoptin' => [ + 'viewAny' => USR::make('everyOne'), + 'delete' => USR::make('everyOne') + ] + ]; + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index df4b423..73af49a 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -3,7 +3,11 @@ namespace App\Providers; use Illuminate\Http\Resources\Json\JsonResource; +use Illuminate\Pagination\Paginator; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\URL; +use Illuminate\Support\Facades\View; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider @@ -31,5 +35,14 @@ class AppServiceProvider extends ServiceProvider if (!in_array(config('app.env'), ['local', 'testing'])) { URL::forceScheme('https'); } + + Paginator::useBootstrap(); + + $appInfos = Cache::remember('composer', 360, function () { + return json_decode(File::get(\app_path('../composer.json'))); + }); + View::share('name', $appInfos->name); + View::share('version', $appInfos->version); + View::share('license', $appInfos->license); } } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index c0b3794..f57fef8 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -2,8 +2,11 @@ namespace App\Providers; +use App\Models\Brand; use App\Models\Customer; use App\Models\CustomerInfo; +use App\Models\Service; +use App\Models\SingleOptin; use Illuminate\Cache\RateLimiting\Limit; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; @@ -36,6 +39,10 @@ class RouteServiceProvider extends ServiceProvider Route::middleware('web')->namespace($this->namespace)->group(base_path('routes/web.php')); }); + Route::model('brand', Brand::class); + Route::model('service', Service::class); + Route::model('single_optin', SingleOptin::class); + Route::bind('customer', function ($value) { if (\ctype_digit($value)) { $customer = Customer::where('id', '=', $value)->firstOrFail(); diff --git a/clients/V2 b/clients/V2 index b208c78..14d966a 160000 --- a/clients/V2 +++ b/clients/V2 @@ -1 +1 @@ -Subproject commit b208c78b97e68c078345620a5a023186a1753ee8 +Subproject commit 14d966a62b297a299e0602e2b4bc5a3abff6cb56 diff --git a/composer.json b/composer.json index 15400c8..5fb6fdd 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "ldc/ldccrmv2client", "type": "project", - "version": "2.1.5", + "version": "2.1.6", "description": "LDC CRM V2", "authors": [ { @@ -32,11 +32,13 @@ "fideloper/proxy": "^4.4", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", + "kwaadpepper/crud-policies": "^0.1.15", "kwaadpepper/enum": "^2.0", "laravel-lang/lang": "~7.0", "laravel/framework": "^8.39", "laravel/tinker": "^2.5", - "rennokki/laravel-eloquent-query-cache": "^3.0" + "rennokki/laravel-eloquent-query-cache": "^3.0", + "spatie/laravel-mix-preload": "^1.2" }, "require-dev": { "facade/ignition": "^2.5", diff --git a/composer.lock b/composer.lock index da781a3..833ee21 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": "5b5341478a5d91d067fb818f97d244fd", + "content-hash": "d0eded9c5677a512f367b9d29c701714", "packages": [ { "name": "arondeparon/laravel-request-sanitizer", @@ -1171,6 +1171,124 @@ ], "time": "2020-12-29T14:50:06+00:00" }, + { + "name": "facade/flare-client-php", + "version": "1.8.1", + "source": { + "type": "git", + "url": "https://github.com/facade/flare-client-php.git", + "reference": "47b639dc02bcfdfc4ebb83de703856fa01e35f5f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/facade/flare-client-php/zipball/47b639dc02bcfdfc4ebb83de703856fa01e35f5f", + "reference": "47b639dc02bcfdfc4ebb83de703856fa01e35f5f", + "shasum": "" + }, + "require": { + "facade/ignition-contracts": "~1.0", + "illuminate/pipeline": "^5.5|^6.0|^7.0|^8.0", + "php": "^7.1|^8.0", + "symfony/http-foundation": "^3.3|^4.1|^5.0", + "symfony/mime": "^3.4|^4.0|^5.1", + "symfony/var-dumper": "^3.4|^4.0|^5.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.14", + "phpunit/phpunit": "^7.5.16", + "spatie/phpunit-snapshot-assertions": "^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Facade\\FlareClient\\": "src" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Send PHP errors to Flare", + "homepage": "https://github.com/facade/flare-client-php", + "keywords": [ + "exception", + "facade", + "flare", + "reporting" + ], + "support": { + "issues": "https://github.com/facade/flare-client-php/issues", + "source": "https://github.com/facade/flare-client-php/tree/1.8.1" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2021-05-31T19:23:29+00:00" + }, + { + "name": "facade/ignition-contracts", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/facade/ignition-contracts.git", + "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/facade/ignition-contracts/zipball/3c921a1cdba35b68a7f0ccffc6dffc1995b18267", + "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267", + "shasum": "" + }, + "require": { + "php": "^7.3|^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^v2.15.8", + "phpunit/phpunit": "^9.3.11", + "vimeo/psalm": "^3.17.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Facade\\IgnitionContracts\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://flareapp.io", + "role": "Developer" + } + ], + "description": "Solution contracts for Ignition", + "homepage": "https://github.com/facade/ignition-contracts", + "keywords": [ + "contracts", + "flare", + "ignition" + ], + "support": { + "issues": "https://github.com/facade/ignition-contracts/issues", + "source": "https://github.com/facade/ignition-contracts/tree/1.0.2" + }, + "time": "2020-10-16T08:27:54+00:00" + }, { "name": "fideloper/proxy", "version": "4.4.1", @@ -1610,6 +1728,69 @@ }, "time": "2021-06-30T20:03:07+00:00" }, + { + "name": "kwaadpepper/crud-policies", + "version": "0.1.15", + "source": { + "type": "git", + "url": "https://github.com/Kwaadpepper/crud-policies.git", + "reference": "cf471dc2dad7851474ee005fbc8dfdfe05096b84" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Kwaadpepper/crud-policies/zipball/cf471dc2dad7851474ee005fbc8dfdfe05096b84", + "reference": "cf471dc2dad7851474ee005fbc8dfdfe05096b84", + "shasum": "" + }, + "require": { + "facade/flare-client-php": "^1.8", + "illuminate/support": "~7|~8", + "kwaadpepper/enum": "^2.0", + "laravel/framework": "~7|~8" + }, + "require-dev": { + "orchestra/testbench": "^6.13", + "phpunit/phpunit": "~9.0", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Kwaadpepper\\CrudPolicies\\Providers\\CrudPoliciesServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Kwaadpepper\\CrudPolicies\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jérémy Munsch", + "email": "github@jeremydev.ovh", + "homepage": "https://jeremydev.ovh" + } + ], + "description": "Makes CRUD easy, make policies easy and everyone happy", + "homepage": "https://github.com/kwaadpepper/crud-policies", + "keywords": [ + "Scafolding", + "crud", + "laravel", + "policies" + ], + "support": { + "issues": "https://github.com/Kwaadpepper/crud-policies/issues", + "source": "https://github.com/Kwaadpepper/crud-policies/tree/0.1.15" + }, + "time": "2021-08-27T10:42:55+00:00" + }, { "name": "kwaadpepper/enum", "version": "2.0.0", @@ -3345,6 +3526,74 @@ ], "time": "2021-07-17T17:42:40+00:00" }, + { + "name": "spatie/laravel-mix-preload", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-mix-preload.git", + "reference": "b89dc366fa8a714ecb3d6af836db3c038795a3b6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-mix-preload/zipball/b89dc366fa8a714ecb3d6af836db3c038795a3b6", + "reference": "b89dc366fa8a714ecb3d6af836db3c038795a3b6", + "shasum": "" + }, + "require": { + "illuminate/support": "^6.0|^7.0|^8.0", + "php": "^7.2.5|^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.0|^9.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\MixPreload\\MixPreloadServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Spatie\\MixPreload\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sebastian De Deyne", + "email": "sebastian@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Add preload and prefetch links based your Mix manifest", + "homepage": "https://github.com/spatie/laravel-mix-preload", + "keywords": [ + "laravel-mix-preload", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-mix-preload/issues", + "source": "https://github.com/spatie/laravel-mix-preload/tree/1.2.2" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://www.patreon.com/spatie", + "type": "patreon" + } + ], + "time": "2021-01-04T08:01:50+00:00" + }, { "name": "swiftmailer/swiftmailer", "version": "v6.2.7", @@ -6081,71 +6330,6 @@ ], "time": "2020-11-10T18:47:58+00:00" }, - { - "name": "facade/flare-client-php", - "version": "1.8.1", - "source": { - "type": "git", - "url": "https://github.com/facade/flare-client-php.git", - "reference": "47b639dc02bcfdfc4ebb83de703856fa01e35f5f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/facade/flare-client-php/zipball/47b639dc02bcfdfc4ebb83de703856fa01e35f5f", - "reference": "47b639dc02bcfdfc4ebb83de703856fa01e35f5f", - "shasum": "" - }, - "require": { - "facade/ignition-contracts": "~1.0", - "illuminate/pipeline": "^5.5|^6.0|^7.0|^8.0", - "php": "^7.1|^8.0", - "symfony/http-foundation": "^3.3|^4.1|^5.0", - "symfony/mime": "^3.4|^4.0|^5.1", - "symfony/var-dumper": "^3.4|^4.0|^5.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^2.14", - "phpunit/phpunit": "^7.5.16", - "spatie/phpunit-snapshot-assertions": "^2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "Facade\\FlareClient\\": "src" - }, - "files": [ - "src/helpers.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Send PHP errors to Flare", - "homepage": "https://github.com/facade/flare-client-php", - "keywords": [ - "exception", - "facade", - "flare", - "reporting" - ], - "support": { - "issues": "https://github.com/facade/flare-client-php/issues", - "source": "https://github.com/facade/flare-client-php/tree/1.8.1" - }, - "funding": [ - { - "url": "https://github.com/spatie", - "type": "github" - } - ], - "time": "2021-05-31T19:23:29+00:00" - }, { "name": "facade/ignition", "version": "2.12.0", @@ -6222,59 +6406,6 @@ }, "time": "2021-08-24T09:53:54+00:00" }, - { - "name": "facade/ignition-contracts", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/facade/ignition-contracts.git", - "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/facade/ignition-contracts/zipball/3c921a1cdba35b68a7f0ccffc6dffc1995b18267", - "reference": "3c921a1cdba35b68a7f0ccffc6dffc1995b18267", - "shasum": "" - }, - "require": { - "php": "^7.3|^8.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^v2.15.8", - "phpunit/phpunit": "^9.3.11", - "vimeo/psalm": "^3.17.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "Facade\\IgnitionContracts\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Freek Van der Herten", - "email": "freek@spatie.be", - "homepage": "https://flareapp.io", - "role": "Developer" - } - ], - "description": "Solution contracts for Ignition", - "homepage": "https://github.com/facade/ignition-contracts", - "keywords": [ - "contracts", - "flare", - "ignition" - ], - "support": { - "issues": "https://github.com/facade/ignition-contracts/issues", - "source": "https://github.com/facade/ignition-contracts/tree/1.0.2" - }, - "time": "2020-10-16T08:27:54+00:00" - }, { "name": "fakerphp/faker", "version": "v1.15.0", diff --git a/config/app.php b/config/app.php index 5bdde92..5f50516 100644 --- a/config/app.php +++ b/config/app.php @@ -227,7 +227,9 @@ return [ 'View' => Illuminate\Support\Facades\View::class, 'Carbon' => Illuminate\Support\Carbon::class, 'ArcadiaMailType' => App\Enums\ArcadiaMailType::class, - 'ArcadiaOrderType' => App\Enums\ArcadiaOrderType::class + 'ArcadiaOrderType' => App\Enums\ArcadiaOrderType::class, + 'Brand' => App\Models\Brand::class, + 'Customer' => App\Models\Customer::class ], ]; diff --git a/package.json b/package.json index e329706..5df4967 100644 --- a/package.json +++ b/package.json @@ -2,28 +2,27 @@ "private": true, "scripts": { "dev": "npm run development", - "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js", - "watch": "npm run development -- --watch", - "watch-poll": "npm run watch -- --watch-poll", - "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js", + "development": "mix", + "watch": "mix watch", + "watch-poll": "mix watch -- --watch-options-poll=1000", + "hot": "mix watch --hot", "prod": "npm run production", - "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --config=node_modules/laravel-mix/setup/webpack.config.js" + "production": "mix --production" }, "devDependencies": { - "axios": "^0.19", - "bootstrap": "^4.5.0", - "cross-env": "^7.0", - "jquery": "^3.2", - "laravel-mix": "^5.0.1", - "lodash": "^4.17.19", - "popper.js": "^1.12", - "resolve-url-loader": "^3.1.0", - "sass-loader": "^8.0.2", - "vue-template-compiler": "^2.6.12" - }, - "dependencies": { + "axios": "^0.21", + "clean-webpack-plugin": "^4.0.0-alpha.0", + "laravel-mix": "^6.0.6", + "laravel-mix-polyfill": "^3.0.0", "moment": "^2.29.1", - "sass": "^1.28.0", - "vue": "^2.6.12" + "postcss": "^8.1.14", + "postcss-discard-comments": "^4.0.2", + "resolve-url-loader": "^3.1.3", + "sass": "^1.32.11", + "sass-loader": "^11.0.1", + "swiper": "^6.6.1", + "vue": "^2.6.12", + "vue-loader": "^15.9.6", + "vue-template-compiler": "^2.6.12" } } diff --git a/public/js/app.js.LICENSE.txt b/public/js/app.js.LICENSE.txt deleted file mode 100644 index 953a26d..0000000 --- a/public/js/app.js.LICENSE.txt +++ /dev/null @@ -1,18 +0,0 @@ -/*! - * Vue.js v2.6.12 - * (c) 2014-2020 Evan You - * Released under the MIT License. - */ - -/** - * @license - * Lodash - * Copyright OpenJS Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ - -//! moment.js - -//! moment.js locale configuration diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 2d60117..6784ee9 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -1,4 +1,4 @@ { - "/js/app.js": "/js/app.js", - "/css/app.css": "/css/app.css" + "/js/preload-back.js": "/js/preload-back.js", + "/css/preload-back.css": "/css/preload-back.css" } diff --git a/public/images/logo_ldc.png b/resources/assets/images/logo_ldc.png similarity index 100% rename from public/images/logo_ldc.png rename to resources/assets/images/logo_ldc.png diff --git a/resources/js/Components/SearchOptin.vue b/resources/js/Components/SearchOptin.vue deleted file mode 100644 index 62c361b..0000000 --- a/resources/js/Components/SearchOptin.vue +++ /dev/null @@ -1,101 +0,0 @@ - - - diff --git a/resources/js/Components/SearchUser.vue b/resources/js/Components/SearchUser.vue deleted file mode 100644 index 2aa9470..0000000 --- a/resources/js/Components/SearchUser.vue +++ /dev/null @@ -1,87 +0,0 @@ - - - diff --git a/resources/js/app.js b/resources/js/app.js deleted file mode 100644 index 4c6aeb6..0000000 --- a/resources/js/app.js +++ /dev/null @@ -1,17 +0,0 @@ -require('./bootstrap'); -import moment from 'moment'; - -window.Vue = require('vue'); - -Vue.filter('formatDate', function(value) { - if (value) { - return moment(String(value)).format('DD/MM/YYYY H:mm') - } -}); - -Vue.component('search-user', require('./Components/SearchUser.vue').default); -Vue.component('search-optin', require('./Components/SearchOptin.vue').default); - -const app = new Vue({ - el: '#app', -}); diff --git a/resources/js/back.js b/resources/js/back.js new file mode 100644 index 0000000..7c36abb --- /dev/null +++ b/resources/js/back.js @@ -0,0 +1,5 @@ +require('./bootstrap'); + +require('./pages/customer.delete') +require('./pages/service.index') +require('./pages/single_optin.index') diff --git a/resources/js/pages/customer.delete.js b/resources/js/pages/customer.delete.js new file mode 100644 index 0000000..565824d --- /dev/null +++ b/resources/js/pages/customer.delete.js @@ -0,0 +1,34 @@ +let customerDelete = document.getElementById('customerDelete'); + +if (customerDelete) { + customerDelete.addEventListener('submit', (e) => { + let self = e.target + e.preventDefault() + Swal.fire({ + title: 'Supprimer ce client pour cette marque ?', + text: 'Attention cette action est irréversible, si le client n\'appartient plus à aucune marque il sera complètement retiré des bases', + icon: 'warning', + confirmButtonText: 'Je comprends le danger et suis conscient de ce que je fait', + showCancelButton: true, + cancelButtonText: 'Annuler', + confirmButtonColor: '#dc3545' + }).then((result) => { + if (result.isConfirmed) { + Swal.fire({ + title: 'Attention au conséquences', + html: 'La supression de ce compte dans la crm n\'entrainera pas ça supression dans MESBR ni dans le front cache DB (pour les sites WPCRM).

Une fois ne compte supprimé je ne pourrai plus récupérer le hashcode nécessaire pour effectuer ces opérations.

', + icon: 'info', + confirmButtonText: 'Je comprends le danger et suis conscient que celà aura des conséquences', + showCancelButton: true, + cancelButtonText: 'Annuler', + confirmButtonColor: '#dc3545' + }).then((result) => { + if (result.isConfirmed) { + self.submit() + } + }) + } + }) + }) +} + diff --git a/resources/js/pages/service.index.js b/resources/js/pages/service.index.js new file mode 100644 index 0000000..61a816d --- /dev/null +++ b/resources/js/pages/service.index.js @@ -0,0 +1,36 @@ +let genForms = document.getElementsByClassName('genToken'); + +if (genForms.length) { + for (let form of genForms) { + form.addEventListener('submit', (e) => { + let self = e.target + e.preventDefault() + Swal.fire({ + title: 'Regénérer un token ?', + text: 'Attention la regeneration empêchera le service de fonctionner tant que son token n\'aura pas été mis à jour', + icon: 'warning', + confirmButtonText: 'Je comprends le danger et suis conscient de ce que je fait', + showCancelButton: true, + cancelButtonText: 'Annuler', + confirmButtonColor: '#dc3545' + }).then((result) => { + if (result.isConfirmed) { + Swal.fire({ + title: 'Vous allez régénérer un token de service en production', + html: '

Je suis conscient que celà va avoir des implications et qu\'il me faudra mettre à jour le bearer token du service concerné dans son envirronement actuel

', + icon: 'info', + confirmButtonText: 'Oui, feu patate !!', + showCancelButton: true, + cancelButtonText: 'Annuler', + confirmButtonColor: '#dc3545' + }).then((result) => { + if (result.isConfirmed) { + self.submit() + } + }) + } + }) + }) + } +} + diff --git a/resources/js/pages/single_optin.index.js b/resources/js/pages/single_optin.index.js new file mode 100644 index 0000000..112407f --- /dev/null +++ b/resources/js/pages/single_optin.index.js @@ -0,0 +1,10 @@ +let brandSelect = document.getElementById('brandSelect'); +if (brandSelect) { + brandSelect.addEventListener('change', function (e) { + if (brandSelect.value !== '0') { + const url = new URL(location.href); + url.searchParams.set('brand', brandSelect.value); + location.assign(url.search); + } + }); +} diff --git a/resources/lang/en/models.php b/resources/lang/en/models.php new file mode 100644 index 0000000..4ad236d --- /dev/null +++ b/resources/lang/en/models.php @@ -0,0 +1,20 @@ + [ + 'services' => 'Services', + 'brands' => 'Brands', + 'customers' => 'Customers', + 'singleoptins' => 'Single Opt-ins' + ], + 'common' => [ + 'title' => 'Title', + 'name' => 'Name', + 'content' => 'Content', + 'visibility' => 'Visibility', + 'published' => 'Published', + 'group' => 'Group', + 'default' => 'Default', + 'optinDate' => 'Date opt-in' + ] +]; diff --git a/resources/lang/fr/models.php b/resources/lang/fr/models.php new file mode 100644 index 0000000..ddb1fee --- /dev/null +++ b/resources/lang/fr/models.php @@ -0,0 +1,20 @@ + [ + 'services' => 'Services', + 'brands' => 'Marques', + 'customers' => 'Clients', + 'singleoptins' => 'Opt-ins uniques' + ], + 'common' => [ + 'title' => 'Titre', + 'name' => 'Nom', + 'content' => 'Contenu', + 'visibility' => 'Visibilitée', + 'published' => 'Publié', + 'group' => 'Groupe', + 'default' => 'Par défaut', + 'optinDate' => 'Date opt-in' + ] +]; diff --git a/resources/sass/_dashboard.scss b/resources/sass/_dashboard.scss deleted file mode 100644 index 0a6abdb..0000000 --- a/resources/sass/_dashboard.scss +++ /dev/null @@ -1,103 +0,0 @@ -body { - font-size: .875rem; -} - -.feather { - width: 16px; - height: 16px; - vertical-align: text-bottom; -} - -/* - * Sidebar - */ - -.sidebar { - position: fixed; - top: 0; - bottom: 0; - left: 0; - z-index: 100; /* Behind the navbar */ - padding: 48px 0 0; /* Height of navbar */ - box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1); -} - -@media (max-width: 767.98px) { - .sidebar { - top: 5rem; - } -} - -.sidebar-sticky { - position: relative; - top: 0; - height: calc(100vh - 48px); - padding-top: .5rem; - overflow-x: hidden; - overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ -} - -@supports ((position: -webkit-sticky) or (position: sticky)) { - .sidebar-sticky { - position: -webkit-sticky; - position: sticky; - } -} - -.sidebar .nav-link { - font-weight: 500; - color: #333; -} - -.sidebar .nav-link .feather { - margin-right: 4px; - color: #999; -} - -.sidebar .nav-link.active { - color: #007bff; -} - -.sidebar .nav-link:hover .feather, -.sidebar .nav-link.active .feather { - color: inherit; -} - -.sidebar-heading { - font-size: .75rem; - text-transform: uppercase; -} - -/* - * Navbar - */ - -.navbar-brand { - padding-top: .75rem; - padding-bottom: .75rem; - font-size: 1rem; - background-color: rgba(0, 0, 0, .25); - box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25); -} - -.navbar .navbar-toggler { - top: .25rem; - right: 1rem; -} - -.navbar .form-control { - padding: .75rem 1rem; - border-width: 0; - border-radius: 0; -} - -.form-control-dark { - color: #fff; - background-color: rgba(255, 255, 255, .1); - border-color: rgba(255, 255, 255, .1); -} - -.form-control-dark:focus { - border-color: transparent; - box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); -} diff --git a/resources/sass/_layout.scss b/resources/sass/_layout.scss new file mode 100644 index 0000000..4b2e2f3 --- /dev/null +++ b/resources/sass/_layout.scss @@ -0,0 +1,17 @@ +.bodyFull { + margin: 0 !important; + padding: 0 !important; + min-height: calc(100vh - #{$navBarHeight} - #{$footerHeight}); +} + +#app { + & > .navbar { + height: $navBarHeight; + } + #footer { + height: $footerHeight; + padding: 0 !important; + color: $body-bg; + background-color: $footerBgColor; + } +} diff --git a/resources/sass/_variables.scss b/resources/sass/_variables.scss index 5af6218..b5d70bc 100644 --- a/resources/sass/_variables.scss +++ b/resources/sass/_variables.scss @@ -22,3 +22,7 @@ $theme-colors: ( "primary": #3176C4, "secondary": #E7374B ); + +$navBarHeight: 4rem; +$footerHeight: 3rem; +$footerBgColor: #161616; diff --git a/resources/sass/app.scss b/resources/sass/app.scss deleted file mode 100644 index 71428e3..0000000 --- a/resources/sass/app.scss +++ /dev/null @@ -1,10 +0,0 @@ -// Fonts -@import url('https://fonts.googleapis.com/css?family=Nunito'); - -// Variables -@import 'variables'; - -// Bootstrap -@import '~bootstrap/scss/bootstrap'; - -@import "dashboard"; diff --git a/resources/sass/back.scss b/resources/sass/back.scss new file mode 100644 index 0000000..55e4403 --- /dev/null +++ b/resources/sass/back.scss @@ -0,0 +1,5 @@ +// Variables +@import 'variables'; +@import 'layout'; + +@import "pages/login"; diff --git a/resources/sass/pages/login.scss b/resources/sass/pages/login.scss new file mode 100644 index 0000000..79f3d3c --- /dev/null +++ b/resources/sass/pages/login.scss @@ -0,0 +1,54 @@ +.bd-placeholder-img { + font-size: 1.125rem; + text-anchor: middle; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +@media (min-width: 768px) { + .bd-placeholder-img-lg { + font-size: 3.5rem; + } +} +div.login { + height: 100%; + display: -ms-flexbox; + display: flex; + -ms-flex-align: center; + align-items: center; + padding-top: 40px; + padding-bottom: 40px; + background-color: #f5f5f5; +} + +.form-signin { + width: 100%; + max-width: 330px; + padding: 15px; + margin: auto; +} +.form-signin .checkbox { + font-weight: 400; +} +.form-signin .form-control { + position: relative; + box-sizing: border-box; + height: auto; + padding: 10px; + font-size: 16px; +} +.form-signin .form-control:focus { + z-index: 2; +} +.form-signin input[type="email"] { + margin-bottom: -1px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} +.form-signin input[type="password"] { + margin-bottom: 10px; + border-top-left-radius: 0; + border-top-right-radius: 0; +} diff --git a/resources/views/brand/index.blade.php b/resources/views/brand/index.blade.php new file mode 100644 index 0000000..5d0906c --- /dev/null +++ b/resources/views/brand/index.blade.php @@ -0,0 +1,158 @@ +@extends($viewLayout) + +@section('title', sprintf('%s - %s', transFb(sprintf('models.classes.%s', strtolower(Str::plural(class_basename($modelClass)))), Str::plural(class_basename($modelClass))), __('crud-policies::crud.viewAny'))) +@section('description', sprintf('%s %s', __('crud-policies::crud.viewAny'), trans(Str::plural(class_basename($modelClass))))) +@section('metaIndex', 'noindex,nofollow') + +@section('content') +
+ @include('crud-policies::crud.modules.flashMessage') +
+ @include('crud-policies::crud.modules.breadcrumb', ['action' => CrudAction::viewAny()]) + @include('crud-policies::crud.modules.actionbar.bar', ['action' => CrudAction::viewAny()]) +
+
+
+
+
+
+ + + + @if(request()->brand) + + @endif + {{ __('crud-policies::crud.reset') }} + +
+
+
+
+ + + + @foreach ($modelClass::getEditableProperties() as $colname => $prop) + @if(in_array(CrudAction::viewAny(), $prop['actions'])) + @switch($prop['type']) + @case(CrudType::password()) + {{-- Ignore --}} + @break + @default + + @endswitch + @endif + @endforeach + + + + + + + + @if(count($models)) + + {{-- INIT QUERIES for OPTIMIZING --}} + @foreach ($modelClass::getEditableProperties() as $fieldName => $prop) + @if($prop['type']->equals(CrudType::order())) + @php ${"$modelTable$fieldName"} = $modelClass::max($fieldName); @endphp + @endif + @if($prop['type']->equals(CrudType::belongsTo())) + @php try { $models->load(Str::singular((new $prop['belongsTo']())->getTable())); } catch(\Exception $e) {} @endphp + @endif + @if($prop['type']->equals(CrudType::belongsToMany())) + @php $models->load("$fieldName"); @endphp + @endif + @endforeach + + {{-- DISPLAY MODELS --}} + @foreach($models as $model) + + @foreach ($modelClass::getEditableProperties() as $fieldName => $prop) + @if(in_array(CrudAction::viewAny(), $prop['actions'])) + @switch($prop['type']) + @case(CrudType::belongsToMany() and $prop['belongsToMany'] === \App\Models\Project::class) + + @break + @case(CrudType::password()) + {{-- Ignore --}} + @break + @default + + @endswitch + @endif + @endforeach + + {{-- INFO COLS --}} + + + + + {{-- MODEL ACTIONS --}} + + + @endforeach + @else + + + + @endif + +
+ {{ $prop['label'] }} + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'desc' and session("crud.$modelTable.sort_col") === $colname)) +  ↓  + @endif + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'asc' and session("crud.$modelTable.sort_col") === $colname)) +  ↑  + @endif + + {{ __('Nombre de comptes')}} + + {{ __('Nombre d\'optins')}} + + {{ __('Date d\'ajout en base')}} + + @if(session("crud.$modelTable.sort_way") and session("crud.$modelTable.sort_col")) + ⌫ + @endif +
+ @foreach($model->{$fieldName} as $pSite) + {{ $pSite->{$prop['belongsToManyLabel']} }} + @endforeach + @include('crud-policies::crud.printfield', [ + 'action' => CrudAction::viewAny(), + 'field' => $model->{$fieldName}, + 'props' => $prop, + "$modelTable$fieldName" => ${"$modelTable$fieldName"} ?? null + ]){{ $model->getAccountsAttribute() }}{{ $model->getTotalOptinsAttribute() }}{{ $model->created_at->format('m/d/Y à H:i') }} +
+ @can('view', $model) + {{ __('crud-policies::crud.view') }} + @endcan + @can('update', $model) + {{ __('crud-policies::crud.edit') }} + @endcan + @can('delete', $model) +
+ @csrf + @method('DELETE') + +
+ @endcan + @can('viewAny', \App\Models\Log::class) + {{ __('Journaux') }} + @endcan + @can('viewAny', \App\Models\File::class) + {{ __('Fichiers') }} + @endcan +
+
+ {{ __('crud-policies::crud.nothingtoshow') }} +
+ {{ $models->links() }} +
+
+@include('crud-policies::crud.modules.scriptConstants') +@endsection diff --git a/resources/views/brands/index.blade.php b/resources/views/brands/index.blade.php deleted file mode 100644 index 1c63dbd..0000000 --- a/resources/views/brands/index.blade.php +++ /dev/null @@ -1,28 +0,0 @@ -@extends('layout.app') - -@section('content') -
-

{{ __('Gestion des marques') }} {{ __('Liste') }}

- {{ __('Ajouter') }} -
- - - - - - - - - - @foreach ($brands as $brand) - - - - - - - - @endforeach - -
{{ __('Nom de la marque') }}{{ __('Nombre de comptes') }}{{ __('Nombre d\'optins') }}{{ __('Date d\'ajout en base') }}
{{ $brand->name }}{{ $brand->accounts }}{{ $brand->total_optins }}{{ Carbon::parse($brand->created_at)->format('d/m/Y à H:i') }}{{ __('Modifier') }}
-@endsection diff --git a/resources/views/brands/manage.blade.php b/resources/views/brands/manage.blade.php deleted file mode 100644 index 036e0f0..0000000 --- a/resources/views/brands/manage.blade.php +++ /dev/null @@ -1,30 +0,0 @@ -@extends('layout.app') - -@section('content') -
-

{{ __('Gestion des marques') }} {{ __('Gestion') }}

- @if ($errors->any()) -
    - @foreach(session('errors')->all(':message') as $error) -
  • {{ $error }}
  • - @endforeach -
- @endif - @if (session('success')) - {!! session('success') !!} - @endif - {{ __('Retour') }} -
-
-
- @csrf -
- - -
-
- -
-
-
-@endsection diff --git a/resources/views/customer/index-tableHeaders.blade.php b/resources/views/customer/index-tableHeaders.blade.php new file mode 100644 index 0000000..56cf8c8 --- /dev/null +++ b/resources/views/customer/index-tableHeaders.blade.php @@ -0,0 +1,63 @@ + + @php $colname = 'email' @endphp + {{ __('Email')}} + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'desc' and session("crud.$modelTable.sort_col") === $colname)) +  ↓  + @endif + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'asc' and session("crud.$modelTable.sort_col") === $colname)) +  ↑  + @endif + + + @php $colname = 'lastname' @endphp + {{ __('Nom')}} + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'desc' and session("crud.$modelTable.sort_col") === $colname)) +  ↓  + @endif + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'asc' and session("crud.$modelTable.sort_col") === $colname)) +  ↑  + @endif + + + @php $colname = 'firstname' @endphp + {{ __('Prénom')}} + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'desc' and session("crud.$modelTable.sort_col") === $colname)) +  ↓  + @endif + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'asc' and session("crud.$modelTable.sort_col") === $colname)) +  ↑  + @endif + + + @php $colname = 'optin' @endphp + {{ __('Opt-In')}} + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'desc' and session("crud.$modelTable.sort_col") === $colname)) +  ↓  + @endif + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'asc' and session("crud.$modelTable.sort_col") === $colname)) +  ↑  + @endif + + + @php $colname = 'brand_id' @endphp + {{ __('Marque')}} + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'desc' and session("crud.$modelTable.sort_col") === $colname)) +  ↓  + @endif + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'asc' and session("crud.$modelTable.sort_col") === $colname)) +  ↑  + @endif + + + @php $colname = 'status' @endphp + {{ __('Activé ?')}} + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'desc' and session("crud.$modelTable.sort_col") === $colname)) +  ↓  + @endif + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'asc' and session("crud.$modelTable.sort_col") === $colname)) +  ↑  + @endif + + + {{ __('Voir')}} + diff --git a/resources/views/customer/index.blade.php b/resources/views/customer/index.blade.php new file mode 100644 index 0000000..80c2959 --- /dev/null +++ b/resources/views/customer/index.blade.php @@ -0,0 +1,104 @@ +@extends('layouts.app') + +@section('title', sprintf('%s - %s', transFb(sprintf('models.classes.%s', strtolower(Str::plural(class_basename($modelClass)))), Str::plural(class_basename($modelClass))), __('crud-policies::crud.viewAny'))) +@section('description', sprintf('%s %s', __('crud-policies::crud.viewAny'), trans(Str::plural(class_basename($modelClass))))) +@section('metaIndex', 'noindex,nofollow') + +@section('content') +
+ @include('crud-policies::crud.modules.flashMessage') +
+ @include('crud-policies::crud.modules.breadcrumb', ['action' => CrudAction::viewAny()]) + @include('crud-policies::crud.modules.actionbar.bar', ['action' => CrudAction::viewAny()]) +
+
+
+
+
+
+ + + + + + + @if(request()->brand) + + @endif + {{ __('crud-policies::crud.reset') }} + +
+
+
+
+ + + + @include('customer.index-tableHeaders') + + + + + @if(count($customers)) + + {{-- DISPLAY MODELS --}} + @foreach($customers as $customerInfo) + + + + + + + + + + {{-- MODEL ACTIONS --}} + + + @endforeach + @else + + + + @endif + +
+ @if(session("crud.$modelTable.sort_way") and session("crud.$modelTable.sort_col")) + ⌫ + @endif +
+ {{ $customerInfo->customer->email }} + + {{ $customerInfo->firstname }} + + {{ $customerInfo->lastname }} + + {{ $customerInfo->optin ? 'Oui' :'Non' }} + + {{ $customerInfo->brand->name }} + + {{ $customerInfo->login()->status ? 'Oui' :'Non' }} + + +
+ {{ __('crud-policies::crud.nothingtoshow') }} +
+ {{ $customers->links() }} +
+
+@include('crud-policies::crud.modules.scriptConstants') +@endsection diff --git a/resources/views/customer/show.blade.php b/resources/views/customer/show.blade.php new file mode 100644 index 0000000..0b12f77 --- /dev/null +++ b/resources/views/customer/show.blade.php @@ -0,0 +1,113 @@ +@extends('layouts.app') + +@section('title', sprintf('%s - %s', transFb(sprintf('models.classes.%s', strtolower(Str::plural(class_basename($modelClass)))), Str::plural(class_basename($modelClass))), __('crud-policies::crud.viewAny'))) +@section('description', sprintf('%s %s', __('crud-policies::crud.viewAny'), trans(Str::plural(class_basename($modelClass))))) +@section('metaIndex', 'noindex,nofollow') + +@section('content') +
+ @include('crud-policies::crud.modules.flashMessage') +
+ +
+
+
+
+
+

{{ __('Informations du client') }} {{ $customerInfos->firstname }} {{ $customerInfos->lastname }} - {{ Str::singular(__('models.classes.brands')) }} {{ $customerInfos->brand->name }}

+ Retour +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @if($customerInfos->customer->optInHistory()->orderBy('created_at', 'DESC')->exists()) + + @else + + @endif + + + + + + + + + + + + + + + + + + + + + + +
{{ __('Email') }}{{ $customerInfos->customer->email }}
Prénom{{ $customerInfos->firstname }}
Nom{{ $customerInfos->lastname }}
Date de naissance{{ \Carbon\Carbon::parse($customerInfos->birth_date)->format('d/m/Y') }}
Téléphone{{ $customerInfos->phone }}
Adresse{{ $customerInfos->address }}
Adresse complémentaire{{ $customerInfos->address2 }}
Pays{{ $customerInfos->country }}
Ville{{ $customerInfos->city }}
Code postal{{ $customerInfos->postcode }}
Abonné à la newsletter{{ $customerInfos->opt_in === 1 ? "Oui" : "Non" }}
Date de la dernière modification de l'abonnement{{ \Carbon\Carbon::parse($customerInfos->customer->optInHistory()->orderBy('created_at', 'DESC')->first()->created_at)->format('d/m/Y à H:i') }}
Dernière connexion{{ \Carbon\Carbon::parse($customerLogin->last_connection)->format('d/m/Y à H:i') }}
Status du compte{{ $customerLogin->status === 1 ? "Activé" : "Non activé" }}
Hashcode{{ $customerInfos->hashcode }}
Date de création{{ \Carbon\Carbon::parse($customerInfos->created_at)->format('d/m/Y à H:i') }}
Date de modification{{ \Carbon\Carbon::parse($customerInfos->updated_at)->format('d/m/Y à H:i') }}
+
+ @csrf + @method('DELETE') + +
+
+
+@include('crud-policies::crud.modules.scriptConstants') +@endsection diff --git a/resources/views/customers/index.blade.php b/resources/views/customers/index.blade.php deleted file mode 100644 index ba4ad56..0000000 --- a/resources/views/customers/index.blade.php +++ /dev/null @@ -1,23 +0,0 @@ -@extends('layout.app') - -@section('content') -@if (session()->has('success')) -
-
-

{{ session()->get('success') }}

-
-
-@endif -@if ($errors->any()) -
-
-
    - @foreach ($errors->all() as $error) -
  • {{ $error }}
  • - @endforeach -
-
-
-@endif - -@endsection diff --git a/resources/views/customers/show.blade.php b/resources/views/customers/show.blade.php deleted file mode 100644 index 2005343..0000000 --- a/resources/views/customers/show.blade.php +++ /dev/null @@ -1,98 +0,0 @@ -@extends('layout.app') - -@section('content') -
-

Informations du client {{ $customerInfos->firstname }} {{ $customerInfos->lastname }} - Marque {{ $customerInfos->brand->name }}

- Retour -
- @if ($errors->any()) -
-
    - @foreach ($errors->all() as $error) -
  • {{ $error }}
  • - @endforeach -
-
- @endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @if($customerInfos->customer->optInHistory()->orderBy('created_at', 'DESC')->exists()) - - @else - - @endif - - - - - - - - - - - - - - - - - - - - - - -
Email{{ $customerInfos->customer->email }}
Prénom{{ $customerInfos->firstname }}
Nom{{ $customerInfos->lastname }}
Date de naissance{{ \Carbon\Carbon::parse($customerInfos->birth_date)->format('d/m/Y') }}
Téléphone{{ $customerInfos->phone }}
Adresse{{ $customerInfos->address }}
Adresse complémentaire{{ $customerInfos->address2 }}
Pays{{ $customerInfos->country }}
Ville{{ $customerInfos->city }}
Code postal{{ $customerInfos->postcode }}
Abonné à la newsletter{{ $customerInfos->opt_in === 1 ? "Oui" : "Non" }}
Date de la dernière modification de l'abonnement{{ \Carbon\Carbon::parse($customerInfos->customer->optInHistory()->orderBy('created_at', 'DESC')->first()->created_at)->format('d/m/Y à H:i') }}
Dernière connexion{{ \Carbon\Carbon::parse($customerLogin->last_connection)->format('d/m/Y à H:i') }}
Status du compte{{ $customerLogin->status === 1 ? "Activé" : "Non activé" }}
Hashcode{{ $customerInfos->hashcode }}
Date de création{{ \Carbon\Carbon::parse($customerInfos->created_at)->format('d/m/Y à H:i') }}
Date de modification{{ \Carbon\Carbon::parse($customerInfos->updated_at)->format('d/m/Y à H:i') }}
-
- @csrf - @method('DELETE') - -
-@endsection diff --git a/resources/views/layout/app.blade.php b/resources/views/layout/app.blade.php deleted file mode 100644 index 84fe32e..0000000 --- a/resources/views/layout/app.blade.php +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - Tableau de bord - - - - - - -
- - -
-
- - -
- @yield('content') -
-
-
-
- - @yield('scripts') - - diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php new file mode 100644 index 0000000..c93ef72 --- /dev/null +++ b/resources/views/layouts/app.blade.php @@ -0,0 +1,35 @@ + + + + @include('layouts.backend.head') + @stack('styles') + @crudPoliciesCSS() + + +
+ @include('layouts.backend.navbar') +
+
+ @if(isset($modelsClasses)) + @include('layouts.backend.sidenav') +
+ @else +
+ @endif + @yield('content') +
+
+
+ @include('layouts.backend.footer') +
+
+
+ @stack('scriptsConstants') + @include('crud-policies::crud.modules.scriptConstants') + + + + @crudPoliciesJS() + @stack('scripts') + + diff --git a/resources/views/layouts/backend/footer.blade.php b/resources/views/layouts/backend/footer.blade.php new file mode 100644 index 0000000..9a24737 --- /dev/null +++ b/resources/views/layouts/backend/footer.blade.php @@ -0,0 +1,10 @@ +
+
+ {{ $license }} + - + {{ $name }} - {{ $version }} + - + LDC Web Services + © {{ date('Y') }} +
+
diff --git a/resources/views/layouts/backend/head.blade.php b/resources/views/layouts/backend/head.blade.php new file mode 100644 index 0000000..668513b --- /dev/null +++ b/resources/views/layouts/backend/head.blade.php @@ -0,0 +1,32 @@ + + + +{{ config('app.name') }}@hasSection('title') - @yield('title')@endif + + + +@hasSection('canonical') + +@else + +@endif + + +@hasSection('metaIndex') + +@else + +@endif + + +{{-- + + + --}} + +@preload('mix-manifest.json') + + + + + diff --git a/resources/views/layouts/backend/navbar.blade.php b/resources/views/layouts/backend/navbar.blade.php new file mode 100644 index 0000000..177643a --- /dev/null +++ b/resources/views/layouts/backend/navbar.blade.php @@ -0,0 +1,15 @@ + diff --git a/resources/views/layouts/backend/sidenav.blade.php b/resources/views/layouts/backend/sidenav.blade.php new file mode 100644 index 0000000..0698851 --- /dev/null +++ b/resources/views/layouts/backend/sidenav.blade.php @@ -0,0 +1,90 @@ + +{{-- --}} diff --git a/resources/views/login.blade.php b/resources/views/login.blade.php index 2b35965..1c3d682 100644 --- a/resources/views/login.blade.php +++ b/resources/views/login.blade.php @@ -1,78 +1,10 @@ - - - - - - Tableau de bord +@extends('layouts.app') - - - - - - +@section('content') + +@endsection diff --git a/resources/views/service/index.blade.php b/resources/views/service/index.blade.php new file mode 100644 index 0000000..f400938 --- /dev/null +++ b/resources/views/service/index.blade.php @@ -0,0 +1,158 @@ +@extends($viewLayout) + +@section('title', sprintf('%s - %s', transFb(sprintf('models.classes.%s', strtolower(Str::plural(class_basename($modelClass)))), Str::plural(class_basename($modelClass))), __('crud-policies::crud.viewAny'))) +@section('description', sprintf('%s %s', __('crud-policies::crud.viewAny'), trans(Str::plural(class_basename($modelClass))))) +@section('metaIndex', 'noindex,nofollow') + +@section('content') +
+ @include('crud-policies::crud.modules.flashMessage') +
+ @include('crud-policies::crud.modules.breadcrumb', ['action' => CrudAction::viewAny()]) + @include('crud-policies::crud.modules.actionbar.bar', ['action' => CrudAction::viewAny()]) +
+
+
+
+
+
+ + + + @if(request()->brand) + + @endif + {{ __('crud-policies::crud.reset') }} + +
+
+
+
+ + + + @foreach ($modelClass::getEditableProperties() as $colname => $prop) + @if(in_array(CrudAction::viewAny(), $prop['actions'])) + @switch($prop['type']) + @case(CrudType::password()) + {{-- Ignore --}} + @break + @default + + @endswitch + @endif + @endforeach + + + + + + + + @if(count($models)) + + {{-- INIT QUERIES for OPTIMIZING --}} + @foreach ($modelClass::getEditableProperties() as $fieldName => $prop) + @if($prop['type']->equals(CrudType::order())) + @php ${"$modelTable$fieldName"} = $modelClass::max($fieldName); @endphp + @endif + @if($prop['type']->equals(CrudType::belongsTo())) + @php try { $models->load(Str::singular((new $prop['belongsTo']())->getTable())); } catch(\Exception $e) {} @endphp + @endif + @if($prop['type']->equals(CrudType::belongsToMany())) + @php $models->load("$fieldName"); @endphp + @endif + @endforeach + + {{-- DISPLAY MODELS --}} + @foreach($models as $model) + + @foreach ($modelClass::getEditableProperties() as $fieldName => $prop) + @if(in_array(CrudAction::viewAny(), $prop['actions'])) + @switch($prop['type']) + @case(CrudType::belongsToMany() and $prop['belongsToMany'] === \App\Models\Project::class) + + @break + @case(CrudType::password()) + {{-- Ignore --}} + @break + @default + + @endswitch + @endif + @endforeach + + {{-- INFO COLS --}} + + + + + {{-- MODEL ACTIONS --}} + + + @endforeach + @else + + + + @endif + +
+ {{ $prop['label'] }} + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'desc' and session("crud.$modelTable.sort_col") === $colname)) +  ↓  + @endif + @if(!session("crud.$modelTable.sort_way") or session("crud.$modelTable.sort_col") !== $colname or (session("crud.$modelTable.sort_way") === 'asc' and session("crud.$modelTable.sort_col") === $colname)) +  ↑  + @endif + + {{ __('Date du Bearer token')}} + + {{ __('Régénerer un token')}} + + {{ __('Date de création')}} + + @if(session("crud.$modelTable.sort_way") and session("crud.$modelTable.sort_col")) + ⌫ + @endif +
+ @foreach($model->{$fieldName} as $pSite) + {{ $pSite->{$prop['belongsToManyLabel']} }} + @endforeach + @include('crud-policies::crud.printfield', [ + 'action' => CrudAction::viewAny(), + 'field' => $model->{$fieldName}, + 'props' => $prop, + "$modelTable$fieldName" => ${"$modelTable$fieldName"} ?? null + ]){{ Carbon::parse($model->bearer_token_date)->format('m/d/Y à H:i') }}
@csrf
{{ $model->created_at->format('m/d/Y à H:i') }} +
+ @can('view', $model) + {{ __('crud-policies::crud.view') }} + @endcan + @can('update', $model) + {{ __('crud-policies::crud.edit') }} + @endcan + @can('delete', $model) +
+ @csrf + @method('DELETE') + +
+ @endcan + @can('viewAny', \App\Models\Log::class) + {{ __('Journaux') }} + @endcan + @can('viewAny', \App\Models\File::class) + {{ __('Fichiers') }} + @endcan +
+
+ {{ __('crud-policies::crud.nothingtoshow') }} +
+ {{ $models->links() }} +
+
+@include('crud-policies::crud.modules.scriptConstants') +@endsection diff --git a/resources/views/services/index.blade.php b/resources/views/services/index.blade.php deleted file mode 100644 index 372f0de..0000000 --- a/resources/views/services/index.blade.php +++ /dev/null @@ -1,36 +0,0 @@ -@extends('layout.app') - -@section('content') -
-

{{ __('Gestion des services') }} {{ __('Liste') }}

- @if (session('success')) - {!! session('success') !!} - @endif - @if (session('error')) - {!! session('error') !!} - @endif - {{ __('Ajouter') }} -
- - - - - - - - - - - @foreach ($services as $service) - - - - - - - - - @endforeach - -
{{ __('Nom') }}{{ __('Marque') }}{{ __('Date du token') }}{{ __('Regénérer un token') }}{{ __('Date de création') }}
{{ $service->name }}{{ $service->brand->name }}{{ Carbon::parse($service->bearer_token_date)->format('d/m/Y à H:i') }}{{ __('Générer') }}{{ Carbon::parse($service->created_at)->format('d/m/Y à H:i') }}{{ __('Modifier') }}
-@endsection diff --git a/resources/views/services/manage.blade.php b/resources/views/services/manage.blade.php deleted file mode 100644 index f888168..0000000 --- a/resources/views/services/manage.blade.php +++ /dev/null @@ -1,42 +0,0 @@ -@extends('layout.app') - -@section('content') -
-

{{ __('Gestion des services') }} {{ __('Gestion') }}

- @if ($errors->any()) -
    - @foreach(session('errors')->all(':message') as $error) -
  • {{ $error }}
  • - @endforeach -
- @endif - @if (session('success')) - {!! session('success') !!} - @endif - {{ __('Retour') }} -
-
-
- @csrf -
- - -
- @if (!$edit) -
- - -
- @else - - @endif -
- -
-
-
-@endsection diff --git a/resources/views/single-optins/index.blade.php b/resources/views/single-optins/index.blade.php deleted file mode 100644 index df1e97a..0000000 --- a/resources/views/single-optins/index.blade.php +++ /dev/null @@ -1,5 +0,0 @@ -@extends('layout.app') - -@section('content') - -@endsection diff --git a/resources/views/single_optin/index.blade.php b/resources/views/single_optin/index.blade.php new file mode 100644 index 0000000..2d0c900 --- /dev/null +++ b/resources/views/single_optin/index.blade.php @@ -0,0 +1,121 @@ +@extends($viewLayout) + +@section('title', sprintf('%s - %s', transFb(sprintf('models.classes.%s', strtolower(Str::plural(class_basename($modelClass)))), Str::plural(class_basename($modelClass))), __('crud-policies::crud.viewAny'))) +@section('description', sprintf('%s %s', __('crud-policies::crud.viewAny'), trans(Str::plural(class_basename($modelClass))))) +@section('metaIndex', 'noindex,nofollow') + +@section('content') +
+ @include('crud-policies::crud.modules.flashMessage') +
+ @include('crud-policies::crud.modules.breadcrumb', ['action' => CrudAction::viewAny()]) + @include('crud-policies::crud.modules.actionbar.bar', ['action' => CrudAction::viewAny()]) +
+
+
+
+
+
+ + + + + + + @if(request()->brand) + + @endif + {{ __('crud-policies::crud.reset') }} + +
+
+
+
+ + + @include('crud-policies::crud.modules.sorter') + + + @if(count($models)) + + {{-- INIT QUERIES for OPTIMIZING --}} + @foreach ($modelClass::getEditableProperties() as $fieldName => $prop) + @if($prop['type']->equals(CrudType::order())) + @php ${"$modelTable$fieldName"} = $modelClass::max($fieldName); @endphp + @endif + @if($prop['type']->equals(CrudType::belongsTo())) + @php try { $models->load(Str::singular((new $prop['belongsTo']())->getTable())); } catch(\Exception $e) {} @endphp + @endif + @if($prop['type']->equals(CrudType::belongsToMany())) + @php $models->load("$fieldName"); @endphp + @endif + @endforeach + + {{-- DISPLAY MODELS --}} + @foreach($models as $model) + + @foreach ($modelClass::getEditableProperties() as $fieldName => $prop) + @if(in_array(CrudAction::viewAny(), $prop['actions'])) + @switch($prop['type']) + @case(CrudType::belongsToMany() and $prop['belongsToMany'] === \App\Models\Project::class) + + @break + @case(CrudType::password()) + {{-- Ignore --}} + @break + @default + + @endswitch + @endif + @endforeach + + {{-- MODEL ACTIONS --}} + + + @endforeach + @else + + + + @endif + +
+ @foreach($model->{$fieldName} as $pSite) + {{ $pSite->{$prop['belongsToManyLabel']} }} + @endforeach + @include('crud-policies::crud.printfield', [ + 'action' => CrudAction::viewAny(), + 'field' => $model->{$fieldName}, + 'props' => $prop, + "$modelTable$fieldName" => ${"$modelTable$fieldName"} ?? null + ]) +
+ @can('view', $model) + {{ __('crud-policies::crud.view') }} + @endcan + @can('update', $model) + {{ __('crud-policies::crud.edit') }} + @endcan + @can('delete', $model) +
+ @csrf + @method('DELETE') + +
+ @endcan +
+
+ {{ __('crud-policies::crud.nothingtoshow') }} +
+ {{ $models->links() }} +
+
+@include('crud-policies::crud.modules.scriptConstants') +@endsection diff --git a/routes/web.php b/routes/web.php index 55b9237..f5dc6bc 100644 --- a/routes/web.php +++ b/routes/web.php @@ -4,7 +4,7 @@ use App\Http\Controllers\BrandController; use App\Http\Controllers\CustomerController; use App\Http\Controllers\LoginController; use App\Http\Controllers\ServiceController; -use App\Http\Controllers\SingleOptinsController; +use App\Http\Controllers\SingleOptinController; use Illuminate\Support\Facades\Route; /* @@ -22,30 +22,32 @@ Route::get('/login', [LoginController::class, 'index'])->name('login'); Route::post('/login', [LoginController::class, 'authenticate'])->name('authenticate'); Route::middleware(['auth'])->group(function () { Route::get('/', function () { - return redirect()->route('customers'); - }); - Route::get('/logout', [LoginController::class, 'logout'])->name('logout'); + return redirect()->route('brands.index'); + })->name('home'); + Route::post('/logout', [LoginController::class, 'logout'])->name('logout'); // Marques - Route::get('/brands', [BrandController::class, 'index'])->name('brands'); - Route::match(['get', 'post'], '/brand/manage/{brand?}', [BrandController::class, 'manage'])->name('manage-brand'); + Route::resource('brands', BrandController::class)->except([ + 'delete' + ]); + Route::match(['get', 'post'], '/brand/manage/{brand?}', [BrandController::class, 'manage']) + ->name('manage-brand'); // Services - Route::get('/services', [ServiceController::class, 'index'])->name('services'); - Route::match(['get', 'post'], '/service/manage/{service?}', [ServiceController::class, 'manage']) - ->name('manage-service'); - Route::get('/services/{service}/token/generate', [ServiceController::class, 'generateApiToken']) + Route::resource('services', ServiceController::class)->except([ + 'delete' + ]); + Route::post('/services/{service}/token/generate', [ServiceController::class, 'generateApiToken']) ->name('generate-token-service'); // Clients - Route::get('/customers', [CustomerController::class, 'index'])->name('customers'); - Route::get('/customers/filter/{texte}/{brand?}', [CustomerController::class, 'filter'])->name('filter-customer'); - Route::get('/customer/{customer}/{brand}', [CustomerController::class, 'show'])->name('show-customer'); - Route::delete('/customer/{customer}/{brand}', [CustomerController::class, 'delete'])->name('customers.delete'); + Route::get('/customers', [CustomerController::class, 'index'])->name('customers.index'); + Route::get('/customers/{customer}/{brand}', [CustomerController::class, 'show'])->name('customers.show'); + Route::delete('/customers/{customer}/{brand}', [CustomerController::class, 'delete'])->name('customers.delete'); // Single optins - Route::get('/single-optins', [SingleOptinsController::class, 'index'])->name('single-optins'); - Route::get('/single-optins/filter/{texte}/{brandId?}', [SingleOptinsController::class, 'filter']) + Route::resource('single_optins', SingleOptinController::class); + Route::get('/single_optins/filter/{texte}/{brandId?}', [SingleOptinController::class, 'filter']) ->name('filter-single-optins'); - Route::post('/single-optins/{id}/delete', [SingleOptinsController::class, 'delete'])->name('single-optins-delete'); + Route::post('/single_optins/{id}/delete', [SingleOptinController::class, 'delete'])->name('single-optins-delete'); }); diff --git a/webpack.mix.js b/webpack.mix.js index 434769a..ae418f1 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -1,15 +1,49 @@ +const path = require('path'); const mix = require('laravel-mix'); +const { CleanWebpackPlugin } = require('clean-webpack-plugin'); +require('laravel-mix-polyfill'); -/* - |-------------------------------------------------------------------------- - | Mix Asset Management - |-------------------------------------------------------------------------- - | - | Mix provides a clean, fluent API for defining some Webpack build steps - | for your Laravel applications. By default, we are compiling the CSS - | file for the application as well as bundling up all the JS files. - | - */ +mix.webpackConfig({ + resolve: { + alias: { + '@': path.resolve('resources/assets') + } + }, + plugins: [ + new CleanWebpackPlugin({ + cleanOnceBeforeBuildPatterns: [ + 'css/*', + 'js/*', + 'images/*', + 'fonts/*', + 'assets/*' + ] + }) + ], +}); -mix.js('resources/js/app.js', 'public/js') - .sass('resources/sass/app.scss', 'public/css'); +let assetDir = 'assets'; +mix.options({ + fileLoaderDirs: { + images: `${assetDir}/images`, + fonts: `${assetDir}/fonts` + }, + postCss: [ + require('postcss-discard-comments')({ + removeAll: true + }) + ] +}); + +// mix Backend +mix.js("resources/js/back.js", "public/js/preload-back.js") + .sass("resources/sass/back.scss", "public/css/preload-back.css") + // .vue() + .polyfill({ + enabled: true, + useBuiltIns: "usage", + targets: { "firefox": "50", "ie": 11 } + }); + +// Copy Blade Images Assets +mix.copyDirectory('resources/assets', 'public/assets');