update CRUD brand
This commit is contained in:
parent
ad5becf181
commit
ff292c6f26
15 changed files with 416 additions and 218 deletions
|
|
@ -3,42 +3,125 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\StoreBrandRequest;
|
||||
use App\Http\Requests\UpdateBrandRequest;
|
||||
use App\Models\Brand;
|
||||
use Kwaadpepper\CrudPolicies\Http\Requests\CrudIndexRequest;
|
||||
use Kwaadpepper\CrudPolicies\Traits\CrudController;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class BrandController extends Controller
|
||||
{
|
||||
use CrudController {
|
||||
index as crudIndex;
|
||||
}
|
||||
|
||||
/** @var Brand */
|
||||
public static $modelClass = Brand::class;
|
||||
|
||||
/**
|
||||
* The Bo app layout
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $layout = 'layouts.app';
|
||||
|
||||
/**
|
||||
* Overload crud-policies index
|
||||
*
|
||||
* @param CrudIndexRequest $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(CrudIndexRequest $request)
|
||||
public function index(Request $request)
|
||||
{
|
||||
/** @var \Illuminate\View\View */
|
||||
$view = $this->crudIndex($request);
|
||||
if ($request->ajax()) {
|
||||
return $view;
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $brands */
|
||||
$brands = Brand::query();
|
||||
|
||||
if ($request->search) {
|
||||
$this->searchQuery(
|
||||
$brands,
|
||||
$request->search,
|
||||
null,
|
||||
'name',
|
||||
);
|
||||
}
|
||||
return view('brand.index', $view->getData());
|
||||
|
||||
$this->sortQuery($brands);
|
||||
$searchFields = trans('Nom');
|
||||
|
||||
$brandModels = $brands->paginate(12);
|
||||
|
||||
return view('brands.index', compact('brandModels', 'searchFields'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @param \App\Models\Brand $brands
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create(Brand $brands)
|
||||
{
|
||||
return view('brands.create', [
|
||||
'brandModel' => $brands
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Brands\StoreBrandRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(StoreBrandRequest $request)
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$brand = new Brand();
|
||||
$brand->fill($request->validated());
|
||||
if ($brand->saveOrFail()) {
|
||||
return redirect()
|
||||
->route('brands.edit', $brand)
|
||||
->with('success', trans(
|
||||
':model a été créé',
|
||||
['model' => Str::singular(trans('models.classes.brands'))]
|
||||
));
|
||||
}
|
||||
return redirect()
|
||||
->back()
|
||||
->with('error', trans(
|
||||
':model n\'a pas été créé',
|
||||
['model' => Str::singular(trans('models.classes.brands'))]
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Models\Brand $brands
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit(Brand $brands)
|
||||
{
|
||||
return view('brands.edit', [
|
||||
'brandModel' => $brands
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a spacific resource in storage.
|
||||
*
|
||||
* @param \App\Http\Requests\Brands\UpdateBrandRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(UpdateBrandRequest $request)
|
||||
{
|
||||
return DB::transaction(function () use ($request) {
|
||||
$brand = new Brand();
|
||||
$brand->fill($request->validated());
|
||||
if ($brand->saveOrFail()) {
|
||||
return redirect()
|
||||
->route('brands.edit', $brand)
|
||||
->with('success', trans(
|
||||
':model a été mis à jour',
|
||||
['model' => Str::singular(trans('models.classes.brands'))]
|
||||
));
|
||||
}
|
||||
return redirect()
|
||||
->back()
|
||||
->with('error', trans(
|
||||
':model n\'a pas été mis à jour',
|
||||
['model' => Str::singular(trans('models.classes.brands'))]
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
42
app/Http/Requests/StoreBrandRequest.php
Normal file
42
app/Http/Requests/StoreBrandRequest.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StoreBrandRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth()->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|min:3|max:255',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'name' => trans('Nom de la marque'),
|
||||
];
|
||||
}
|
||||
}
|
||||
7
app/Http/Requests/UpdateBrandRequest.php
Normal file
7
app/Http/Requests/UpdateBrandRequest.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
class UpdateBrandRequest extends StoreBrandRequest
|
||||
{
|
||||
}
|
||||
|
|
@ -4,15 +4,10 @@ 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;
|
||||
|
||||
|
|
@ -47,22 +42,6 @@ class Brand extends Model
|
|||
{
|
||||
$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()
|
||||
]
|
||||
]
|
||||
];
|
||||
parent::__construct($attributes);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,158 +0,0 @@
|
|||
@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']) }}"> ↓ </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']) }}"> ↑ </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">⌫</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
|
||||
50
resources/views/brands/create.blade.php
Normal file
50
resources/views/brands/create.blade.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
@extends('layouts.app', ['brParam' => $brandModel])
|
||||
|
||||
@section('title', sprintf('%s - %s', __('models.classes.brands'), Str::ucfirst(__('création'))))
|
||||
@section('description', __('Création d\'une :model', ['model' => __('models.classes.brands')]))
|
||||
@section('metaIndex', 'noindex,nofollow')
|
||||
@section('breadcrumb', request()->route()->getName())
|
||||
|
||||
@section('content')
|
||||
<div class="card border-0">
|
||||
<div class="card-header bg-light">
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center">
|
||||
<div class="d-flex flex-row align-items-start">
|
||||
<a href="{{ route('brands.index') }}"
|
||||
class="btn btn-primary text-decoration-none me-2"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
title="{{ __('Retourner sur la liste des :model', ['model' => __('models.classes.brands')]) }}"
|
||||
data-bs-toggle="tooltip">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
@include('breadcrumbs.breadcrumb-body', ['brParam' => $brandModel])
|
||||
</div>
|
||||
<div class="col-12 col-md-4 d-flex justify-content-center justify-content-md-end align-items-center">
|
||||
<button id="formSubmitClone"
|
||||
type="button"
|
||||
class="btn btn-primary pull-end"
|
||||
title="{{ __('Sauvegarder ce :model', ['model' => Str::singular(__('models.classes.brands'))]) }}"
|
||||
data-bs-toggle="tooltip">
|
||||
{{ __('Sauvegarder') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body bg-white">
|
||||
<form action="{{ route('brands.store') }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@include('brands.form')
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<button type="submit"
|
||||
class="btn btn-primary"
|
||||
title="{{ __('Sauvegarder ce :model', ['model' => Str::singular(__('models.classes.brands'))]) }}"
|
||||
data-bs-toggle="tooltip">{{ __('Sauvegarder') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
54
resources/views/brands/edit.blade.php
Normal file
54
resources/views/brands/edit.blade.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
@extends('layouts.app', ['brParam' => $brandModel])
|
||||
|
||||
@section('title', sprintf('%s - %s', __('models.classes.brands'), Str::ucfirst(__('édition'))))
|
||||
@section('description', __('Édition d\'une :model', ['model' => __('models.classes.brands')]))
|
||||
@section('metaIndex', 'noindex,nofollow')
|
||||
@section('breadcrumb', request()->route()->getName())
|
||||
|
||||
@section('content')
|
||||
<div class="card border-0">
|
||||
<div class="card-header bg-light">
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center">
|
||||
<div class="d-flex flex-row align-items-start">
|
||||
<a href="{{ route('brands.index') }}"
|
||||
class="btn btn-primary text-decoration-none me-2"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
title="{{ __('Retourner sur la liste des :model', ['model' => __('models.classes.brands')]) }}"
|
||||
data-bs-toggle="tooltip">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
@include('breadcrumbs.breadcrumb-body', ['brParam' => $brandModel])
|
||||
</div>
|
||||
<div class="col-12 col-md-4 d-flex justify-content-center justify-content-md-end align-items-center">
|
||||
<button id="formSubmitClone"
|
||||
type="button"
|
||||
class="btn btn-primary pull-end"
|
||||
title="{{ __('Sauvegarder cette :model', ['model' => Str::singular(__('models.classes.brands'))]) }}"
|
||||
data-bs-toggle="tooltip">
|
||||
{{ __('Sauvegarder') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body bg-white">
|
||||
<form action="{{ route('brands.update', $brandModel->id) }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
@include('brands.form')
|
||||
<div class="row">
|
||||
<div class="col text-center">
|
||||
<button id="formSubmit"
|
||||
type="submit"
|
||||
class="btn btn-primary"
|
||||
title="{{ __('Sauvegarder ce :model', ['model' => Str::singular(__('models.classes.brands'))]) }}"
|
||||
data-bs-toggle="tooltip">
|
||||
{{ __('Sauvegarder') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
21
resources/views/brands/form.blade.php
Normal file
21
resources/views/brands/form.blade.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<div class="row">
|
||||
{{-- TITLE --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<legend>{{ __('Nom') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
@include('partials.inputs.varchar', [
|
||||
'id' => 'brandName',
|
||||
'label' => __('Nom de la :model', ['model' => Str::singular(__('models.classes.brands'))]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'name',
|
||||
'required' => true,
|
||||
'model' => $brandModel ?? null,
|
||||
'helper' => __('Doit décrire précisément le produit (3 caractères minimum, 255 maximum).'),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
60
resources/views/brands/index-list.blade.php
Normal file
60
resources/views/brands/index-list.blade.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<div class="table-responsive">
|
||||
<table class="table table-hover fix-action m-0">
|
||||
<thead class="border-dark border-top-0 border-start-0 border-end-0 border-2">
|
||||
@php
|
||||
$rst = !is_null(request()->rst);
|
||||
$routeName = request()->route()->getName();
|
||||
$noOrder = Session::get("$routeName.sort_col") !== 'status' and (Session::has("$routeName.sort_col") or Session::has("$routeName.sort_way"));
|
||||
$cols = [
|
||||
'name' => __('Nom'),
|
||||
'status' => __('Nombre de comptes'),
|
||||
'optin' => __('Nombre d\'optins'),
|
||||
'updated_at' => __('Date d\'ajout en base')
|
||||
];
|
||||
@endphp
|
||||
@include('modules.table-col-sorter', ['cols' => $cols, 'mobileHide' => ['status'], 'ignore' => ['status', 'optin', 'updated_at']])
|
||||
</thead>
|
||||
<tbody>
|
||||
@if($brandModels->count())
|
||||
@foreach ($brandModels as $brandModel)
|
||||
<tr>
|
||||
<td class="text-center align-middle bg-white">{{ $brandModel->name }}</td>
|
||||
<td class="text-center align-middle bg-white">{{ count(\App\Models\CustomerInfo::where('brand_id', 'LIKE', $brandModel->id)->get()) }}</td>
|
||||
<td class="text-center align-middle bg-white">{{ count(\App\Models\CustomerInfo::where('brand_id', 'LIKE', $brandModel->id)->where('opt_in', true)->get()) }}</td>
|
||||
@php $routeName = request()->route()->getName(); @endphp
|
||||
@if(empty(request()->search) and empty($noOrder) and Session::get("$routeName.sort_col") === 'order')
|
||||
<td class="d-flex">
|
||||
<form action="{{ route('brands.change-order', ['product' => $brandModel, 'action' => 'up']) }}" method="POST" class="text-center @if($loop->first and $brandModels->onFirstPage()) invisible @endif">
|
||||
@csrf
|
||||
<button type="submit" class="btn btn-sm @if(($loop->first and $brandModels->onFirstPage())) disabled @endif" title="{{ __('Change the order of appearance upwards') }}" data-bs-toggle="tooltip">
|
||||
<i class="fas fa-arrow-alt-circle-up"></i>
|
||||
</button>
|
||||
</form>
|
||||
<form action="{{ route('brands.change-order', ['product' => $brandModel, 'action' => 'down']) }}" method="POST" class="text-center @if($loop->last and $brandModels->currentPage() === $brandModels->lastPage()) invisible @endif">
|
||||
@csrf
|
||||
<button type="submit" class="btn btn-sm @if($loop->last and $brandModels->currentPage() === $brandModels->lastPage()) disabled @endif" title="{{ __('Change the order of appearance downwards') }}" data-bs-toggle="tooltip">
|
||||
<i class="fas fa-arrow-alt-circle-down"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
@endif
|
||||
<td class="text-center align-middle bg-white">
|
||||
<span class="badge bg-warning text-dark text-wrap">{{ $brandModel->updated_at->formatLocalized('%d/%m/%Y à %H:%M') }}</span>
|
||||
</td>
|
||||
<td class="text-end align-middle bg-white">
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('brands.edit', $brandModel->id) }}" title="{{ __('Modifier cette :model', ['model' => Str::singular(__('models.classes.brands'))]) }}" data-bs-toggle="tooltip">
|
||||
<i class="fa-solid fa-pencil"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@else
|
||||
<tr>
|
||||
<td colspan="5" class="text-center bg-white">
|
||||
<span class="h3">{{ __('Aucun résultat pour les :models', ['models' => __('models.classes.brands')]) }}
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
37
resources/views/brands/index.blade.php
Normal file
37
resources/views/brands/index.blade.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
@extends('layouts.app')
|
||||
|
||||
@section('title', sprintf('%s - %s', __('models.classes.brands'), Str::ucfirst(__('liste'))))
|
||||
@section('description', __('Listage de toutes les :model', ['model' => __('models.classes.brands')]))
|
||||
@section('metaIndex', 'noindex,nofollow')
|
||||
|
||||
@section('content')
|
||||
<div class="row w-100 mx-auto">
|
||||
<div class="col p-0">
|
||||
<div class="card rounded-0 border-0">
|
||||
<div class="card-header bg-light">
|
||||
<div class="row w-100 mx-auto">
|
||||
<div class="col p-0">
|
||||
@include('breadcrumbs.breadcrumb-body')
|
||||
</div>
|
||||
<div class="col-md-3 d-flex align-items-center p-0">
|
||||
<div class="input-group justify-content-end">
|
||||
<a href="{{ route('brands.create') }}" class="btn btn-primary" title="{{ __('Ajouter une :model', ['model' => Str::singular(__('models.classes.brands'))]) }}" data-bs-toggle="tooltip">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body bg-white">
|
||||
@include('modules.search-bar')
|
||||
<div class="row w-100 mx-auto">
|
||||
<div class="col p-0">
|
||||
@include('brands.index-list')
|
||||
</div>
|
||||
</div>
|
||||
{!! $brandModels->links() !!}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
|
@ -10,10 +10,21 @@
|
|||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
@if(auth()->check())
|
||||
@include('layouts.backend.sidenav', ['modelsClasses' => [
|
||||
\App\Models\Brand::class,
|
||||
\App\Models\Question::class,
|
||||
\App\Models\Service::class,
|
||||
\App\Models\SingleOptin::class
|
||||
]])
|
||||
<main role="main" class="col-md-9 mt-5 mb-5 ml-sm-auto col-lg-10 px-md-4 bg-white body-full">
|
||||
@else
|
||||
<main role="main" class="mt-5 mb-5 bg-white body-full">
|
||||
@endif
|
||||
<div class="row justify-content-center bg-light">
|
||||
<div class="col col-md-6">
|
||||
@include('modules.flash-messages')
|
||||
</div>
|
||||
</div>
|
||||
@yield('content')
|
||||
</main>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,39 +1,36 @@
|
|||
@if(!request()->routeIs('login'))
|
||||
@if ($message = Session::get('success', Session::get('bo.success')))
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<div class="alert alert-success alert-dismissible fade show my-2" role="alert">
|
||||
<strong>{!! nl2br(e($message)) !!}</strong>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="{{ __('Fermer') }}"></button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($message = Session::get('error', Session::get('bo.error')))
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<div class="alert alert-danger alert-dismissible fade show my-2" role="alert">
|
||||
<strong>{!! nl2br(e($message)) !!}</strong>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="{{ __('Fermer') }}"></button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
@if ($message = Session::get('warning', Session::get('bo.warning')))
|
||||
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
||||
<div class="alert alert-warning alert-dismissible fade show my-2" role="alert">
|
||||
<strong>{!! nl2br(e($message)) !!}</strong>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="{{ __('Fermer') }}"></button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
@if ($message = Session::get('info', Session::get('bo.info')))
|
||||
<div class="alert alert-info alert-dismissible fade show" role="alert">
|
||||
<div class="alert alert-info alert-dismissible fade show my-2" role="alert">
|
||||
<strong>{!! nl2br(e($message)) !!}</strong>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="{{ __('Fermer') }}"></button>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
@if ($errors->any())
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<div class="alert alert-danger alert-dismissible fade show my-2" role="alert">
|
||||
@if ($errors->any())
|
||||
<ul class="list-unstyled">
|
||||
<ul class="list-unstyled m-0">
|
||||
@foreach ($errors->all() as $error)
|
||||
<li>{{ $error }}</li>
|
||||
@endforeach
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ $ignore = (isset($ignore) and is_array($ignore)) ? $ignore : [];
|
|||
{{-- NO Sort for order column --}}
|
||||
@if($col === 'order' or in_array($col, $ignore))
|
||||
@if($noOrder and !$rst and !in_array($col, $ignore)) @continue @endif
|
||||
<th scope="col" class="text-center @if(isset($mobileHide) and is_array($mobileHide) and in_array($col, $mobileHide)) d-none d-md-table-cell @endif">
|
||||
<th scope="col" class="text-center bg-white @if(isset($mobileHide) and is_array($mobileHide) and in_array($col, $mobileHide)) d-none d-md-table-cell @endif">
|
||||
<span class="text-nowrap">{{ $colname }}</span>
|
||||
</th>
|
||||
@continue
|
||||
@endif
|
||||
<th scope="col" class="text-center @if(isset($mobileHide) and is_array($mobileHide) and in_array($col, $mobileHide)) d-none d-md-table-cell @endif">
|
||||
<th scope="col" class="text-center bg-white @if(isset($mobileHide) and is_array($mobileHide) and in_array($col, $mobileHide)) d-none d-md-table-cell @endif">
|
||||
<span class="text-nowrap">
|
||||
{{ $colname }}
|
||||
</span>
|
||||
|
|
@ -53,7 +53,7 @@ $ignore = (isset($ignore) and is_array($ignore)) ? $ignore : [];
|
|||
</th>
|
||||
@endforeach
|
||||
{{-- Buttons Col --}}
|
||||
<th class="text-end" scope="col">
|
||||
<th class="text-end bg-white" scope="col">
|
||||
@if($noOrder and !$rst)
|
||||
<a class="btn btn-sm btn-danger"
|
||||
href="{{ request()->fullUrlWithQuery(['sort_col' => null, 'sort_way' => null, 'rst' => true, 'search' => null]) }}"
|
||||
|
|
|
|||
|
|
@ -1 +1,18 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Brand;
|
||||
use Diglactic\Breadcrumbs\Breadcrumbs;
|
||||
use Diglactic\Breadcrumbs\Generator;
|
||||
|
||||
// * BRANDS
|
||||
Breadcrumbs::for('brands.index', function (Generator $trail) {
|
||||
$trail->push(trans('Marques'), route('brands.index'));
|
||||
});
|
||||
Breadcrumbs::for('brands.create', function (Generator $trail) {
|
||||
$trail->parent('brands.index');
|
||||
$trail->push(trans('Création'), route('brands.create'));
|
||||
});
|
||||
Breadcrumbs::for('brands.edit', function (Generator $trail, Brand $brand) {
|
||||
$trail->parent('brands.index');
|
||||
$trail->push(trans('Édition'), route('brands.edit', $brand));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ Route::middleware(['auth'])->group(function () {
|
|||
Route::post('/logout', [LoginController::class, 'logout'])->name('logout');
|
||||
|
||||
// * Marques
|
||||
Route::resource('brands', BrandController::class)->except([
|
||||
'delete'
|
||||
]);
|
||||
Route::resource('brands', BrandController::class)->except(['delete']);
|
||||
Route::match(['get', 'post'], '/brand/manage/{brand?}', [BrandController::class, 'manage'])
|
||||
->name('manage-brand');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue