overhaull UI upgrade

using crud policies
This commit is contained in:
Jérémy Munsch 2021-09-08 16:43:44 +02:00
parent d3325f6e5d
commit 72a5b73902
63 changed files with 1838 additions and 1001 deletions

1
.gitignore vendored
View file

@ -19,3 +19,4 @@ storage/crm_migration.csv
MIG/errors_sql.txt
public/js
public/css
public/assets

View file

@ -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());
}
}

View file

@ -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é.");
}
}

View file

@ -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.");

View file

@ -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'");
}
}

View file

@ -0,0 +1,38 @@
<?php
namespace App\Http\Controllers;
use App\Models\SingleOptin;
use Illuminate\Database\Eloquent\Builder;
use Kwaadpepper\CrudPolicies\Http\Requests\CrudIndexRequest;
use Kwaadpepper\CrudPolicies\Traits\CrudController;
class SingleOptinController extends Controller
{
use CrudController {
index as crudIndex;
}
/** @var SingleOptin */
public static $modelClass = SingleOptin::class;
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('single_optin.index', $view->getData());
}
public function indexQuery(Builder $query): Builder
{
if (request()->brand) {
$query = $query->where('brand_id', request()->brand);
}
return $query;
}
}

View file

@ -1,37 +0,0 @@
<?php
namespace App\Http\Controllers;
use App\Http\Resources\StatusResource;
use App\Models\Brand;
use App\Models\SingleOptin;
class SingleOptinsController extends Controller
{
public function index()
{
$brands = Brand::select('id', 'name')->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"]);
}
}

View file

@ -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);
}

View file

@ -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
*

View file

@ -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);
}

View file

@ -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
*

View file

@ -0,0 +1,28 @@
<?php
namespace App\Policies;
use App\Policies\Rules\UserStaticRules as USR;
use Kwaadpepper\CrudPolicies\Policies\RootPolicy;
class BrandPolicy extends RootPolicy
{
/**
* Init policies on call
*
* @return void
*/
public function setPolicies()
{
/**
* This first rule to return true in a policy action authorises the action
*/
$this->policies = [
'brand' => [
'viewAny' => USR::make('everyOne'),
'update' => USR::make('everyOne'),
'create' => USR::make('everyOne')
]
];
}
}

View file

@ -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));

View file

@ -0,0 +1,17 @@
<?php
namespace App\Policies\Rules;
use Kwaadpepper\CrudPolicies\Policies\Rules\StaticRules;
/**
* Userlevel Policiy Static Rules
*! Rules has to return boolean value
*/
abstract class UserStaticRules extends StaticRules
{
protected static function everyOne(): bool
{
return true;
}
}

View file

@ -0,0 +1,29 @@
<?php
namespace App\Policies;
use App\Policies\Rules\UserStaticRules as USR;
use Kwaadpepper\CrudPolicies\Policies\RootPolicy;
class ServicePolicy extends RootPolicy
{
/**
* Init policies on call
*
* @return void
*/
public function setPolicies()
{
/**
* This first rule to return true in a policy action authorises the action
*/
$this->policies = [
'service' => [
'viewAny' => USR::make('everyOne'),
'view' => USR::make('everyOne'),
'update' => USR::make('everyOne'),
'create' => USR::make('everyOne')
]
];
}
}

View file

@ -0,0 +1,27 @@
<?php
namespace App\Policies;
use App\Policies\Rules\UserStaticRules as USR;
use Kwaadpepper\CrudPolicies\Policies\RootPolicy;
class SingleOptinPolicy extends RootPolicy
{
/**
* Init policies on call
*
* @return void
*/
public function setPolicies()
{
/**
* This first rule to return true in a policy action authorises the action
*/
$this->policies = [
'singleoptin' => [
'viewAny' => USR::make('everyOne'),
'delete' => USR::make('everyOne')
]
];
}
}

View file

@ -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);
}
}

View file

@ -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();

@ -1 +1 @@
Subproject commit b208c78b97e68c078345620a5a023186a1753ee8
Subproject commit 14d966a62b297a299e0602e2b4bc5a3abff6cb56

View file

@ -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",

369
composer.lock generated
View file

@ -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",

View file

@ -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
],
];

View file

@ -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"
}
}

View file

@ -1,18 +0,0 @@
/*!
* Vue.js v2.6.12
* (c) 2014-2020 Evan You
* Released under the MIT License.
*/
/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
//! moment.js
//! moment.js locale configuration

View file

@ -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"
}

View file

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View file

@ -1,101 +0,0 @@
<template>
<div>
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Rechercher un opt-in</h1>
<div class="spinner-border text-dark float-right" role="status" v-show="processing">
<span class="sr-only">Chargement...</span>
</div>
</div>
<div class="form-group form-row">
<label class="col-form-label col text-center">Marque :</label>
<select v-model="selectedBrand" class="custom-select col">
<option value="0" selected>Toutes les marques</option>
<option v-for="item in brands" :key="item.id" :value="item.id">{{ item.name }}</option>
</select>
<label class="col-form-label col text-center">Votre recherche :</label>
<input v-model="search" type="text" class="form-control col" placeholder="Entrer votre recherche ici" v-on:keyup.enter="enterSearch">
</div>
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">Email</th>
<th scope="col">Marque</th>
<th scope="col">Date opt-in</th>
<th scope="col"></th>
</tr>
</thead>
<tbody id="emails">
<tr v-for="item in datas" :key="item.id">
<td>{{ item.email }}</td>
<td>{{ brands.find(element => element.id === item.brand_id).name }}</td>
<td>{{ item.created_at | formatDate }}</td>
<td><a class="btn btn-sm btn-danger" @click="deleteOptin(item.id)">Supprimer</a></td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
export default {
mounted() {
console.log('SearchOptin Component mounted.');
this.brands = JSON.parse(this.dbbrands);
},
props: [
'dbbrands',
],
data() {
return {
brands: [],
datas: [],
processing: false,
search: '',
selectedBrand: "0",
}
},
methods: {
enterSearch() {
if (this.search.length < 1)
return false;
this.processing = true;
let chaine = this.search;
if (this.selectedBrand !== "0")
chaine += '/' + this.selectedBrand;
axios.get('/single-optins/filter/' + chaine)
.then(
(response) => {
this.datas = response.data;
this.processing = false;
}
)
.catch(function (error) {
console.log(error);
this.processing = false;
});
},
deleteOptin(id) {
let r = confirm("Veuillez confirmer cette action en cliquant sur OK.");
if (r === true) {
axios.post('/single-optins/' + id + '/delete')
.then(
(response) => {
if (response.data.status === 'OK'){
this.datas = [];
this.search = '';
this.selectedBrand = "0";
this.processing = false;
alert("Suppression terminée.");
}
}
)
.catch(function (error) {
console.log(error);
this.processing = false;
alert("Une erreur est survenue.");
});
}
}
},
}
</script>

View file

@ -1,87 +0,0 @@
<template>
<div>
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Rechercher un client</h1>
<div class="spinner-border text-dark float-right" role="status" v-show="processing">
<span class="sr-only">Chargement...</span>
</div>
</div>
<div class="form-group form-row">
<label class="col-form-label col text-center">Marque :</label>
<select v-model="selectedBrand" class="custom-select col">
<option value="0" selected>Toutes les marques</option>
<option v-for="item in brands" :key="item.id" :value="item.id">{{ item.name }}</option>
</select>
<label class="col-form-label col text-center">Votre recherche :</label>
<input v-model="search" type="text" class="form-control col" placeholder="Entrer votre recherche ici" v-on:keyup.enter="enterSearch">
</div>
<table class="table table-bordered">
<thead>
<tr>
<th scope="col">CRM ID</th>
<th scope="col">Email</th>
<th scope="col">Nom</th>
<th scope="col">Prénom</th>
<th scope="col">Opt-In</th>
<th scope="col">Marque</th>
<th scope="col">Dernière connexion</th>
<th scope="col">Voir</th>
</tr>
</thead>
<tbody id="emails">
<tr v-for="item in datas" :key="item.id">
<td>{{ item.customer_id }}</td>
<td>{{ item.email }}</td>
<td>{{ item.lastname }}</td>
<td>{{ item.firstname }}</td>
<td>{{ item.opt_in === 1 ? "Oui" : "Non" }}</td>
<td>{{ brands.find(element => element.id === item.brand_id).name }}</td>
<td>{{ item.last_connection | formatDate }}</td>
<td><a :href="'/customer/' + item.customer_id + '/' + item.brand_id" class="btn btn-sm btn-primary">Détail</a></td>
</tr>
</tbody>
</table>
</div>
</template>
<script>
export default {
mounted() {
console.log('SearchUser Component mounted.');
this.brands = JSON.parse(this.dbbrands);
},
props: [
'dbbrands',
],
data() {
return {
brands: [],
datas: [],
processing: false,
search: '',
selectedBrand: "0",
}
},
methods: {
enterSearch() {
if (this.search.length < 1)
return false;
this.processing = true;
let chaine = this.search;
if (this.selectedBrand !== "0")
chaine += '/' + this.selectedBrand;
axios.get('/customers/filter/' + chaine)
.then(
(response) => {
this.datas = response.data;
this.processing = false;
}
)
.catch(function (error) {
console.log(error);
this.processing = false;
});
},
},
}
</script>

17
resources/js/app.js vendored
View file

@ -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',
});

5
resources/js/back.js vendored Normal file
View file

@ -0,0 +1,5 @@
require('./bootstrap');
require('./pages/customer.delete')
require('./pages/service.index')
require('./pages/single_optin.index')

34
resources/js/pages/customer.delete.js vendored Normal file
View file

@ -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). <br><h3><b>Une fois ne compte supprimé je ne pourrai plus récupérer le hashcode nécessaire pour effectuer ces opérations.</b></h3>',
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()
}
})
}
})
})
}

36
resources/js/pages/service.index.js vendored Normal file
View file

@ -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: '<h3><b>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</b></h3>',
icon: 'info',
confirmButtonText: 'Oui, feu patate !!',
showCancelButton: true,
cancelButtonText: 'Annuler',
confirmButtonColor: '#dc3545'
}).then((result) => {
if (result.isConfirmed) {
self.submit()
}
})
}
})
})
}
}

View file

@ -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);
}
});
}

View file

@ -0,0 +1,20 @@
<?php
return [
'classes' => [
'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'
]
];

View file

@ -0,0 +1,20 @@
<?php
return [
'classes' => [
'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'
]
];

View file

@ -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);
}

17
resources/sass/_layout.scss vendored Normal file
View file

@ -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;
}
}

View file

@ -22,3 +22,7 @@ $theme-colors: (
"primary": #3176C4,
"secondary": #E7374B
);
$navBarHeight: 4rem;
$footerHeight: 3rem;
$footerBgColor: #161616;

View file

@ -1,10 +0,0 @@
// Fonts
@import url('https://fonts.googleapis.com/css?family=Nunito');
// Variables
@import 'variables';
// Bootstrap
@import '~bootstrap/scss/bootstrap';
@import "dashboard";

5
resources/sass/back.scss vendored Normal file
View file

@ -0,0 +1,5 @@
// Variables
@import 'variables';
@import 'layout';
@import "pages/login";

54
resources/sass/pages/login.scss vendored Normal file
View file

@ -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;
}

View file

@ -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')
<div class="card">
@include('crud-policies::crud.modules.flashMessage')
<div class="card-header">
@include('crud-policies::crud.modules.breadcrumb', ['action' => CrudAction::viewAny()])
@include('crud-policies::crud.modules.actionbar.bar', ['action' => CrudAction::viewAny()])
</div>
<div class="card-body">
<div class="row justify-content-end">
<div class="col-6">
<form action="{{ url()->current() }}">
<div class="input-group mb-3">
<input type="search" name="search" class="form-control" value="{{ request()->search }}" placeholder="Recherche.."/>
<input type="text" name="sort_col" class="d-none" value="{{ request()->sort_col }}"/>
<input type="text" name="sort_way" class="d-none" value="{{ request()->sort_way }}"/>
@if(request()->brand)
<input type="hidden" name="brand" class="d-none" value="{{ request()->brand }}"/>
@endif
<a class="btn btn-danger" href="{{ url()->current() }}">{{ __('crud-policies::crud.reset') }}</a>
<button type="submit" class="btn btn-primary">
{{ __('crud-policies::crud.search') }}
</button>
</div>
</form>
</div>
</div>
<table class="table text-center">
<thead class="thead-dark">
<tr>
@foreach ($modelClass::getEditableProperties() as $colname => $prop)
@if(in_array(CrudAction::viewAny(), $prop['actions']))
@switch($prop['type'])
@case(CrudType::password())
{{-- Ignore --}}
@break
@default
<th scope="col">
{{ $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))
<a class="col_sort text-secondary lead asc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'asc']) }}">&nbsp;&darr;&nbsp;</a>
@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))
<a class="col_sort text-secondary lead desc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'desc']) }}">&nbsp;&uarr;&nbsp;</a>
@endif
</th>
@endswitch
@endif
@endforeach
<th scope="col">
{{ __('Nombre de comptes')}}
</th>
<th scope="col">
{{ __('Nombre d\'optins')}}
</th>
<th scope="col">
{{ __('Date d\'ajout en base')}}
</th>
<th scope="col">
@if(session("crud.$modelTable.sort_way") and session("crud.$modelTable.sort_col"))
<a href="{{ request()->fullUrlWithQuery(['rst' => 'true']) }}" class="btn btn-small btn-danger">&#9003;</a>
@endif
</th>
</tr>
</thead>
<tbody>
@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)
<tr>
@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)
<td>
@foreach($model->{$fieldName} as $pSite)
<a href="{{ CrudController::getRoutePrefixed($pSite->getTable().'.show', $pSite) }}">{{ $pSite->{$prop['belongsToManyLabel']} }}</a>
@endforeach
</td>
@break
@case(CrudType::password())
{{-- Ignore --}}
@break
@default
<td>@include('crud-policies::crud.printfield', [
'action' => CrudAction::viewAny(),
'field' => $model->{$fieldName},
'props' => $prop,
"$modelTable$fieldName" => ${"$modelTable$fieldName"} ?? null
])</td>
@endswitch
@endif
@endforeach
{{-- INFO COLS --}}
<td>{{ $model->getAccountsAttribute() }}</td>
<td>{{ $model->getTotalOptinsAttribute() }}</td>
<td>{{ $model->created_at->format('m/d/Y à H:i') }}</td>
{{-- MODEL ACTIONS --}}
<td>
<div class="btn-group" role="group" aria-label="{{ Str::plural(__('crud-policies::crud.action')) }}">
@can('view', $model)
<a href="{{ CrudController::getRoutePrefixed("$modelTable.show", $model) }}" class="btn btn-sm btn-primary">{{ __('crud-policies::crud.view') }}</a>
@endcan
@can('update', $model)
<a href="{{ CrudController::getRoutePrefixed("$modelTable.edit", $model) }}" class="btn btn-sm btn-info">{{ __('crud-policies::crud.edit') }}</a>
@endcan
@can('delete', $model)
<form action="{{ CrudController::getRoutePrefixed("$modelTable.destroy", $model) }}" method="POST" onsubmit="__CRUD.confirmDelete(event)">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-sm btn-danger">{{ __('crud-policies::crud.delete') }}</button>
</form>
@endcan
@can('viewAny', \App\Models\Log::class)
<a href="{{ CrudController::getRoutePrefixed("sites.logs.index", $model) }}" class="btn btn-sm btn-dark">{{ __('Journaux') }}</a>
@endcan
@can('viewAny', \App\Models\File::class)
<a href="{{ CrudController::getRoutePrefixed("sites.files.index", $model) }}" class="btn btn-sm btn-dark">{{ __('Fichiers') }}</a>
@endcan
</div>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="{{ count($modelClass::getEditableProperties()) }}">
{{ __('crud-policies::crud.nothingtoshow') }}
</td>
</tr>
@endif
</tbody>
</table>
{{ $models->links() }}
</div>
</div>
@include('crud-policies::crud.modules.scriptConstants')
@endsection

View file

@ -1,28 +0,0 @@
@extends('layout.app')
@section('content')
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h2>{{ __('Gestion des marques') }} <small class="text-muted">{{ __('Liste') }}</small></h2>
<a href="{{ route('manage-brand') }}" class="btn btn-sm btn-primary float-right">{{ __('Ajouter') }}</a>
</div>
<table class="table">
<thead>
<th>{{ __('Nom de la marque') }}</th>
<th>{{ __('Nombre de comptes') }}</th>
<th>{{ __('Nombre d\'optins') }}</th>
<th>{{ __('Date d\'ajout en base') }}</th>
<th></th>
</thead>
<tbody>
@foreach ($brands as $brand)
<tr>
<td>{{ $brand->name }}</td>
<td>{{ $brand->accounts }}</td>
<td>{{ $brand->total_optins }}</td>
<td>{{ Carbon::parse($brand->created_at)->format('d/m/Y à H:i') }}</td>
<td><a href="{{ route('manage-brand', $brand) }}" class="btn btn-sm btn-success">{{ __('Modifier') }}</a></td>
</tr>
@endforeach
</tbody>
</table>
@endsection

View file

@ -1,30 +0,0 @@
@extends('layout.app')
@section('content')
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h2>{{ __('Gestion des marques') }} <small class="text-muted">{{ __('Gestion') }}</small></h2>
@if ($errors->any())
<ul class="text-danger text-center">
@foreach(session('errors')->all(':message') as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
@endif
@if (session('success'))
<span class="text-success text-center">{!! session('success') !!}</span>
@endif
<a href="{{ route('brands') }}" class="btn btn-sm btn-primary float-right">{{ __('Retour') }}</a>
</div>
<div class="form-group">
<form action="{{ route('manage-brand', $brand) }}" method="POST">
@csrf
<div class="form-group form-row">
<label class="col-form-label col">{{ __('Nom de la marque') }}</label>
<input type="text" name="name" class="form-control col" value="{{ $brand->name ?? null }}">
</div>
<div class="text-center">
<input type="submit" class="btn btn-success" value="{{ __('Enregistrer') }}">
</div>
</form>
</div>
@endsection

View file

@ -0,0 +1,63 @@
<th scope="col">
@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))
<a class="col_sort text-secondary lead asc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'asc']) }}">&nbsp;&darr;&nbsp;</a>
@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))
<a class="col_sort text-secondary lead desc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'desc']) }}">&nbsp;&uarr;&nbsp;</a>
@endif
</th>
<th scope="col">
@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))
<a class="col_sort text-secondary lead asc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'asc']) }}">&nbsp;&darr;&nbsp;</a>
@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))
<a class="col_sort text-secondary lead desc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'desc']) }}">&nbsp;&uarr;&nbsp;</a>
@endif
</th>
<th scope="col">
@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))
<a class="col_sort text-secondary lead asc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'asc']) }}">&nbsp;&darr;&nbsp;</a>
@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))
<a class="col_sort text-secondary lead desc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'desc']) }}">&nbsp;&uarr;&nbsp;</a>
@endif
</th>
<th scope="col">
@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))
<a class="col_sort text-secondary lead asc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'asc']) }}">&nbsp;&darr;&nbsp;</a>
@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))
<a class="col_sort text-secondary lead desc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'desc']) }}">&nbsp;&uarr;&nbsp;</a>
@endif
</th>
<th scope="col">
@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))
<a class="col_sort text-secondary lead asc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'asc']) }}">&nbsp;&darr;&nbsp;</a>
@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))
<a class="col_sort text-secondary lead desc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'desc']) }}">&nbsp;&uarr;&nbsp;</a>
@endif
</th>
<th scope="col">
@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))
<a class="col_sort text-secondary lead asc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'asc']) }}">&nbsp;&darr;&nbsp;</a>
@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))
<a class="col_sort text-secondary lead desc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'desc']) }}">&nbsp;&uarr;&nbsp;</a>
@endif
</th>
<th scope="col">
{{ __('Voir')}}
</th>

View file

@ -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')
<div class="card">
@include('crud-policies::crud.modules.flashMessage')
<div class="card-header">
@include('crud-policies::crud.modules.breadcrumb', ['action' => CrudAction::viewAny()])
@include('crud-policies::crud.modules.actionbar.bar', ['action' => CrudAction::viewAny()])
</div>
<div class="card-body">
<div class="row justify-content-center">
<div class="col">
<form action="{{ url()->current() }}">
<div class="input-group mb-3">
<label class="input-group-text" for="brandSelect">{{ __('Filter par Marque') }}</label>
<select class="form-select" id="brandSelect">
<option value="0" @if(!request()->brand) selected @endif>{{ __('Sélectionnez une marque..') }}</option>
@foreach(Brand::all() as $brand)
<option value="{{ $brand->id }}" @if(request()->brand == "$brand->id") selected @endif>{{ $brand->name }}</option>
@endforeach
</select>
<label class="input-group-text bg-warning" for="searchField">🔍🠚</label>
<input type="search" id="searchField" name="search" class="form-control" value="{{ request()->search }}" placeholder="Recherche.."/>
<input type="text" name="sort_col" class="d-none" value="{{ request()->sort_col }}"/>
<input type="text" name="sort_way" class="d-none" value="{{ request()->sort_way }}"/>
@if(request()->brand)
<input type="hidden" name="brand" class="d-none" value="{{ request()->brand }}"/>
@endif
<a class="btn btn-danger" href="{{ url()->current() }}">{{ __('crud-policies::crud.reset') }}</a>
<button type="submit" class="btn btn-primary">
{{ __('crud-policies::crud.search') }}
</button>
</div>
</form>
</div>
</div>
<table class="table text-center">
<thead class="thead-dark">
<tr>
@include('customer.index-tableHeaders')
<th scope="col">
@if(session("crud.$modelTable.sort_way") and session("crud.$modelTable.sort_col"))
<a href="{{ request()->fullUrlWithQuery(['rst' => 'true']) }}" class="btn btn-small btn-danger">&#9003;</a>
@endif
</th>
</tr>
</thead>
<tbody>
@if(count($customers))
{{-- DISPLAY MODELS --}}
@foreach($customers as $customerInfo)
<tr>
<td>
{{ $customerInfo->customer->email }}
</td>
<td>
{{ $customerInfo->firstname }}
</td>
<td>
{{ $customerInfo->lastname }}
</td>
<td>
{{ $customerInfo->optin ? 'Oui' :'Non' }}
</td>
<td>
{{ $customerInfo->brand->name }}
</td>
<td>
{{ $customerInfo->login()->status ? 'Oui' :'Non' }}
</td>
{{-- MODEL ACTIONS --}}
<td>
<div class="btn-group" role="group" aria-label="{{ Str::plural(__('crud-policies::crud.action')) }}">
@can('view', $customerInfo->customer)
<a href="{{ CrudController::getRoutePrefixed("customers.show", [
'customer' => $customerInfo->customer_id,
'brand' => $customerInfo->brand_id
]) }}" class="btn btn-sm btn-primary">{{ __('crud-policies::crud.view') }}</a>
@endcan
</div>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="5">
{{ __('crud-policies::crud.nothingtoshow') }}
</td>
</tr>
@endif
</tbody>
</table>
{{ $customers->links() }}
</div>
</div>
@include('crud-policies::crud.modules.scriptConstants')
@endsection

View file

@ -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')
<div class="card">
@include('crud-policies::crud.modules.flashMessage')
<div class="card-header">
<nav aria-label="breadcrumb" class="d-inline">
<ol class="breadcrumb d-inline-flex">
<li class="breadcrumb-item">
<a href="{{ route('customers.index') }}">{{ __('models.classes.customers') }}</a>
</li>
<li class="breadcrumb-item active" aria-current="page">{{__('Liste') }}</li>
</ol>
</nav>
</div>
<div class="card-body">
<div class="row justify-content-center">
<div class="col">
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">{{ __('Informations du client') }} {{ $customerInfos->firstname }} {{ $customerInfos->lastname }} - {{ Str::singular(__('models.classes.brands')) }} {{ $customerInfos->brand->name }}</h1>
<a href="{{ route('customers.index') }}" class="btn btn-sm btn-primary float-right">Retour</a>
</div>
</div>
</div>
<table class="table table-sm table-bordered table-striped">
<tbody>
<tr>
<td class="w-50"><b>{{ __('Email') }}</b></td>
<td class="w-50">{{ $customerInfos->customer->email }}</td>
</tr>
<tr>
<td><b>Prénom</b></td>
<td>{{ $customerInfos->firstname }}</td>
</tr>
<tr>
<td><b>Nom</b></td>
<td>{{ $customerInfos->lastname }}</td>
</tr>
<tr>
<td><b>Date de naissance</b></td>
<td>{{ \Carbon\Carbon::parse($customerInfos->birth_date)->format('d/m/Y') }}</td>
</tr>
<tr>
<td><b>Téléphone</b></td>
<td>{{ $customerInfos->phone }}</td>
</tr>
<tr>
<td><b>Adresse</b></td>
<td>{{ $customerInfos->address }}</td>
</tr>
<tr>
<td><b>Adresse complémentaire</b></td>
<td>{{ $customerInfos->address2 }}</td>
</tr>
<tr>
<td><b>Pays</b></td>
<td>{{ $customerInfos->country }}</td>
</tr>
<tr>
<td><b>Ville</b></td>
<td>{{ $customerInfos->city }}</td>
</tr>
<tr>
<td><b>Code postal</b></td>
<td>{{ $customerInfos->postcode }}</td>
</tr>
<tr>
<td><b>Abonné à la newsletter</b></td>
<td>{{ $customerInfos->opt_in === 1 ? "Oui" : "Non" }}</td>
</tr>
<tr>
<td><b>Date de la dernière modification de l'abonnement</b></td>
@if($customerInfos->customer->optInHistory()->orderBy('created_at', 'DESC')->exists())
<td>{{ \Carbon\Carbon::parse($customerInfos->customer->optInHistory()->orderBy('created_at', 'DESC')->first()->created_at)->format('d/m/Y à H:i') }}</td>
@else
<td></td>
@endif
</tr>
<tr>
<td><b>Dernière connexion</b></td>
<td>{{ \Carbon\Carbon::parse($customerLogin->last_connection)->format('d/m/Y à H:i') }}</td>
</tr>
<tr>
<td><b>Status du compte</b></td>
<td>{{ $customerLogin->status === 1 ? "Activé" : "Non activé" }}</td>
</tr>
<tr>
<td><b>Hashcode</b></td>
<td>{{ $customerInfos->hashcode }}</td>
</tr>
<tr>
<td><b>Date de création</b></td>
<td>{{ \Carbon\Carbon::parse($customerInfos->created_at)->format('d/m/Y à H:i') }}</td>
</tr>
<tr>
<td><b>Date de modification</b></td>
<td>{{ \Carbon\Carbon::parse($customerInfos->updated_at)->format('d/m/Y à H:i') }}</td>
</tr>
</tbody>
</table>
<form id="customerDelete" action="{{ route('customers.delete', ['customer' => $customerInfos->customer_id, 'brand' => $customerInfos->brand_id]) }}" method="POST">
@csrf
@method('DELETE')
<input type="submit" value="{{ __('Supprimer') }}" class="btn btn-sm btn-danger">
</form>
</div>
</div>
@include('crud-policies::crud.modules.scriptConstants')
@endsection

View file

@ -1,23 +0,0 @@
@extends('layout.app')
@section('content')
@if (session()->has('success'))
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3">
<div class="alert alert-success">
<p>{{ session()->get('success') }}</p>
</div>
</div>
@endif
@if ($errors->any())
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3">
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
</div>
@endif
<search-user dbbrands='@json($brands)'></search-user>
@endsection

View file

@ -1,98 +0,0 @@
@extends('layout.app')
@section('content')
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Informations du client {{ $customerInfos->firstname }} {{ $customerInfos->lastname }} - Marque {{ $customerInfos->brand->name }}</h1>
<a href="{{ route('customers') }}" class="btn btn-sm btn-primary float-right">Retour</a>
</div>
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<table class="table table-sm table-bordered table-striped">
<tbody>
<tr>
<td class="w-50"><b>Email</b></td>
<td class="w-50">{{ $customerInfos->customer->email }}</td>
</tr>
<tr>
<td><b>Prénom</b></td>
<td>{{ $customerInfos->firstname }}</td>
</tr>
<tr>
<td><b>Nom</b></td>
<td>{{ $customerInfos->lastname }}</td>
</tr>
<tr>
<td><b>Date de naissance</b></td>
<td>{{ \Carbon\Carbon::parse($customerInfos->birth_date)->format('d/m/Y') }}</td>
</tr>
<tr>
<td><b>Téléphone</b></td>
<td>{{ $customerInfos->phone }}</td>
</tr>
<tr>
<td><b>Adresse</b></td>
<td>{{ $customerInfos->address }}</td>
</tr>
<tr>
<td><b>Adresse complémentaire</b></td>
<td>{{ $customerInfos->address2 }}</td>
</tr>
<tr>
<td><b>Pays</b></td>
<td>{{ $customerInfos->country }}</td>
</tr>
<tr>
<td><b>Ville</b></td>
<td>{{ $customerInfos->city }}</td>
</tr>
<tr>
<td><b>Code postal</b></td>
<td>{{ $customerInfos->postcode }}</td>
</tr>
<tr>
<td><b>Abonné à la newsletter</b></td>
<td>{{ $customerInfos->opt_in === 1 ? "Oui" : "Non" }}</td>
</tr>
<tr>
<td><b>Date de la dernière modification de l'abonnement</b></td>
@if($customerInfos->customer->optInHistory()->orderBy('created_at', 'DESC')->exists())
<td>{{ \Carbon\Carbon::parse($customerInfos->customer->optInHistory()->orderBy('created_at', 'DESC')->first()->created_at)->format('d/m/Y à H:i') }}</td>
@else
<td></td>
@endif
</tr>
<tr>
<td><b>Dernière connexion</b></td>
<td>{{ \Carbon\Carbon::parse($customerLogin->last_connection)->format('d/m/Y à H:i') }}</td>
</tr>
<tr>
<td><b>Status du compte</b></td>
<td>{{ $customerLogin->status === 1 ? "Activé" : "Non activé" }}</td>
</tr>
<tr>
<td><b>Hashcode</b></td>
<td>{{ $customerInfos->hashcode }}</td>
</tr>
<tr>
<td><b>Date de création</b></td>
<td>{{ \Carbon\Carbon::parse($customerInfos->created_at)->format('d/m/Y à H:i') }}</td>
</tr>
<tr>
<td><b>Date de modification</b></td>
<td>{{ \Carbon\Carbon::parse($customerInfos->updated_at)->format('d/m/Y à H:i') }}</td>
</tr>
</tbody>
</table>
<form action="{{ route('customers.delete', ['customer' => $customerInfos->customer_id, 'brand' => $customerInfos->brand->id]) }}" method="POST" onsubmit="return confirm('{{ __('Êtes-vous sûr de vouloir supprimer cet utilisateur ?') }}');">
@csrf
@method('DELETE')
<input type="submit" value="{{ __('Supprimer') }}" class="btn btn-sm btn-danger">
</form>
@endsection

View file

@ -1,68 +0,0 @@
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Tableau de bord</title>
<script src="https://cdn.ckeditor.com/ckeditor5/23.0.0/classic/ckeditor.js"></script>
<link rel="stylesheet" href="/css/app.css">
</head>
<body>
<div id="app">
<nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 shadow">
<a class="navbar-brand col-md-3 col-lg-2 mr-0 px-3" href="#">{{ config('app.name') }}</a>
<button class="navbar-toggler position-absolute d-md-none collapsed" type="button" data-toggle="collapse" data-target="#sidebarMenu" aria-controls="sidebarMenu" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</nav>
<div class="container-fluid">
<div class="row">
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
<div class="sidebar-sticky pt-3">
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>CLIENTS</span>
</h6>
<ul class="nav flex-column mb-2">
<li class="nav-item"><a class="nav-link" href="{{route('customers')}}">Rechercher un client</a></li>
</ul>
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>OPT-INS UNIQUES</span>
</h6>
<ul class="nav flex-column mb-2">
<li class="nav-item"><a class="nav-link" href="{{route('single-optins')}}">Rechercher un opt-in</a></li>
</ul>
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>MARQUES</span>
</h6>
<ul class="nav flex-column mb-2">
<li class="nav-item"><a class="nav-link" href="{{route('brands')}}">Gestion des marques</a></li>
</ul>
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>SERVICES</span>
</h6>
<ul class="nav flex-column mb-2">
<li class="nav-item"><a class="nav-link" href="{{route('services')}}">Gestion des services</a></li>
</ul>
<ul class="nav flex-column mb-2" style="position: absolute; bottom: 5px;">
<li class="nav-item"><a class="nav-link" href="{{route('logout')}}">Se déconnecter</a></li>
</ul>
</div>
</nav>
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-md-4">
@yield('content')
</main>
</div>
</div>
</div>
<script src="/js/app.js"></script>
@yield('scripts')
</body>
</html>

View file

@ -0,0 +1,35 @@
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
@include('layouts.backend.head')
@stack('styles')
@crudPoliciesCSS()
</head>
<body>
<div id="app">
@include('layouts.backend.navbar')
<div class="container-fluid">
<div class="row">
@if(isset($modelsClasses))
@include('layouts.backend.sidenav')
<main role="main" class="col-md-9 mt-5 mb-5 ml-sm-auto col-lg-10 px-md-4 bodyFull">
@else
<main role="main" class="mt-5 mb-5 bodyFull">
@endif
@yield('content')
</main>
</div>
<div class="row">
@include('layouts.backend.footer')
</div>
</div>
</div>
@stack('scriptsConstants')
@include('crud-policies::crud.modules.scriptConstants')
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha256-edRDsV9ULIqKzKjpN/KjyQ7Lp4vUn9usbJuHjH8Sk+k=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.16/dist/sweetalert2.all.min.js" integrity="sha256-551HBsteMvKOSqjUXSmRy/EOF0bBNbWB96b5L3Deh8A=" crossorigin="anonymous"></script>
<script src="{{ asset('js/preload-back.js') }}"></script>
@crudPoliciesJS()
@stack('scripts')
</body>
</html>

View file

@ -0,0 +1,10 @@
<footer id="footer" class="text-center text-lg-start">
<div class="text-center p-2" style="background-color: rgba(0, 0, 0, 0.05);">
<span class="text-reset">{{ $license }}</span>
-
<span class="text-reset">{{ $name }}&nbsp;-&nbsp;{{ $version }}</span>
-
<span class="text-reset fw-bold">LDC Web Services</span>
© {{ date('Y') }}
</div>
</footer>

View file

@ -0,0 +1,32 @@
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>{{ config('app.name') }}@hasSection('title') - @yield('title')@endif</title>
<meta name="description" content="@yield('description')">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
@hasSection('canonical')
<link rel="canonical" href="@yield('canonical')" />
@else
<link rel="canonical" href="{{ url()->current() }}" />
@endif
<!-- META INDEX, FOLLOW -->
@hasSection('metaIndex')
<meta name="robots" content="@yield('metaIndex')">
@else
<meta name="robots" content="index, follow">
@endif
<!-- Favicon -->
{{-- <link rel="icon" href="{{ asset('assets/images/favicon.png') }}" type="image/png">
<link rel="icon" sizes="16x16" href="{{ asset('assets/images/LG-favicons_16x16.png') }}" type="image/png">
<link rel="icon" sizes="32x32" href="{{ asset('assets/images/LG-favicons_32x32.png') }}" type="image/png">
<link rel="icon" sizes="48x48" href="{{ asset('assets/images/LG-favicons_48x48.png') }}" type="image/png"> --}}
@preload('mix-manifest.json')
<!-- STYLES -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" integrity="sha256-hHKA3d/HttC8OW3Sl093W8DoZudhHJDj++kZYo6MLzA=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.16/dist/sweetalert2.min.css" integrity="sha256-qpXwccFYncH5gTqXFe9EXZ8QeDw1Re68bbNVfFZzIzg=" crossorigin="anonymous">
<link rel="stylesheet" href="{{ asset('css/preload-back.css') }}">

View file

@ -0,0 +1,15 @@
<nav class="navbar navbar-expand-lg navbar-dark bg-dark sticky-top">
<div class="container-fluid">
<a class="navbar-brand" href="{{ route('home') }}">{{ config('app.name') }}</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarScroll" aria-controls="navbarScroll" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarScroll">
<ul class="navbar-nav ms-auto my-2 my-lg-0 navbar-nav-scroll " style="--bs-scroll-height: 100px;">
@auth()
<li class="nav-item"><span class="nav-link text-success">{{ auth()->user()->name }}</span></li>
@endauth
</ul>
</div>
</div>
</nav>

View file

@ -0,0 +1,90 @@
<nav id="sidebarMenu" class="col-md-3 col-lg-2 min-height-100vh d-md-block bg-light sidebar collapse">
<div class="sidebar-sticky pt-3 d-flex flex-column justify-content-between align-items-center">
<div class="col-12 mt-4">
<h6 class="sidebar-heading px-3 mb-1 text-muted">
<span>{{ __(sprintf('models.classes.%s', strtolower(Str::plural(class_basename(Customer::class))))) }}</span>
</h6>
@php
$crudModel = Customer::class;
$crudModel = new $crudModel();
@endphp
<ul class="nav flex-column mb-2">
@can('viewAny', $crudModel)
<li class="nav-item"><a class="nav-link" href="{{ route(sprintf('%s%s.index', $prefix ?? '', $crudModel->getTable())) }}">{{ __('Liste') }}</a></li>
@endcan
@can('create', $crudModel)
<li class="nav-item"><a class="nav-link" href="{{ route(sprintf('%s%s.create', $prefix ?? '', $crudModel->getTable())) }}">{{ __('Ajouter') }}</a></li>
@endcan
</ul>
<hr>
@foreach($modelsClasses as $crudModel)
@php if($crudModel === Customer::class) continue; @endphp
@if(
auth()->user()->can('viewAny', $crudModel) or
auth()->user()->can('create', $crudModel)
)
<h6 class="sidebar-heading px-3 mb-1 text-muted">
<span>{{ __(sprintf('models.classes.%s', strtolower(Str::plural(class_basename($crudModel))))) }}</span>
</h6>
@php
$crudModel = new $crudModel();
@endphp
<ul class="nav flex-column mb-2">
@can('viewAny', $crudModel)
<li class="nav-item"><a class="nav-link" href="{{ route(sprintf('%s%s.index', $prefix ?? '', $crudModel->getTable())) }}">{{ __('Liste') }}</a></li>
@endcan
@can('create', $crudModel)
<li class="nav-item"><a class="nav-link" href="{{ route(sprintf('%s%s.create', $prefix ?? '', $crudModel->getTable())) }}">{{ __('Ajouter') }}</a></li>
@endcan
</ul>
<hr>
@endcan
@endforeach
</div>
<div class="col-12">
<ul class="nav flex-column mb-2">
<li class="nav-item">
<form action="{{ route('logout') }}" method="POST">
@csrf
<button class="btn btn-primary">{{ __('Se déconnecter') }}</button>
</form>
</li>
</ul>
</div>
</div>
</nav>
{{-- <nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
<div class="sidebar-sticky pt-3">
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>CLIENTS</span>
</h6>
<ul class="nav flex-column mb-2">
<li class="nav-item"><a class="nav-link" href="{{route('customers')}}">Rechercher un client</a></li>
</ul>
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>OPT-INS UNIQUES</span>
</h6>
<ul class="nav flex-column mb-2">
<li class="nav-item"><a class="nav-link" href="{{route('single-optins')}}">Rechercher un opt-in</a></li>
</ul>
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>MARQUES</span>
</h6>
<ul class="nav flex-column mb-2">
<li class="nav-item"><a class="nav-link" href="{{route('brands.index')}}">Gestion des marques</a></li>
</ul>
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">
<span>SERVICES</span>
</h6>
<ul class="nav flex-column mb-2">
<li class="nav-item"><a class="nav-link" href="{{route('services.index')}}">Gestion des services</a></li>
</ul>
<ul class="nav flex-column mb-2" style="position: absolute; bottom: 5px;">
<li class="nav-item"><a class="nav-link" href="{{route('logout')}}">Se déconnecter</a></li>
</ul>
</div>
</nav> --}}

View file

@ -1,78 +1,10 @@
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Tableau de bord</title>
@extends('layouts.app')
<script src="https://cdn.ckeditor.com/ckeditor5/23.0.0/classic/ckeditor.js"></script>
<link rel="stylesheet" href="/css/app.css">
<style>
.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;
}
}
html,
body {
height: 100%;
}
body {
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;
}
</style>
</head>
<body class="text-center">
@section('content')
<div class="login text-center">
<form class="form-signin" method="POST" action="{{ route('authenticate') }}">
@csrf
<img class="mb-4" src="{{ asset('images/logo_ldc.png') }}" alt="LDC Services">
<img class="mb-4" src="{{ asset('assets/images/logo_ldc.png') }}" alt="LDC Services">
<h1 class="h3 mb-3 font-weight-normal">LDC CRM</h1>
@if ($errors->any())
<div class="alert alert-danger">
@ -83,12 +15,12 @@
</ul>
</div>
@endif
<label for="inputEmail" class="sr-only">Adresse email</label>
<label for="inputEmail" class="visually-hidden">Adresse email</label>
<input type="email" id="inputEmail" class="form-control" placeholder="Adresse email" name="email" value="{{ old('email') }}" required autofocus>
<label for="inputPassword" class="sr-only">Mot de passe</label>
<label for="inputPassword" class="visually-hidden">Mot de passe</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Mot de passe" name="password" required>
<button class="btn btn-lg btn-primary btn-block" type="submit">Connexion</button>
<p class="mt-5 mb-3 text-muted">&copy; LDC Services {{ date('Y') }}</p>
</form>
</body>
</html>
</div>
@endsection

View file

@ -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')
<div class="card">
@include('crud-policies::crud.modules.flashMessage')
<div class="card-header">
@include('crud-policies::crud.modules.breadcrumb', ['action' => CrudAction::viewAny()])
@include('crud-policies::crud.modules.actionbar.bar', ['action' => CrudAction::viewAny()])
</div>
<div class="card-body">
<div class="row justify-content-end">
<div class="col-6">
<form action="{{ url()->current() }}">
<div class="input-group mb-3">
<input type="search" name="search" class="form-control" value="{{ request()->search }}" placeholder="Recherche.."/>
<input type="text" name="sort_col" class="d-none" value="{{ request()->sort_col }}"/>
<input type="text" name="sort_way" class="d-none" value="{{ request()->sort_way }}"/>
@if(request()->brand)
<input type="hidden" name="brand" class="d-none" value="{{ request()->brand }}"/>
@endif
<a class="btn btn-danger" href="{{ url()->current() }}">{{ __('crud-policies::crud.reset') }}</a>
<button type="submit" class="btn btn-primary">
{{ __('crud-policies::crud.search') }}
</button>
</div>
</form>
</div>
</div>
<table class="table text-center">
<thead class="thead-dark">
<tr>
@foreach ($modelClass::getEditableProperties() as $colname => $prop)
@if(in_array(CrudAction::viewAny(), $prop['actions']))
@switch($prop['type'])
@case(CrudType::password())
{{-- Ignore --}}
@break
@default
<th scope="col">
{{ $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))
<a class="col_sort text-secondary lead asc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'asc']) }}">&nbsp;&darr;&nbsp;</a>
@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))
<a class="col_sort text-secondary lead desc" href="{{ request()->fullUrlWithQuery(['sort_col' => $colname, 'sort_way' => 'desc']) }}">&nbsp;&uarr;&nbsp;</a>
@endif
</th>
@endswitch
@endif
@endforeach
<th scope="col">
{{ __('Date du Bearer token')}}
</th>
<th scope="col">
{{ __('Régénerer un token')}}
</th>
<th scope="col">
{{ __('Date de création')}}
</th>
<th scope="col">
@if(session("crud.$modelTable.sort_way") and session("crud.$modelTable.sort_col"))
<a href="{{ request()->fullUrlWithQuery(['rst' => 'true']) }}" class="btn btn-small btn-danger">&#9003;</a>
@endif
</th>
</tr>
</thead>
<tbody>
@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)
<tr>
@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)
<td>
@foreach($model->{$fieldName} as $pSite)
<a href="{{ CrudController::getRoutePrefixed($pSite->getTable().'.show', $pSite) }}">{{ $pSite->{$prop['belongsToManyLabel']} }}</a>
@endforeach
</td>
@break
@case(CrudType::password())
{{-- Ignore --}}
@break
@default
<td>@include('crud-policies::crud.printfield', [
'action' => CrudAction::viewAny(),
'field' => $model->{$fieldName},
'props' => $prop,
"$modelTable$fieldName" => ${"$modelTable$fieldName"} ?? null
])</td>
@endswitch
@endif
@endforeach
{{-- INFO COLS --}}
<td>{{ Carbon::parse($model->bearer_token_date)->format('m/d/Y à H:i') }}</td>
<td><form class="genToken" action="{{ route('generate-token-service', $model) }}" method="POST">@csrf<button class="btn btn-success">Générer</button></form></td>
<td>{{ $model->created_at->format('m/d/Y à H:i') }}</td>
{{-- MODEL ACTIONS --}}
<td>
<div class="btn-group" role="group" aria-label="{{ Str::plural(__('crud-policies::crud.action')) }}">
@can('view', $model)
<a href="{{ CrudController::getRoutePrefixed("$modelTable.show", $model) }}" class="btn btn-sm btn-primary">{{ __('crud-policies::crud.view') }}</a>
@endcan
@can('update', $model)
<a href="{{ CrudController::getRoutePrefixed("$modelTable.edit", $model) }}" class="btn btn-sm btn-info">{{ __('crud-policies::crud.edit') }}</a>
@endcan
@can('delete', $model)
<form action="{{ CrudController::getRoutePrefixed("$modelTable.destroy", $model) }}" method="POST" onsubmit="__CRUD.confirmDelete(event)">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-sm btn-danger">{{ __('crud-policies::crud.delete') }}</button>
</form>
@endcan
@can('viewAny', \App\Models\Log::class)
<a href="{{ CrudController::getRoutePrefixed("sites.logs.index", $model) }}" class="btn btn-sm btn-dark">{{ __('Journaux') }}</a>
@endcan
@can('viewAny', \App\Models\File::class)
<a href="{{ CrudController::getRoutePrefixed("sites.files.index", $model) }}" class="btn btn-sm btn-dark">{{ __('Fichiers') }}</a>
@endcan
</div>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="{{ count($modelClass::getEditableProperties()) }}">
{{ __('crud-policies::crud.nothingtoshow') }}
</td>
</tr>
@endif
</tbody>
</table>
{{ $models->links() }}
</div>
</div>
@include('crud-policies::crud.modules.scriptConstants')
@endsection

View file

@ -1,36 +0,0 @@
@extends('layout.app')
@section('content')
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h2>{{ __('Gestion des services') }} <small class="text-muted">{{ __('Liste') }}</small></h2>
@if (session('success'))
<span class="text-success text-center">{!! session('success') !!}</span>
@endif
@if (session('error'))
<span class="text-danger text-center">{!! session('error') !!}</span>
@endif
<a href="{{ route('manage-service') }}" class="btn btn-sm btn-primary float-right">{{ __('Ajouter') }}</a>
</div>
<table class="table">
<thead>
<th>{{ __('Nom') }}</th>
<th>{{ __('Marque') }}</th>
<th>{{ __('Date du token') }}</th>
<th>{{ __('Regénérer un token') }}</th>
<th>{{ __('Date de création') }}</th>
<th></th>
</thead>
<tbody>
@foreach ($services as $service)
<tr>
<td>{{ $service->name }}</td>
<td>{{ $service->brand->name }}</td>
<td>{{ Carbon::parse($service->bearer_token_date)->format('d/m/Y à H:i') }}</td>
<td><a href="{{ route('generate-token-service', $service) }}" class="btn btn-sm btn-success">{{ __('Générer') }}</a></td>
<td>{{ Carbon::parse($service->created_at)->format('d/m/Y à H:i') }}</td>
<td><a href="{{ route('manage-service', $service) }}" class="btn btn-sm btn-success">{{ __('Modifier') }}</a></td>
</tr>
@endforeach
</tbody>
</table>
@endsection

View file

@ -1,42 +0,0 @@
@extends('layout.app')
@section('content')
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h2>{{ __('Gestion des services') }} <small class="text-muted">{{ __('Gestion') }}</small></h2>
@if ($errors->any())
<ul class="text-danger text-center">
@foreach(session('errors')->all(':message') as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
@endif
@if (session('success'))
<span class="text-success text-center">{!! session('success') !!}</span>
@endif
<a href="{{ route('services') }}" class="btn btn-sm btn-primary float-right">{{ __('Retour') }}</a>
</div>
<div class="form-group">
<form action="{{ route('manage-service', $service ? $service->id : null) }}" method="POST">
@csrf
<div class="form-group form-row">
<label class="col-form-label col" for="name">{{ __('Nom du service') }}</label>
<input type="text" id="name" name="name" class="form-control col" value="{{ $service ? $service->name : null }}">
</div>
@if (!$edit)
<div class="form-group form-row">
<label class="col-form-label col" for="brand_id">{{ __('Marque associée') }}</label>
<select class="custom-select col" id="brand_id" name="brand_id">
@foreach($brands as $brand)
<option value="{{ $brand->id }}">{{ $brand->name }}</option>
@endforeach
</select>
</div>
@else
<input type="hidden" value="{{ $service->brand->id }}" name="brand_id">
@endif
<div class="text-center">
<input type="submit" class="btn btn-success" value="{{ __('Enregistrer') }}">
</div>
</form>
</div>
@endsection

View file

@ -1,5 +0,0 @@
@extends('layout.app')
@section('content')
<search-optin dbbrands='@json($brands)'></search-optin>
@endsection

View file

@ -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')
<div class="card">
@include('crud-policies::crud.modules.flashMessage')
<div class="card-header">
@include('crud-policies::crud.modules.breadcrumb', ['action' => CrudAction::viewAny()])
@include('crud-policies::crud.modules.actionbar.bar', ['action' => CrudAction::viewAny()])
</div>
<div class="card-body">
<div class="row justify-content-center">
<div class="col">
<form action="{{ url()->current() }}">
<div class="input-group mb-3">
<label class="input-group-text" for="brandSelect">Filter par Marque</label>
<select class="form-select" id="brandSelect">
<option value="0" @if(!request()->brand) selected @endif>Sélectionnez une marque..</option>
@foreach(Brand::all() as $brand)
<option value="{{ $brand->id }}" @if(request()->brand == "$brand->id") selected @endif>{{ $brand->name }}</option>
@endforeach
</select>
<label class="input-group-text bg-warning" for="searchField">🔍🠚</label>
<input type="search" id="searchField" name="search" class="form-control" value="{{ request()->search }}" placeholder="Recherche.."/>
<input type="text" name="sort_col" class="d-none" value="{{ request()->sort_col }}"/>
<input type="text" name="sort_way" class="d-none" value="{{ request()->sort_way }}"/>
@if(request()->brand)
<input type="hidden" name="brand" class="d-none" value="{{ request()->brand }}"/>
@endif
<a class="btn btn-danger" href="{{ url()->current() }}">{{ __('crud-policies::crud.reset') }}</a>
<button type="submit" class="btn btn-primary">
{{ __('crud-policies::crud.search') }}
</button>
</div>
</form>
</div>
</div>
<table class="table text-center">
<thead class="thead-dark">
@include('crud-policies::crud.modules.sorter')
</thead>
<tbody>
@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)
<tr>
@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)
<td>
@foreach($model->{$fieldName} as $pSite)
<a href="{{ CrudController::getRoutePrefixed($pSite->getTable().'.show', $pSite) }}">{{ $pSite->{$prop['belongsToManyLabel']} }}</a>
@endforeach
</td>
@break
@case(CrudType::password())
{{-- Ignore --}}
@break
@default
<td>@include('crud-policies::crud.printfield', [
'action' => CrudAction::viewAny(),
'field' => $model->{$fieldName},
'props' => $prop,
"$modelTable$fieldName" => ${"$modelTable$fieldName"} ?? null
])</td>
@endswitch
@endif
@endforeach
{{-- MODEL ACTIONS --}}
<td>
<div class="btn-group" role="group" aria-label="{{ Str::plural(__('crud-policies::crud.action')) }}">
@can('view', $model)
<a href="{{ CrudController::getRoutePrefixed("$modelTable.show", $model) }}" class="btn btn-sm btn-primary">{{ __('crud-policies::crud.view') }}</a>
@endcan
@can('update', $model)
<a href="{{ CrudController::getRoutePrefixed("$modelTable.edit", $model) }}" class="btn btn-sm btn-info">{{ __('crud-policies::crud.edit') }}</a>
@endcan
@can('delete', $model)
<form action="{{ CrudController::getRoutePrefixed("$modelTable.destroy", $model) }}" method="POST" onsubmit="__CRUD.confirmDelete(event)">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-sm btn-danger">{{ __('crud-policies::crud.delete') }}</button>
</form>
@endcan
</div>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="{{ count($modelClass::getEditableProperties()) }}">
{{ __('crud-policies::crud.nothingtoshow') }}
</td>
</tr>
@endif
</tbody>
</table>
{{ $models->links() }}
</div>
</div>
@include('crud-policies::crud.modules.scriptConstants')
@endsection

View file

@ -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');
});

58
webpack.mix.js vendored
View file

@ -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');