Crud brands
This commit is contained in:
parent
8659827b93
commit
82ca7da7db
15 changed files with 235 additions and 23 deletions
51
app/Http/Controllers/Bo/BrandController.php
Normal file
51
app/Http/Controllers/Bo/BrandController.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Bo;
|
||||
|
||||
use App\Enums\Pagination\ItemsPerPaginationEnum;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ArcadiaBrand;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BrandController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $query */
|
||||
$query = ArcadiaBrand::query();
|
||||
|
||||
if ($request->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]);
|
||||
}
|
||||
}
|
||||
|
|
@ -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)) . '%']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
||||
|
|
|
|||
|
|
@ -3,5 +3,6 @@
|
|||
return [
|
||||
'classes' => [
|
||||
'users' => 'Users',
|
||||
'brands' => 'Brands',
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -125,5 +125,7 @@ return [
|
|||
'publication' => 'Publication',
|
||||
'updated_at' => 'Updated_at',
|
||||
'order' => 'Order',
|
||||
'label' => 'Label',
|
||||
'arcadia_id' => 'Arcadia Id',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -3,5 +3,6 @@
|
|||
return [
|
||||
'classes' => [
|
||||
'users' => 'Utilisateurs',
|
||||
'brands' => 'Marques',
|
||||
]
|
||||
];
|
||||
|
|
|
|||
|
|
@ -125,5 +125,7 @@ return [
|
|||
'publication' => 'Publication',
|
||||
'updated_at' => 'Mis à jour le',
|
||||
'order' => 'Order',
|
||||
'label' => 'Libellé',
|
||||
'arcadia_id' => 'Id Arcadia',
|
||||
],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -1,22 +1,28 @@
|
|||
@auth('backend')
|
||||
<ul class="navbar-nav me-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if(request()->routeIs('bo.dashboard')) active @endif"
|
||||
href="{{ route('bo.dashboard') }}"
|
||||
title="{{ __('Revenir à l\'accueil') }}"
|
||||
data-bs-toggle="tooltip">
|
||||
{{ __('Dashboard') }}
|
||||
</a>
|
||||
</li>
|
||||
@can('isConceptor')
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if(request()->routeIs('bo.users.*')) active @endif"
|
||||
href="{{ route('bo.users.index', ['sort_col' => 'updated_at', 'sort_way' => 'desc']) }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => __('models.classes.users')]) }}"
|
||||
data-bs-toggle="tooltip">
|
||||
{{ __('Users') }}
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
</ul>
|
||||
<ul class="navbar-nav me-auto">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if (request()->routeIs('bo.dashboard')) active @endif" data-bs-toggle="tooltip" href="{{ route('bo.dashboard') }}"
|
||||
title="{{ __('Revenir à l\'accueil') }}">
|
||||
{{ __('Dashboard') }}
|
||||
</a>
|
||||
</li>
|
||||
@can('isConceptor')
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if (request()->routeIs('bo.users.*')) active @endif" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.users.index', ['sort_col' => 'updated_at', 'sort_way' => 'desc']) }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => __('models.classes.users')]) }}">
|
||||
{{ __('models.classes.users') }}
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
@can('isConceptor')
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if (request()->routeIs('bo.brands.*')) active @endif" data-bs-toggle="tooltip"
|
||||
href="{{ route('bo.brands.index', ['sort_col' => 'updated_at', 'sort_way' => 'desc']) }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => __('models.classes.brands')]) }}">
|
||||
{{ __('models.classes.brands') }}
|
||||
</a>
|
||||
</li>
|
||||
@endcan
|
||||
</ul>
|
||||
@endauth
|
||||
|
|
|
|||
51
resources/views/bo/pages/brands/form.blade.php
Normal file
51
resources/views/bo/pages/brands/form.blade.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<div class="row">
|
||||
{{-- ID --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="h-100 border bg-white p-3">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@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' => '',
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- LABEL --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="h-100 border bg-white p-3">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@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' => '',
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- LABEL --}}
|
||||
<div class="col-12">
|
||||
<div class="h1">{{ __('Statistiques') }}</div>
|
||||
<div>
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">{{ __('Nombre de fiches Inco :amount', ['amount' => $brandModel->xmlIncos()->count()]) }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
48
resources/views/bo/pages/brands/index.blade.php
Normal file
48
resources/views/bo/pages/brands/index.blade.php
Normal file
|
|
@ -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')
|
||||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap">
|
||||
@include('modules.breadcrumbs.breadcrumb-body')
|
||||
</div>
|
||||
@include('bo.modules.search-bar')
|
||||
<div class="table-responsive mb-3">
|
||||
<table class="table-hover table-fix-action m-0 table">
|
||||
@if (count($brandModels) > 0)
|
||||
<thead>
|
||||
@include('bo.modules.table-col-sorter', [
|
||||
'cols' => [
|
||||
'id' => __('validation.attributes.arcadia_id'),
|
||||
'label' => __('validation.attributes.label'),
|
||||
'updated_at' => __('validation.attributes.updated_at'),
|
||||
],
|
||||
])
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($brandModels as $brandModel)
|
||||
<tr class="border-bottom list-item">
|
||||
<td class="text-center align-middle">{{ $brandModel->id }}</td>
|
||||
<td class="text-center align-middle">{{ $brandModel->label }}</td>
|
||||
<td class="text-center align-middle"><span class="badge bg-secondary">{{ $brandModel->updated_at }}</span></td>
|
||||
<td class="text-end align-middle">
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-sm btn-warning" data-bs-toggle="tooltip" data-bs-placement="top"
|
||||
href="{{ route('bo.brands.show', $brandModel) }}" title="{{ __('crud.actions.show') }}">
|
||||
<i class="fa-solid fa-eye"></i>
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@else
|
||||
<tr>
|
||||
<td class="border-0">{{ __('list.no_model_found', ['model' => __('models.classes.brands')]) }}</td>
|
||||
</tr>
|
||||
@endif
|
||||
</table>
|
||||
</div>
|
||||
{!! $brandModels->links() !!}
|
||||
@endsection
|
||||
22
resources/views/bo/pages/brands/show.blade.php
Normal file
22
resources/views/bo/pages/brands/show.blade.php
Normal file
|
|
@ -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')
|
||||
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap pb-3">
|
||||
<div class="d-flex align-items-start flex-row">
|
||||
<a class="btn btn-primary text-decoration-none m-0" data-bs-toggle="tooltip" data-bs-placement="top"
|
||||
href="{{ route('bo.brands.index', ['sort_col' => 'updated_at', 'sort_way' => 'desc']) }}"
|
||||
title="{{ __('crud.helpers.list_all', ['model' => __('models.classes.brands')]) }}">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $brandModel])
|
||||
</div>
|
||||
<div class="mb-md-0 mb-2">
|
||||
</div>
|
||||
</div>
|
||||
@include('bo.pages.brands.form')
|
||||
@endsection
|
||||
|
|
@ -25,6 +25,9 @@
|
|||
@else
|
||||
min="{{ !empty($unsigned) ? '0' : '-2147483648' }}"
|
||||
@endif
|
||||
@if(!empty($disabled))
|
||||
disabled
|
||||
@endif
|
||||
@if(!empty($required))
|
||||
required
|
||||
@endif>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Http\Controllers\Bo\BrandController;
|
||||
use App\Http\Controllers\Bo\DashboardController;
|
||||
use App\Http\Controllers\Bo\UsersController;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
|
@ -22,7 +23,6 @@ Route::prefix('bo')
|
|||
);
|
||||
});
|
||||
Route::middleware('auth:backend')->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']
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue