diff --git a/app/Http/Controllers/Bo/BrandController.php b/app/Http/Controllers/Bo/BrandController.php new file mode 100644 index 0000000..2efb73f --- /dev/null +++ b/app/Http/Controllers/Bo/BrandController.php @@ -0,0 +1,51 @@ +search) { + $this->searchQuery( + $query, + $request->search, + null, + 'id', + 'label', + ); + } + + $this->sortQuery($query); + $searchFields = trans('Arcadia id, Label'); + + $brandModels = $this->paginate($query, ItemsPerPaginationEnum::twentyfive); + + return view('bo.pages.brands.index', compact('brandModels', 'searchFields')); + } + + /** + * Display the specified resource. + * + * @param \App\Models\ArcadiaBrand $arcadiaBrand + * @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory + */ + public function show(ArcadiaBrand $arcadiaBrand) + { + return view('bo.pages.brands.show', ['brandModel' => $arcadiaBrand]); + } +} diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index cedbec5..e82c86e 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -75,12 +75,12 @@ class Controller extends BaseController sprintf("UPPER(CONCAT(%s)) LIKE UPPER(?)", collect($f)->map(function ($q) use ($table) { return "`$table`.`$q`"; })->implode(', \' \', ')), - ['%' . filter_var($search, FILTER_SANITIZE_STRING) . '%'] + ['%' . preg_replace('/\x00|<[^>]*>?/', '', \strip_tags($search)) . '%'] ); } else { $query->orWhereRaw( "UPPER(`$table`.`$f`) LIKE UPPER(?)", - ['%' . filter_var($search, FILTER_SANITIZE_STRING) . '%'] + ['%' . preg_replace('/\x00|<[^>]*>?/', '', \strip_tags($search)) . '%'] ); } } diff --git a/app/Models/ArcadiaBrand.php b/app/Models/ArcadiaBrand.php index 7de3b9e..661f58b 100644 --- a/app/Models/ArcadiaBrand.php +++ b/app/Models/ArcadiaBrand.php @@ -4,6 +4,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\HasMany; use Rennokki\QueryCache\Traits\QueryCacheable; /** @@ -99,4 +100,14 @@ class ArcadiaBrand extends Model { return $this->belongsToMany(Service::class); } + + /** + * Get all of the xmlIncos for the ArcadiaBrand + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function xmlIncos(): HasMany + { + return $this->hasMany(XmlInco::class); + } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 7c71b2f..09e2251 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use Illuminate\Database\Eloquent\Model; use Illuminate\Pagination\Paginator; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\App; @@ -20,6 +21,9 @@ class AppServiceProvider extends ServiceProvider */ public function boot() { + // * Strict Mode + Model::shouldBeStrict(!$this->app->environment('production')); + // * HTTPS FIX URL::forceScheme('https'); diff --git a/resources/lang/en/models.php b/resources/lang/en/models.php index dc2eea9..2bb83a8 100644 --- a/resources/lang/en/models.php +++ b/resources/lang/en/models.php @@ -3,5 +3,6 @@ return [ 'classes' => [ 'users' => 'Users', + 'brands' => 'Brands', ] ]; diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index d3f2d04..8110fbb 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -125,5 +125,7 @@ return [ 'publication' => 'Publication', 'updated_at' => 'Updated_at', 'order' => 'Order', + 'label' => 'Label', + 'arcadia_id' => 'Arcadia Id', ], ]; diff --git a/resources/lang/fr/models.php b/resources/lang/fr/models.php index a028f96..65e6a1f 100644 --- a/resources/lang/fr/models.php +++ b/resources/lang/fr/models.php @@ -3,5 +3,6 @@ return [ 'classes' => [ 'users' => 'Utilisateurs', + 'brands' => 'Marques', ] ]; diff --git a/resources/lang/fr/validation.php b/resources/lang/fr/validation.php index f8cf269..abdd231 100644 --- a/resources/lang/fr/validation.php +++ b/resources/lang/fr/validation.php @@ -125,5 +125,7 @@ return [ 'publication' => 'Publication', 'updated_at' => 'Mis à jour le', 'order' => 'Order', + 'label' => 'Libellé', + 'arcadia_id' => 'Id Arcadia', ], ]; diff --git a/resources/views/bo/layouts/nav-list.blade.php b/resources/views/bo/layouts/nav-list.blade.php index ac304f2..2cb46ae 100644 --- a/resources/views/bo/layouts/nav-list.blade.php +++ b/resources/views/bo/layouts/nav-list.blade.php @@ -1,22 +1,28 @@ @auth('backend') - + @endauth diff --git a/resources/views/bo/pages/brands/form.blade.php b/resources/views/bo/pages/brands/form.blade.php new file mode 100644 index 0000000..0ca16c7 --- /dev/null +++ b/resources/views/bo/pages/brands/form.blade.php @@ -0,0 +1,51 @@ +
+ {{-- ID --}} +
+
+
+
+ @include('bo.partials.inputs.int-number', [ + 'id' => 'brandFirstname', + 'label' => __('Id Arcadia de la :model', ['model' => Str::singular(__('models.classes.brands'))]), + 'hasWordCounter' => true, + 'name' => 'id', + 'required' => false, + 'model' => $brandModel ?? null, + 'helper' => '', + 'disabled' => true, + 'placeholder' => '', + ]) +
+
+
+
+ {{-- LABEL --}} +
+
+
+
+ @include('bo.partials.inputs.varchar', [ + 'id' => 'brandLabel', + 'label' => __('Libellé de la :model', ['model' => Str::singular(__('models.classes.brands'))]), + 'hasWordCounter' => false, + 'name' => 'label', + 'required' => false, + 'disabled' => true, + 'model' => $brandModel ?? null, + 'helper' => '', + 'placeholder' => '', + ]) +
+
+
+
+ {{-- LABEL --}} +
+
{{ __('Statistiques') }}
+
+
    +
  • {{ __('Nombre de fiches Inco :amount', ['amount' => $brandModel->xmlIncos()->count()]) }}
  • +
+
+
+
diff --git a/resources/views/bo/pages/brands/index.blade.php b/resources/views/bo/pages/brands/index.blade.php new file mode 100644 index 0000000..5bf8dda --- /dev/null +++ b/resources/views/bo/pages/brands/index.blade.php @@ -0,0 +1,48 @@ +@extends('bo.layout') + +@section('title', __('models.classes.brands')) +@section('description', __('Liste de tous les :model', ['model' => __('models.classes.brands')])) + +@section('content') +
+ @include('modules.breadcrumbs.breadcrumb-body') +
+ @include('bo.modules.search-bar') +
+ + @if (count($brandModels) > 0) + + @include('bo.modules.table-col-sorter', [ + 'cols' => [ + 'id' => __('validation.attributes.arcadia_id'), + 'label' => __('validation.attributes.label'), + 'updated_at' => __('validation.attributes.updated_at'), + ], + ]) + + + @foreach ($brandModels as $brandModel) + + + + + + + @endforeach + + @else + + + + @endif +
{{ $brandModel->id }}{{ $brandModel->label }}{{ $brandModel->updated_at }} +
+ + + +
+
{{ __('list.no_model_found', ['model' => __('models.classes.brands')]) }}
+
+ {!! $brandModels->links() !!} +@endsection diff --git a/resources/views/bo/pages/brands/show.blade.php b/resources/views/bo/pages/brands/show.blade.php new file mode 100644 index 0000000..9c57d06 --- /dev/null +++ b/resources/views/bo/pages/brands/show.blade.php @@ -0,0 +1,22 @@ +@extends('bo.layout', ['brParam' => $brandModel]) + +@section('title', __('Édition d\'un :model', ['model' => Str::singular(__('models.classes.brands'))])) +@section('description', __('Édition d\'un :model déjà existant', ['model' => Str::singular(__('models.classes.brands'))])) +@section('breadcrumb', + request()->route()->getName()) + +@section('content') +
+
+ + + + @include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $brandModel]) +
+
+
+
+ @include('bo.pages.brands.form') +@endsection diff --git a/resources/views/bo/partials/inputs/int-number.blade.php b/resources/views/bo/partials/inputs/int-number.blade.php index 6879aa1..88bd77c 100644 --- a/resources/views/bo/partials/inputs/int-number.blade.php +++ b/resources/views/bo/partials/inputs/int-number.blade.php @@ -25,6 +25,9 @@ @else min="{{ !empty($unsigned) ? '0' : '-2147483648' }}" @endif + @if(!empty($disabled)) + disabled + @endif @if(!empty($required)) required @endif> diff --git a/resources/views/bo/partials/inputs/varchar.blade.php b/resources/views/bo/partials/inputs/varchar.blade.php index 2f5f308..9c7967c 100644 --- a/resources/views/bo/partials/inputs/varchar.blade.php +++ b/resources/views/bo/partials/inputs/varchar.blade.php @@ -13,6 +13,9 @@ id="{{ $id }}" aria-describedby="{{ $id }}Help" placeholder="{{ $placeholder ?? __('A beautiful title') }}" + @if(!empty($disabled)) + disabled + @endif @if(!empty($required)) required @endif> diff --git a/routes/web-bo.php b/routes/web-bo.php index 87e3854..f0ddd97 100644 --- a/routes/web-bo.php +++ b/routes/web-bo.php @@ -1,5 +1,6 @@ group(function () { - Route::get('/', [DashboardController::class, 'index'])->name('dashboard'); Route::middleware('can:isConceptor')->group(function () { Route::resource('users', UsersController::class)->except('show'); Route::get('/users/change-order/{user}/{direction}', [ @@ -35,5 +35,12 @@ Route::prefix('bo') UsersController::class, 'duplicate' ])->name('users.duplicate'); }); + + Route::get('/', [DashboardController::class, 'index'])->name('dashboard'); + + Route::resource('arcadia_brands', BrandController::class, [ + 'names' => 'brands', + 'only' => ['index', 'show'] + ]); }); });