update CRUD app-users #3
This commit is contained in:
parent
d4d7268707
commit
f0223f3cd6
28 changed files with 1866 additions and 477 deletions
|
|
@ -5,13 +5,26 @@ namespace App\Http\Controllers\Bo;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Bo\AppUser\StoreAppUserRequest;
|
||||
use App\Http\Requests\Bo\AppUser\UpdateAppUserRequest;
|
||||
use App\Http\Requests\Bo\ImportRequest;
|
||||
use App\Imports\AppUserImport;
|
||||
use App\Models\AppUser;
|
||||
use App\Models\Directory;
|
||||
use App\Traits\Controllers\ChangesModelOrder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class AppUserController extends Controller
|
||||
{
|
||||
use ChangesModelOrder;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $nameDirectory = "";
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
|
|
@ -49,7 +62,9 @@ class AppUserController extends Controller
|
|||
*/
|
||||
public function create()
|
||||
{
|
||||
return view('bo.pages.app-users.create');
|
||||
$directories = $this->renderDirectories(Directory::where('needAuthorization', 1)->get());
|
||||
|
||||
return view('bo.pages.app-users.create', compact('directories'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -63,11 +78,9 @@ class AppUserController extends Controller
|
|||
return DB::transaction(function () use ($request) {
|
||||
$app_user = new AppUser();
|
||||
$app_user->fill($request->validated());
|
||||
if (!isset($request->validated()['status'])) {
|
||||
$app_user->status = 0;
|
||||
}
|
||||
|
||||
if ($app_user->saveOrFail()) {
|
||||
$app_user->directories()->sync(collect($request->directories)->pluck('id'));
|
||||
return redirect()
|
||||
->route('bo.app-users.edit', $app_user)
|
||||
->with('success', trans(
|
||||
|
|
@ -93,8 +106,12 @@ class AppUserController extends Controller
|
|||
*/
|
||||
public function edit(AppUser $app_user)
|
||||
{
|
||||
$directories = $this->renderDirectories(Directory::where('needAuthorization', 1)->get());
|
||||
$app_user->directories = $this->renderDirectories($app_user->directories);
|
||||
|
||||
return view('bo.pages.app-users.edit', [
|
||||
'app_userModel' => $app_user,
|
||||
'directories' => $directories
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -107,15 +124,14 @@ class AppUserController extends Controller
|
|||
*/
|
||||
public function update(UpdateAppUserRequest $request, AppUser $app_user)
|
||||
{
|
||||
$app_user->directories()->sync(collect($request->directories)->pluck('id'));
|
||||
$params = $request->validated();
|
||||
if (\is_null($params['password'])) {
|
||||
unset($params['password']);
|
||||
}
|
||||
return DB::transaction(function () use ($params, $app_user) {
|
||||
$app_user->fill($params);
|
||||
if (!isset($params['status'])) {
|
||||
$app_user->status = !$app_user->status;
|
||||
}
|
||||
|
||||
if ($app_user->saveOrFail()) {
|
||||
return redirect()
|
||||
->route('bo.app-users.edit', $app_user)
|
||||
|
|
@ -153,8 +169,57 @@ class AppUserController extends Controller
|
|||
return redirect()
|
||||
->back()
|
||||
->with('error', trans(
|
||||
':model n\'a pas été supprimée',
|
||||
':model n\'a pas été supprimé',
|
||||
['model' => Str::singular(trans('models.classes.app_users'))]
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render directories.
|
||||
*
|
||||
* @param Collection $directories
|
||||
* @return array
|
||||
*/
|
||||
private function renderDirectories(Collection $directories)
|
||||
{
|
||||
foreach ($directories as $k => $directory) {
|
||||
$this->nameDirectory = "";
|
||||
$directories[$k]->name = $this->renameDirectory($directory);
|
||||
}
|
||||
return $directories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename directory.
|
||||
*
|
||||
* @param Directory $directory
|
||||
* @return array
|
||||
*/
|
||||
private function renameDirectory(Directory $directory)
|
||||
{
|
||||
if (strlen($this->nameDirectory)) {
|
||||
$this->nameDirectory = $directory->name . " / " . $this->nameDirectory;
|
||||
} else {
|
||||
$this->nameDirectory = $directory->name;
|
||||
}
|
||||
if (isset($directory->parent)) {
|
||||
$this->renameDirectory($directory->parent);
|
||||
}
|
||||
return $this->nameDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mass import by CSV.
|
||||
* matricule;lastname;firstname;email
|
||||
* default role = user
|
||||
*
|
||||
* @param \App\Http\Requests\Bo\ImportRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function import(ImportRequest $request)
|
||||
{
|
||||
Excel::import(new AppUserImport(), $request->import, null, \Maatwebsite\Excel\Excel::CSV);
|
||||
|
||||
return redirect()->route('bo.app-users.index')->with('success', 'Import terminé.');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,19 @@ class StoreAppUserRequest extends FormRequest
|
|||
return auth('backend')->check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the data for validation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'status' => $this->status ? true : false,
|
||||
'authorizedFolders' => $this->authorizedFolders ? $this->authorizedFolders : [],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
|
@ -29,13 +42,13 @@ class StoreAppUserRequest extends FormRequest
|
|||
'lastname' => 'required|min:3|max:255',
|
||||
'firstname' => 'required|min:3|max:255',
|
||||
'email' => 'required|min:3|max:255|email:rfc,dns|unique:app_users,email',
|
||||
'password' => 'min:8',
|
||||
'authorizedFolders' => 'json|required',
|
||||
'password' => 'required|nullable|required_with:password_confirmation|confirmed|min:8|max:255',
|
||||
'authorizedFolders' => 'present|array',
|
||||
'role' => [
|
||||
'required',
|
||||
new EnumIsValidRule(AppUserRolesEnum::class)
|
||||
],
|
||||
'status' => 'sometimes'
|
||||
'status' => 'required|boolean'
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ class UpdateAppUserRequest extends StoreAppUserRequest
|
|||
'email:rfc,dns',
|
||||
Rule::unique('app_users', 'email')->ignore($this->route('app_user')->id),
|
||||
],
|
||||
'password' => 'nullable|min:8',
|
||||
'authorizedFolders' => 'json|required',
|
||||
'password' => 'sometimes|nullable|required_with:password_confirmation|confirmed|min:8|max:255',
|
||||
'role' => [
|
||||
'required',
|
||||
new EnumIsValidRule(AppUserRolesEnum::class)
|
||||
|
|
|
|||
46
app/Http/Requests/Bo/ImportRequest.php
Normal file
46
app/Http/Requests/Bo/ImportRequest.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests\Bo;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ImportRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return Auth::check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'import' => [
|
||||
'required',
|
||||
'file',
|
||||
'mimes:csv,txt',
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong
|
||||
'mimetypes:text/csv,text/plain,application/csv,text/comma-separated-values,text/anytext,application/octet-stream,application/txt',
|
||||
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
|
||||
function ($attribute, $value, $fail) {
|
||||
if (
|
||||
$this->import->getClientMimeType() !== 'text/csv'
|
||||
&& $this->import->getClientMimeType() !== 'application/vnd.ms-excel'
|
||||
) {
|
||||
$fail(__('Le fichier doit être d\'un mime type text/csv ou application/vnd.ms-excel'));
|
||||
}
|
||||
}
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
55
app/Imports/AppUserImport.php
Normal file
55
app/Imports/AppUserImport.php
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace App\Imports;
|
||||
|
||||
use App\Enums\AppUserRolesEnum;
|
||||
use App\Models\AppUser;
|
||||
use Illuminate\Support\Str;
|
||||
use Maatwebsite\Excel\Concerns\ToModel;
|
||||
use Maatwebsite\Excel\Concerns\WithUpserts;
|
||||
use Maatwebsite\Excel\Concerns\WithCustomCsvSettings;
|
||||
|
||||
class AppUserImport implements ToModel, WithUpserts, WithCustomCsvSettings
|
||||
{
|
||||
/**
|
||||
* @return string|array
|
||||
*/
|
||||
public function uniqueBy()
|
||||
{
|
||||
return 'email';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getCsvSettings(): array
|
||||
{
|
||||
return [
|
||||
'delimiter' => ";"
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $row
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Model|null
|
||||
*/
|
||||
public function model(array $row)
|
||||
{
|
||||
if (!isset($row[0]) || !isset($row[1]) || !isset($row[2]) || !isset($row[3])) {
|
||||
return null;
|
||||
}
|
||||
$user = new AppUser([
|
||||
'email' => $row[3],
|
||||
'lastname' => ucfirst(strtolower($row[1])),
|
||||
'firstname' => ucfirst(strtolower($row[2])),
|
||||
'password' => Str::random(10),
|
||||
'status' => 1,
|
||||
'role' => AppUserRolesEnum::user(),
|
||||
]);
|
||||
|
||||
$user->saveOrFail();
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,24 +3,27 @@
|
|||
namespace App\Models;
|
||||
|
||||
use App\Enums\AppUserRolesEnum;
|
||||
use App\Lib\Helpers\ToolboxHelper;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Kwaadpepper\Enum\Traits\CastsEnums;
|
||||
|
||||
/**
|
||||
* @property integer $id
|
||||
* @property string $lastname
|
||||
* @property string $firstname
|
||||
* @property string $email
|
||||
* @property string $password
|
||||
* @property integer $role
|
||||
* @property boolean $status
|
||||
* @property integer $order
|
||||
*/
|
||||
class AppUser extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use CastsEnums;
|
||||
|
||||
/**
|
||||
* cast enum
|
||||
* @var string[]
|
||||
*/
|
||||
protected $enumCasts = [
|
||||
'role' => AppUserRolesEnum::class
|
||||
];
|
||||
|
||||
/**
|
||||
* fillable
|
||||
* @var string[]
|
||||
|
|
@ -30,11 +33,21 @@ class AppUser extends Model
|
|||
'firstname',
|
||||
'email',
|
||||
'password',
|
||||
'authorizedFolders',
|
||||
'role',
|
||||
'status',
|
||||
'order',
|
||||
];
|
||||
|
||||
/**
|
||||
* cast enum
|
||||
* @var string[]
|
||||
*/
|
||||
protected $enumCasts = [
|
||||
'role' => AppUserRolesEnum::class
|
||||
];
|
||||
|
||||
// * EVENTS
|
||||
|
||||
/**
|
||||
* Perform any actions required after the model boots.
|
||||
*
|
||||
|
|
@ -43,16 +56,53 @@ class AppUser extends Model
|
|||
protected static function booted()
|
||||
{
|
||||
static::creating(function (self $model) {
|
||||
$model->lastname = strtoupper($model->lastname);
|
||||
$model->firstname = ucfirst(strtolower($model->firstname));
|
||||
$model->password = Hash::make($model->password);
|
||||
self::assertFieldIsUnique('email', $model->email);
|
||||
self::setOrder($model);
|
||||
$model->password = Hash::make($model->password);
|
||||
});
|
||||
static::updating(function (self $model) {
|
||||
$model->lastname = strtoupper($model->lastname);
|
||||
$model->firstname = ucfirst(strtolower($model->firstname));
|
||||
if (Hash::needsRehash($model->password)) {
|
||||
$model->password = Hash::make($model->password);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// * METHODS
|
||||
|
||||
/**
|
||||
* Asserts using validation that the field is unique.
|
||||
*
|
||||
* @param string $nameField
|
||||
* @param string $valueField
|
||||
* @param integer|null $id
|
||||
* @return void
|
||||
*/
|
||||
private static function assertFieldIsUnique(string $nameField, string $valueField, ?int $id = null)
|
||||
{
|
||||
$table = (new self())->getTable();
|
||||
ToolboxHelper::assertFieldIsUnique($table, $nameField, $valueField, $id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set order after the last element of the list.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $model
|
||||
* @return void
|
||||
*/
|
||||
private static function setOrder(Model $model): void
|
||||
{
|
||||
$model->order = \intval(self::query()->max('order')) + 1;
|
||||
}
|
||||
|
||||
// * RELATIONSHIPS
|
||||
|
||||
/**
|
||||
* MorphToMany Directories
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\MorphToMany
|
||||
*/
|
||||
public function directories()
|
||||
{
|
||||
return $this->morphToMany(Directory::class, 'taggable');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\AppUser;
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
|
|
@ -35,6 +36,8 @@ class RouteServiceProvider extends ServiceProvider
|
|||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web-bo.php'));
|
||||
});
|
||||
|
||||
Route::model('appuser', AppUser::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
"laravel/ui": "^3.4",
|
||||
"ldc/web-admin-secure-laravel": "^1.0",
|
||||
"ldc/web-status-checker-laravel": "^1.0",
|
||||
"maatwebsite/excel": "^3.1",
|
||||
"mews/purifier": "^3.3",
|
||||
"sentry/sentry-laravel": "^3.2",
|
||||
"spatie/laravel-mix-preload": "^1.3"
|
||||
|
|
@ -89,7 +90,8 @@
|
|||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true,
|
||||
"php-http/discovery": true
|
||||
},
|
||||
"gitlab-domains": [
|
||||
"lab.s-web.fr"
|
||||
|
|
|
|||
979
composer.lock
generated
979
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -167,6 +167,8 @@ return [
|
|||
* Package Service Providers...
|
||||
*/
|
||||
|
||||
Maatwebsite\Excel\ExcelServiceProvider::class,
|
||||
|
||||
/*
|
||||
* Application Service Providers...
|
||||
*/
|
||||
|
|
@ -230,7 +232,6 @@ return [
|
|||
'URL' => Illuminate\Support\Facades\URL::class,
|
||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||
'View' => Illuminate\Support\Facades\View::class,
|
||||
|
||||
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
|
||||
],
|
||||
|
||||
];
|
||||
|
|
|
|||
349
config/excel.php
Normal file
349
config/excel.php
Normal file
|
|
@ -0,0 +1,349 @@
|
|||
<?php
|
||||
|
||||
use Maatwebsite\Excel\Excel;
|
||||
|
||||
return [
|
||||
'exports' => [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Chunk size
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using FromQuery, the query is automatically chunked.
|
||||
| Here you can specify how big the chunk should be.
|
||||
|
|
||||
*/
|
||||
|
||||
'chunk_size' => 1000,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Pre-calculate formulas during export
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
'pre_calculate_formulas' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Enable strict null comparison
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When enabling strict null comparison empty cells ('') will
|
||||
| be added to the sheet.
|
||||
*/
|
||||
|
||||
'strict_null_comparison' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CSV Settings
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Configure e.g. delimiter, enclosure and line ending for CSV exports.
|
||||
|
|
||||
*/
|
||||
|
||||
'csv' => [
|
||||
'delimiter' => ',',
|
||||
'enclosure' => '"',
|
||||
'line_ending' => PHP_EOL,
|
||||
'use_bom' => false,
|
||||
'include_separator_line' => false,
|
||||
'excel_compatibility' => false,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Worksheet properties
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Configure e.g. default title, creator, subject,...
|
||||
|
|
||||
*/
|
||||
|
||||
'properties' => [
|
||||
'creator' => '',
|
||||
'lastModifiedBy' => '',
|
||||
'title' => '',
|
||||
'description' => '',
|
||||
'subject' => '',
|
||||
'keywords' => '',
|
||||
'category' => '',
|
||||
'manager' => '',
|
||||
'company' => '',
|
||||
],
|
||||
],
|
||||
|
||||
'imports' => [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Read Only
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When dealing with imports, you might only be interested in the
|
||||
| data that the sheet exists. By default we ignore all styles,
|
||||
| however if you want to do some logic based on style data
|
||||
| you can enable it by setting read_only to false.
|
||||
|
|
||||
*/
|
||||
|
||||
'read_only' => true,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Ignore Empty
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When dealing with imports, you might be interested in ignoring
|
||||
| rows that have null values or empty strings. By default rows
|
||||
| containing empty strings or empty values are not ignored but can be
|
||||
| ignored by enabling the setting ignore_empty to true.
|
||||
|
|
||||
*/
|
||||
|
||||
'ignore_empty' => false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Heading Row Formatter
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Configure the heading row formatter.
|
||||
| Available options: none|slug|custom
|
||||
|
|
||||
*/
|
||||
|
||||
'heading_row' => [
|
||||
'formatter' => 'slug',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CSV Settings
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Configure e.g. delimiter, enclosure and line ending for CSV imports.
|
||||
|
|
||||
*/
|
||||
|
||||
'csv' => [
|
||||
'delimiter' => ',',
|
||||
'enclosure' => '"',
|
||||
'escape_character' => '\\',
|
||||
'contiguous' => false,
|
||||
'input_encoding' => 'UTF-8',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Worksheet properties
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Configure e.g. default title, creator, subject,...
|
||||
|
|
||||
*/
|
||||
|
||||
'properties' => [
|
||||
'creator' => '',
|
||||
'lastModifiedBy' => '',
|
||||
'title' => '',
|
||||
'description' => '',
|
||||
'subject' => '',
|
||||
'keywords' => '',
|
||||
'category' => '',
|
||||
'manager' => '',
|
||||
'company' => '',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Extension detector
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Configure here which writer/reader type should be used when the package
|
||||
| needs to guess the correct type based on the extension alone.
|
||||
|
|
||||
*/
|
||||
|
||||
'extension_detector' => [
|
||||
'xlsx' => Excel::XLSX,
|
||||
'xlsm' => Excel::XLSX,
|
||||
'xltx' => Excel::XLSX,
|
||||
'xltm' => Excel::XLSX,
|
||||
'xls' => Excel::XLS,
|
||||
'xlt' => Excel::XLS,
|
||||
'ods' => Excel::ODS,
|
||||
'ots' => Excel::ODS,
|
||||
'slk' => Excel::SLK,
|
||||
'xml' => Excel::XML,
|
||||
'gnumeric' => Excel::GNUMERIC,
|
||||
'htm' => Excel::HTML,
|
||||
'html' => Excel::HTML,
|
||||
'csv' => Excel::CSV,
|
||||
'tsv' => Excel::TSV,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| PDF Extension
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Configure here which Pdf driver should be used by default.
|
||||
| Available options: Excel::MPDF | Excel::TCPDF | Excel::DOMPDF
|
||||
|
|
||||
*/
|
||||
|
||||
'pdf' => Excel::DOMPDF,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Value Binder
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| PhpSpreadsheet offers a way to hook into the process of a value being
|
||||
| written to a cell. In there some assumptions are made on how the
|
||||
| value should be formatted. If you want to change those defaults,
|
||||
| you can implement your own default value binder.
|
||||
|
|
||||
| Possible value binders:
|
||||
|
|
||||
| [x] Maatwebsite\Excel\DefaultValueBinder::class
|
||||
| [x] PhpOffice\PhpSpreadsheet\Cell\StringValueBinder::class
|
||||
| [x] PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder::class
|
||||
|
|
||||
*/
|
||||
|
||||
'value_binder' => [
|
||||
'default' => Maatwebsite\Excel\DefaultValueBinder::class,
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default cell caching driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By default PhpSpreadsheet keeps all cell values in memory, however when
|
||||
| dealing with large files, this might result into memory issues. If you
|
||||
| want to mitigate that, you can configure a cell caching driver here.
|
||||
| When using the illuminate driver, it will store each value in a the
|
||||
| cache store. This can slow down the process, because it needs to
|
||||
| store each value. You can use the "batch" store if you want to
|
||||
| only persist to the store when the memory limit is reached.
|
||||
|
|
||||
| Drivers: memory|illuminate|batch
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => 'memory',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Batch memory caching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When dealing with the "batch" caching driver, it will only
|
||||
| persist to the store when the memory limit is reached.
|
||||
| Here you can tweak the memory limit to your liking.
|
||||
|
|
||||
*/
|
||||
|
||||
'batch' => [
|
||||
'memory_limit' => 60000,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Illuminate cache
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "illuminate" caching driver, it will automatically use
|
||||
| your default cache store. However if you prefer to have the cell
|
||||
| cache on a separate store, you can configure the store name here.
|
||||
| You can use any store defined in your cache config. When leaving
|
||||
| at "null" it will use the default store.
|
||||
|
|
||||
*/
|
||||
|
||||
'illuminate' => [
|
||||
'store' => null,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Transaction Handler
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By default the import is wrapped in a transaction. This is useful
|
||||
| for when an import may fail and you want to retry it. With the
|
||||
| transactions, the previous import gets rolled-back.
|
||||
|
|
||||
| You can disable the transaction handler by setting this to null.
|
||||
| Or you can choose a custom made transaction handler here.
|
||||
|
|
||||
| Supported handlers: null|db
|
||||
|
|
||||
*/
|
||||
|
||||
'transactions' => [
|
||||
'handler' => 'db',
|
||||
],
|
||||
|
||||
'temporary_files' => [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Local Temporary Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When exporting and importing files, we use a temporary file, before
|
||||
| storing reading or downloading. Here you can customize that path.
|
||||
|
|
||||
*/
|
||||
|
||||
'local_path' => storage_path('framework/laravel-excel'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Remote Temporary Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When dealing with a multi server setup with queues in which you
|
||||
| cannot rely on having a shared local temporary path, you might
|
||||
| want to store the temporary file on a shared disk. During the
|
||||
| queue executing, we'll retrieve the temporary file from that
|
||||
| location instead. When left to null, it will always use
|
||||
| the local path. This setting only has effect when using
|
||||
| in conjunction with queued imports and exports.
|
||||
|
|
||||
*/
|
||||
|
||||
'remote_disk' => null,
|
||||
'remote_prefix' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Force Resync
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When dealing with a multi server setup as above, it's possible
|
||||
| for the clean up that occurs after entire queue has been run to only
|
||||
| cleanup the server that the last AfterImportJob runs on. The rest of the server
|
||||
| would still have the local temporary file stored on it. In this case your
|
||||
| local storage limits can be exceeded and future imports won't be processed.
|
||||
| To mitigate this you can set this config value to be true, so that after every
|
||||
| queued chunk is processed the local temporary file is deleted on the server that
|
||||
| processed it.
|
||||
|
|
||||
*/
|
||||
|
||||
'force_resync_remote' => null,
|
||||
],
|
||||
];
|
||||
37
database/factories/AppUserFactory.php
Normal file
37
database/factories/AppUserFactory.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\AppUserRolesEnum;
|
||||
use App\Models\AppUser;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<\App\Models\AppUser>
|
||||
*/
|
||||
class AppUserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = AppUser::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'firstname' => $this->faker->unique()->firstname(),
|
||||
'lastname' => $this->faker->unique()->lastName(),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi',
|
||||
'status' => $this->faker->boolean(75),
|
||||
'role' => collect(AppUserRolesEnum::toArray())->random(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UpdateAppUsersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('app_users', function (Blueprint $table) {
|
||||
$table->integer('order')->after('role')->comment('Ordonnance des utilisateurs de l\'applications.');
|
||||
$table->dropColumn('authorizedFolders');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('app_users', function (Blueprint $table) {
|
||||
$table->dropColumn('order');
|
||||
$table->text('authorizedFolders')->nullable();
|
||||
});
|
||||
}
|
||||
}
|
||||
24
database/seeders/AppUserSeeder.php
Normal file
24
database/seeders/AppUserSeeder.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\AppUser;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class AppUserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$i = 1;
|
||||
AppUser::factory(15)->make()->each(function (AppUser $directory) use (&$i) {
|
||||
$directory->order = $i;
|
||||
$directory->saveOrFail();
|
||||
$i = $i + 1;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ class DatabaseSeeder extends Seeder
|
|||
public function run()
|
||||
{
|
||||
$this->call([
|
||||
AppUserSeeder::class,
|
||||
DirectorySeeder::class,
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\AppUser;
|
||||
use App\Models\Directory;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
|
|
@ -20,5 +21,13 @@ class DirectorySeeder extends Seeder
|
|||
$directory->saveOrFail();
|
||||
$i = $i + 1;
|
||||
});
|
||||
|
||||
// Seeder for directory_authorizations table.
|
||||
$directories = Directory::query()->where('needAuthorization', true)->get();
|
||||
AppUser::each(function (AppUser $model) use ($directories) {
|
||||
$offset = rand(1, 15);
|
||||
$length = rand(1, 2);
|
||||
$model->directories()->saveMany($directories->slice($offset, $length));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
return [
|
||||
'classes' => [
|
||||
'dashboard' => 'Dashboard',
|
||||
'app_users' => 'Application\'s users',
|
||||
'directories' => 'Directories',
|
||||
'users' => 'Users'
|
||||
]
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
return [
|
||||
'classes' => [
|
||||
'dashboard' => 'Tableau de bord',
|
||||
'app_users' => 'Application utilisateurs',
|
||||
'directories' => 'Dossiers',
|
||||
'users' => 'Utilisateurs'
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
.need-word-counter {
|
||||
border-radius: 0 0 0.375rem 0.375rem;
|
||||
|
||||
&-password {
|
||||
border-radius: 0 0 0 0.375rem !important;
|
||||
|
||||
&-btn {
|
||||
border-radius: 0 0 0.375rem !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.table {
|
||||
|
|
|
|||
124
resources/ts/bo/components/PasswordVisibility.vue
Normal file
124
resources/ts/bo/components/PasswordVisibility.vue
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
<template>
|
||||
<div :class="`password-visibility-${inputId} h-100`">
|
||||
<span
|
||||
v-if="visible"
|
||||
class="text-bg-primary reveal d-flex justify-content-center align-items-center h-100"
|
||||
@click.prevent="toggleVisibility()"
|
||||
type="button"
|
||||
:title="__('Cacher le mot de passe')"
|
||||
data-bs="tooltip"
|
||||
>
|
||||
<FontAwesomeIcon
|
||||
icon="fas fa-eye-slash"
|
||||
:aria-hidden="true"
|
||||
/>
|
||||
</span>
|
||||
<span
|
||||
v-else
|
||||
class="text-bg-primary reveal d-flex justify-content-center align-items-center h-100"
|
||||
@click.prevent="toggleVisibility()"
|
||||
type="button"
|
||||
:title="__('Dévoiler le mot de passe')"
|
||||
data-bs="tooltip"
|
||||
>
|
||||
<FontAwesomeIcon
|
||||
icon="fas fa-eye"
|
||||
:aria-hidden="true"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
||||
import { Tooltip } from "bootstrap";
|
||||
import trans from "./../../modules/trans";
|
||||
|
||||
export default defineComponent({
|
||||
name: "PasswordVisibility",
|
||||
mixins: [trans],
|
||||
components: { FontAwesomeIcon },
|
||||
data(): {
|
||||
inputId: string;
|
||||
input: HTMLInputElement;
|
||||
visible: boolean;
|
||||
tooltipList: HTMLButtonElement[];
|
||||
} {
|
||||
return {
|
||||
inputId: "",
|
||||
input: document.createElement("input"),
|
||||
visible: false,
|
||||
tooltipList: [],
|
||||
};
|
||||
},
|
||||
computed: {},
|
||||
mounted() {
|
||||
const json = String(this.$attrs.json ?? "{}"),
|
||||
data = JSON.parse(json);
|
||||
this.inputId = data.inputId;
|
||||
this.input = document.getElementById(this.inputId) as HTMLInputElement;
|
||||
if (!this.input) {
|
||||
throw new Error(`Cannot find input id '${this.inputId}'`);
|
||||
}
|
||||
if (this.input.tagName !== "INPUT") {
|
||||
throw new Error(`id '${this.inputId}' is not an input`);
|
||||
}
|
||||
if ((this.input as HTMLInputElement).type !== "password") {
|
||||
throw new Error(`id '${this.inputId}' is not an input password`);
|
||||
}
|
||||
this.input = this.input as HTMLInputElement;
|
||||
this.$nextTick(() => {
|
||||
this.updateBootstrapTooltip();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* Update password status (visible, hidden).
|
||||
*/
|
||||
toggleVisibility(): void {
|
||||
if (this.input.type === "password") {
|
||||
this.input.type = "text";
|
||||
this.visible = true;
|
||||
} else {
|
||||
this.input.type = "password";
|
||||
this.visible = false;
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.updateBootstrapTooltip();
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Update Bootstrap tooltips.
|
||||
*/
|
||||
updateBootstrapTooltip() {
|
||||
let newTooltipList = [].slice.call(
|
||||
document.querySelectorAll(
|
||||
".password-visibility-" + this.inputId + " [data-bs=\"tooltip\"]"
|
||||
)
|
||||
) as HTMLButtonElement[];
|
||||
let tmp = newTooltipList.filter((x) => !this.tooltipList.includes(x));
|
||||
tmp.map((tooltip) => {
|
||||
return new Tooltip(tooltip);
|
||||
});
|
||||
this.closeBootstrapTooltip();
|
||||
this.tooltipList = newTooltipList;
|
||||
},
|
||||
/**
|
||||
* Close all Bootstrap tooltips.
|
||||
*/
|
||||
closeBootstrapTooltip() {
|
||||
this.tooltipList.forEach((tooltip) => {
|
||||
tooltip.blur();
|
||||
Tooltip.getInstance(tooltip)?.hide();
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.reveal {
|
||||
width: 52px;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -9,11 +9,11 @@
|
|||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link @if(request()->routeIs('bo.app-users')) active @endif"
|
||||
href="{{ route('bo.app-users.index') }}"
|
||||
title="{{ __('Utilisateurs') }}"
|
||||
<a class="nav-link @if(request()->routeIs('bo.app-users.*')) active @endif"
|
||||
href="{{ route('bo.app-users.index') }}?rst=1"
|
||||
title="{{ __('Liste des :model', ['model' => __('models.classes.users')]) }}"
|
||||
data-bs-toggle="tooltip">
|
||||
{{ __('Utilisateurs') }}
|
||||
{{ __(':model', ['model' => __('models.classes.users')]) }}
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
@extends('bo.layout')
|
||||
|
||||
@section('title', sprintf('%s - %s', __('models.classes.app_users'), Str::ucfirst(__('création'))))
|
||||
@section('title', sprintf('%s - %s', Str::singular(__('models.classes.app_users')), Str::ucfirst(__('création'))))
|
||||
@section('description', __('Creation of a new app users.'))
|
||||
|
||||
@section('breadcrumb', request()->route()->getName())
|
||||
|
||||
|
|
@ -8,24 +9,41 @@
|
|||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="row">
|
||||
<h1 class="col h4">
|
||||
<a href="{{ route('bo.app-users.index') }}" class="text-decoration-none btn btn-sm btn-primary" role="button" aria-roledescription="{{ __('Revenir en arrière') }}"><i class="fa-solid fa-arrow-left-long"></i></a>
|
||||
<span> {{ __('models.classes.app_users') }} {{ __('création') }}</span>
|
||||
</h1>
|
||||
<div class="col">
|
||||
<h1 class="text-center text-md-start h2">
|
||||
<a href="{{ route('bo.app-users.index') }}"
|
||||
class="btn btn-primary text-decoration-none m-0"
|
||||
data-bs="tooltip"
|
||||
data-bs-placement="top"
|
||||
title="{{ __('Return to the :model list', ['model' => __('models.classes.app_users')]) }}"
|
||||
data-bs-toggle="tooltip">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
<span class="fw-bold">{{ Str::singular(__('models.classes.app_users')) }}</span> <small class="text-muted">{{ Str::ucfirst(__('création')) }}</small>
|
||||
</h1>
|
||||
</div>
|
||||
<div class="col-12 col-md-4 d-flex justify-content-center justify-content-md-end align-items-center">
|
||||
<button id="formSubmitClone" class="btn btn-primary pull-end">{{ __('Save') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ route('bo.app-users.store') }}" method="POST">
|
||||
<div class="card-body bg-light">
|
||||
<form action="{{ route('bo.app-users.store') }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
@include('bo.pages.app-users.form')
|
||||
<div class="row">
|
||||
<div class="col text-center text-md-end">
|
||||
<button type="submit" class="btn btn-primary" title="{{ __('Enregister :model', [
|
||||
'model' => Str::singular(__('models.classes.app_users')),
|
||||
]) }}" data-bs-toggle="tooltip">{{ __('Enregister') }}</button>
|
||||
<div class="col text-center">
|
||||
<button id="formSubmit"
|
||||
type="submit"
|
||||
class="btn btn-primary"
|
||||
title="{{ __('Save :model', ['model' => Str::singular(__('models.classes.app_users'))]) }}"
|
||||
data-bs-toggle="tooltip">
|
||||
{{ __('Save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
@extends('bo.layout', ['brParam' => $app_userModel])
|
||||
|
||||
@section('title', sprintf('%s - %s %s', __('models.classes.app_users'), Str::ucfirst(__('édition')), $app_userModel->lastname))
|
||||
@section('title', sprintf('%s - %s %s', Str::singular(__('models.classes.app_users')), Str::ucfirst(__('édition')), $app_userModel->lastname))
|
||||
@section('description', $app_userModel->seo_description)
|
||||
|
||||
@section('breadcrumb', request()->route()->getName())
|
||||
|
||||
|
|
@ -9,47 +10,48 @@
|
|||
<div class="card-header">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h1 class="col h4">
|
||||
<a href="{{ route('bo.app-users.index') }}" class="text-decoration-none btn btn-sm btn-primary" role="button" aria-roledescription="{{ __('Revenir en arrière') }}">
|
||||
<i class="fa-solid fa-arrow-left-long"></i>
|
||||
<h1 class="text-center text-md-start h2">
|
||||
<a href="{{ route('bo.app-users.index') }}"
|
||||
class="btn btn-primary text-decoration-none m-0"
|
||||
data-bs="tooltip"
|
||||
data-bs-placement="top"
|
||||
title="{{ __('Retourner sur la liste des :model', ['model' => __('models.classes.app_users')]) }}"
|
||||
data-bs-toggle="tooltip">
|
||||
<i class="fa-solid fa-arrow-left"></i>
|
||||
</a>
|
||||
<span> {{ __('models.classes.app_users') }} {{ __('édition') }}</span>
|
||||
<span class="fw-bold">{{ Str::singular(__('models.classes.app_users')) }}</span> <small class="text-muted">{{ Str::ucfirst(__('édition')) }}</small>
|
||||
</h1>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<div class="col-12 col-md-4 d-flex justify-content-center justify-content-md-end align-items-center">
|
||||
<form action="{{ route('bo.app-users.destroy', $app_userModel->id) }}" method="POST" class="d-inline confirmDeleteJS">
|
||||
@method('DELETE')
|
||||
@csrf
|
||||
<div class="btn-group" role="group">
|
||||
<button class="btn btn-danger" title="{{ __('Supprimer :model', [
|
||||
'model' => Str::singular(__('models.classes.app_users')),
|
||||
]) }}" data-bs-toggle="tooltip">
|
||||
<button class="btn btn-danger"
|
||||
title="{{ __('Supprimer :model', ['model' => Str::singular(__('models.classes.app_users'))]) }}"
|
||||
data-bs-toggle="tooltip">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
<a id="formSubmitClone" class="btn btn-primary" role="button" title="{{ __('Enregistrer :model', [
|
||||
'model' => Str::singular(__('models.classes.app_users')),
|
||||
]) }}" data-bs-toggle="tooltip">{{ __('Enregistrer') }}</a>
|
||||
<button id="formSubmitClone" class="btn btn-primary pull-end">{{ __('Save') }}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form id="formSubmit" action="{{ route('bo.app-users.update', $app_userModel->id) }}" method="POST">
|
||||
<div class="card-body bg-light">
|
||||
<form action="{{ route('bo.app-users.update', $app_userModel->id) }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
@include('bo.pages.app-users.form', compact('app_userModel'))
|
||||
|
||||
<div class="row my-3">
|
||||
<div class="col text-center">
|
||||
<strong>* {{ __('champs obligatoires') }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
@include('bo.pages.app-users.form', ['model' => $app_userModel])
|
||||
<div class="row">
|
||||
<div class="col text-center text-md-end">
|
||||
<button type="submit" class="btn btn-primary" title="{{ __('Enregister :model', [
|
||||
'model' => Str::singular(__('models.classes.app_users')),
|
||||
]) }}" data-bs-toggle="tooltip">{{ __('Enregister') }}</button>
|
||||
<div class="col text-center">
|
||||
<button id="formSubmit"
|
||||
type="submit"
|
||||
class="btn btn-primary"
|
||||
title="{{ __('Save :model', ['model' => Str::singular(__('models.classes.app_users'))]) }}"
|
||||
data-bs-toggle="tooltip">
|
||||
{{ __('Save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -1,137 +1,161 @@
|
|||
<div class="row">
|
||||
<div class="col-12 col-md-6">
|
||||
{{-- LASTNAME --}}
|
||||
<fieldset class="border p-3 mb-3">
|
||||
<legend>{{ __('Nom *') }}</legend>
|
||||
{{-- LASTNAME --}}
|
||||
<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('bo.partials.inputs.varchar', [
|
||||
'id' => 'app_userSurname',
|
||||
'hasWordCounter' => false,
|
||||
'name' => 'lastname',
|
||||
'required' => true,
|
||||
'model' => $app_userModel ?? null,
|
||||
'helper' => __('Nom (3 caractères minimum, 255 maximum).'),
|
||||
'placeholder' => "Dupont"
|
||||
'id' => 'app_userSurname',
|
||||
'label' => __('Nom de l\':model', ['model' => Str::singular(__('models.classes.users'))]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'lastname',
|
||||
'required' => true,
|
||||
'model' => $app_userModel ?? null,
|
||||
'helper' => __('Doit posséder 3 caractères minimum, 255 maximum.'),
|
||||
'placeholder' => "Un beau nom"
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="col-12 col-md-6">
|
||||
{{-- FIRSTNAME --}}
|
||||
<fieldset class="border p-3 mb-3">
|
||||
<legend>{{ __('Prénom *') }}</legend>
|
||||
{{-- FIRSTNAME --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<legend>{{ __('Prénom') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
@include('bo.partials.inputs.varchar', [
|
||||
'id' => 'app_userFirstname',
|
||||
'hasWordCounter' => false,
|
||||
'name' => 'firstname',
|
||||
'required' => true,
|
||||
'model' => $app_userModel ?? null,
|
||||
'helper' => __('Prénom (3 caractères minimum, 255 maximum).'),
|
||||
'placeholder' => "Thomas"
|
||||
'id' => 'app_userFirstname',
|
||||
'label' => __('Prénom de l\':model', ['model' => Str::singular(__('models.classes.users'))]),
|
||||
'hasWordCounter' => true,
|
||||
'name' => 'firstname',
|
||||
'required' => true,
|
||||
'model' => $app_userModel ?? null,
|
||||
'helper' => __('Doit posséder 3 caractères minimum, 255 maximum.'),
|
||||
'placeholder' => "Un beau prénom"
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-12">
|
||||
{{-- EMAIL --}}
|
||||
<fieldset class="border p-3 mb-3">
|
||||
<legend>{{ __('Email *') }}</legend>
|
||||
{{-- EMAIL --}}
|
||||
<div class="col-12 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<legend>{{ __('Email') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
@include('bo.partials.inputs.varchar-email', [
|
||||
'id' => 'app_userEmail',
|
||||
'name' => 'email',
|
||||
'required' => true,
|
||||
'model' => $app_userModel ?? null,
|
||||
'helper' => __('Email.'),
|
||||
'placeholder' => "test@test.test"
|
||||
'id' => 'app_userEmail',
|
||||
'label' => __('Email de l\':model', ['model' => Str::singular(__('models.classes.users'))]),
|
||||
'name' => 'email',
|
||||
'hasWordCounter' => true,
|
||||
'required' => true,
|
||||
'model' => $app_userModel ?? null,
|
||||
'helper' => __('Tapez votre e-mail en respectant la convention d\'appellation des e-mails (ex: firstname.lastname@yourdomain.com).'),
|
||||
'placeholder' => "firstname.lastname@yourdomain.com"
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-6">
|
||||
{{-- Password --}}
|
||||
<fieldset class="border p-3 mb-3">
|
||||
{{-- PASSWORD --}}
|
||||
<div class="col-12 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<legend>{{ __('Mot de passe') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
@include('bo.partials.inputs.varchar-password', [
|
||||
'id' => 'app_userPassword',
|
||||
'name' => 'password',
|
||||
'required' => false,
|
||||
'model' => null,
|
||||
'helper' => __('Mot de passe (8 caractères min.).'),
|
||||
'placeholder' => ''
|
||||
'id' => 'app_userPassword',
|
||||
'label' => __('Mot de passe de l\':model', ['model' => Str::singular(__('models.classes.users'))]),
|
||||
'name' => 'password',
|
||||
'hasWordCounter' => true,
|
||||
'required' => false,
|
||||
'model' => null,
|
||||
'helper' => __('Mot de passe (8 caractères minimum).'),
|
||||
])
|
||||
</div>
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
@include('bo.partials.inputs.varchar-password', [
|
||||
'id' => 'app_userPassword_confirmation',
|
||||
'label' => __('Confirmation du mot de passe de l\':model', ['model' => Str::singular(__('models.classes.users'))]),
|
||||
'name' => 'password_confirmation',
|
||||
'hasWordCounter' => true,
|
||||
'required' => false,
|
||||
'model' => null,
|
||||
'helper' => __('Doit correspondre au mot de passe précédemment saisi.'),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="col-12 col-md-6">
|
||||
{{-- STATUS --}}
|
||||
<fieldset class="border p-3 mb-3">
|
||||
<legend>{{ __('Statut') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
@include('bo.partials.inputs.tinyint-boolean', [
|
||||
'id' => 'app_userStatus',
|
||||
'name' => 'status',
|
||||
'label' => __('Statut'),
|
||||
'model' => $app_userModel ?? null,
|
||||
'helper' => __('L\'utilisateur est-il activé ?')
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-6">
|
||||
{{-- ROLE --}}
|
||||
<fieldset class="border p-3 mb-3">
|
||||
<legend>{{ __('Rôle *') }}</legend>
|
||||
{{-- ROLE --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<legend>{{ __('Rôle') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
@include('bo.partials.inputs.tinyint-enum', [
|
||||
'id' => 'app_userRole',
|
||||
'name' => 'role',
|
||||
'label' => __('Rôle'),
|
||||
'model' => $app_userModel ?? null,
|
||||
'helper' => __('Rôle de l\'utilisateur'),
|
||||
'enumClass' =>\App\Enums\AppUserRolesEnum::class,
|
||||
'required' => true
|
||||
'id' => 'app_userRole',
|
||||
'label' => __('Rôle de l\':model', ['model' => Str::singular(__('models.classes.users'))]),
|
||||
'name' => 'role',
|
||||
'model' => $app_userModel ?? null,
|
||||
'required' => true,
|
||||
'associatedDatas' => \App\Enums\AppUserRolesEnum::toArray(),
|
||||
'helper' => __('Rôle de l\'utilisateur.'),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="col-12 col-md-6">
|
||||
{{-- AUTHORIZED FOLDERS --}}
|
||||
<fieldset class="border p-3 mb-3">
|
||||
<legend>{{ __('Dossiers autorisés *') }}</legend>
|
||||
{{-- STATUS --}}
|
||||
<div class="col-12 col-md-6 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<legend>{{ __('Visibility') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@include('bo.partials.inputs.boolean-switch', [
|
||||
'id' => 'app_userStatus',
|
||||
'name' => 'status',
|
||||
'label' => __('L\'utilisateur est-il activé ?'),
|
||||
'model' => $app_userModel ?? null,
|
||||
'helper' => __('Activation de l\'utilisateur de l\'application.')
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{-- AUTHORIZED FOLDERS --}}
|
||||
<div class="col-12 mb-3">
|
||||
<fieldset class="border h-100 bg-white p-3">
|
||||
<legend>{{ __('Dossiers') }}</legend>
|
||||
<div class="row">
|
||||
<div class="col-12 mb-3">
|
||||
@include('bo.partials.inputs.text', [
|
||||
'id' => 'app_userAuthorizedFolders',
|
||||
'name' => 'authorizedFolders',
|
||||
'label' => __('Dossiers autorisés'),
|
||||
'model' => $app_userModel ?? null,
|
||||
'helper' => __('Dossiers autorisés de l\'utilisateur'),
|
||||
'required' => true,
|
||||
'hasWordCounter' => false // FIXME : NOK si true
|
||||
@include('bo.partials.inputs.pivot-belongs-to-many', [
|
||||
'id' => 'app_userAuthorizedFolders',
|
||||
'name' => 'directories',
|
||||
'label' => __('Dossiers autorisés'),
|
||||
'model' => $app_userModel ?? null,
|
||||
'itemsList' => $directories,
|
||||
'placeholder' => __('Recherchez un dossier'),
|
||||
'helper' => __('Dossiers autorisés de l\'utilisateur.'),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script nonce="{{ $nonce }}">
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// Submit button clone.
|
||||
const submit = document.getElementById('formSubmit')
|
||||
submitClone = document.getElementById('formSubmitClone');
|
||||
submitClone.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
submit.click('');
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
|
|
|||
91
resources/views/bo/pages/app-users/index-list.blade.php
Normal file
91
resources/views/bo/pages/app-users/index-list.blade.php
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<div class="table-responsive">
|
||||
<table class="table fix-action">
|
||||
<thead>
|
||||
@php
|
||||
$rst = !is_null(request()->rst);
|
||||
$routeName = request()->route()->getName();
|
||||
$noOrder = Session::get("$routeName.sort_col") !== 'order' and (Session::has("$routeName.sort_col") or Session::has("$routeName.sort_way"));
|
||||
$noOrder = Session::get("$routeName.sort_col") !== '' and (Session::has("$routeName.sort_col") or Session::has("$routeName.sort_way"));
|
||||
$cols = ['lastname' => __('Nom'), 'firstname' => __('Prénom'), 'email' => __('Email'), 'order' => __('Order')];
|
||||
@endphp
|
||||
@include('bo.modules.table-col-sorter', [
|
||||
'cols' => $cols,
|
||||
'mobileHide' => [],
|
||||
])
|
||||
</thead>
|
||||
<tbody>
|
||||
@if ($app_users->count())
|
||||
@foreach ($app_users as $app_usersModel)
|
||||
<tr>
|
||||
<td>
|
||||
<span>{{ $app_usersModel->lastname }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span>{{ $app_usersModel->firstname }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span>{{ $app_usersModel->email }}</span>
|
||||
</td>
|
||||
@if(!$noOrder or $rst)
|
||||
<td class="d-flex">
|
||||
<form action="{{ route('bo.app-users.change-order', ['appuser' => $app_usersModel, 'action' => 'up']) }}"
|
||||
method="POST"
|
||||
class="text-center @if($loop->first and $app_users->onFirstPage()) invisible @endif">
|
||||
@csrf
|
||||
<button type="submit"
|
||||
class="btn btn-sm btn-outline-dark @if(($loop->first and $app_users->onFirstPage())) disabled @endif"
|
||||
title="{{ __('Change the order of appearance upwards') }}"
|
||||
data-bs-toggle="tooltip">
|
||||
<i class="fas fa-arrow-up"></i>
|
||||
</button>
|
||||
</form>
|
||||
<form action="{{ route('bo.app-users.change-order', ['appuser' => $app_usersModel, 'action' => 'down']) }}"
|
||||
method="POST"
|
||||
class="text-center @if($loop->last and $app_users->currentPage() === $app_users->lastPage()) invisible @endif">
|
||||
@csrf
|
||||
<button type="submit"
|
||||
class="btn btn-sm btn-outline-dark ms-1 @if($loop->last and $app_users->currentPage() === $app_users->lastPage()) disabled @endif"
|
||||
title="{{ __('Change the order of appearance downwards') }}"
|
||||
data-bs-toggle="tooltip">
|
||||
<i class="fas fa-arrow-down"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
@endif
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<form action="{{ route('bo.app-users.destroy', $app_usersModel->id) }}" method="POST" class="d-inline confirmDeleteJS">
|
||||
@method('DELETE')
|
||||
@csrf
|
||||
<div class="btn-group" role="group">
|
||||
<a id="formSubmitClone"
|
||||
href="{{ route('bo.app-users.edit', $app_usersModel) }}"
|
||||
class="btn btn-sm btn-primary"
|
||||
role="button"
|
||||
title="{{ __('Modifier l\':model', ['model' => Str::singular(__('models.classes.users'))]) }}"
|
||||
data-bs-toggle="tooltip">
|
||||
<i class="fa-solid fa-pencil"></i>
|
||||
</a>
|
||||
<button class="btn btn-sm btn-danger"
|
||||
title="{{ __('Supprimer l\':model', ['model' => Str::singular(__('models.classes.users'))]) }}"
|
||||
data-bs-toggle="tooltip">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@else
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">
|
||||
<span class="h3">
|
||||
{{ __('Aucun résultat pour les :models', ['models' => __('models.classes.users')]) }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
@ -9,19 +9,34 @@
|
|||
<div class="card-header">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h1 class="h3">{{ __('models.classes.app_users') }} {{ Str::ucfirst(__('liste')) }}</h1>
|
||||
<h1 class="col h2">
|
||||
<span class="fw-bold">{{ __('models.classes.app_users') }}</span> <small class="text-muted">{{ Str::ucfirst(__('liste')) }}</small>
|
||||
</h1>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="input-group justify-content-end">
|
||||
<a href="{{ route('bo.app-users.create') }}" class="btn btn-primary" title="{{ __('Ajouter un :model', [
|
||||
'model' => Str::singular(__('models.classes.app_users')),
|
||||
]) }}" data-bs-toggle="tooltip"><i class="fa-solid fa-plus"></i></a>
|
||||
<div class="col d-flex align-items-center">
|
||||
<form class="input-group"
|
||||
action="{{ route('bo.app-users.import') }}"
|
||||
method="POST"
|
||||
enctype="multipart/form-data">
|
||||
<input class="form-control" type="file" name="import" accept="text/csv,.csv" required>
|
||||
@csrf
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{{ __('Importer') }}
|
||||
</button>
|
||||
</form>
|
||||
<div class="ms-1 justify-content-end">
|
||||
<a href="{{ route('bo.app-users.create') }}"
|
||||
class="btn btn-primary"
|
||||
title="{{ __('Créer un(e) :model', ['model' => Str::singular(__('models.classes.app_users'))]) }}"
|
||||
data-bs-toggle="tooltip">
|
||||
<i class="fa-solid fa-plus"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@include('modules.searchBar')
|
||||
@include('bo.modules.search-bar')
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-12 col-md-6 p-0 p-md-3">
|
||||
{{ $app_users->withQueryString()->onEachSide(1)->links() }}
|
||||
|
|
@ -29,7 +44,7 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
@include('bo.pages.app-users.indexList')
|
||||
@include('bo.pages.app-users.index-list')
|
||||
</div>
|
||||
</div>
|
||||
<div class="row justify-content-center">
|
||||
|
|
@ -39,4 +54,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -1,51 +0,0 @@
|
|||
<div class="table-responsive">
|
||||
<table class="table fix-action">
|
||||
<thead>
|
||||
@php
|
||||
$cols = [
|
||||
'lastname' => __('Nom'),
|
||||
'firstname' => __('Prénom'),
|
||||
'email' => __('Email')];
|
||||
$routeName = request()->route()->getName();
|
||||
$rst = !is_null(request()->rst) || !Session::has("$routeName.sorted");
|
||||
$noOrder = Session::get("$routeName.sort_col") !== 'order' and (Session::has("$routeName.sort_col") or Session::has("$routeName.sort_way"));
|
||||
$noOrder = Session::get("$routeName.sort_col") !== '' and (Session::has("$routeName.sort_col") or Session::has("$routeName.sort_way"));
|
||||
@endphp
|
||||
@include('modules.tableColSorter', [
|
||||
'cols' => $cols,
|
||||
'mobileHide' => [],
|
||||
])
|
||||
</thead>
|
||||
<tbody>
|
||||
@if ($app_users->count())
|
||||
@foreach ($app_users as $app_usersModel)
|
||||
<tr>
|
||||
<td>
|
||||
<span>{{ $app_usersModel->lastname }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span>{{ $app_usersModel->firstname }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<span>{{ $app_usersModel->email }}</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('bo.app-users.edit', $app_usersModel) }}" title="{{ __('Modifier :model', [
|
||||
'model' => Str::singular(__('models.classes.app_users')),
|
||||
]) }}" data-bs-toggle="tooltip"><i class="fa-solid fa-pencil"></i></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@else
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">
|
||||
<span class="h3">{{ __('Aucun résultat pour les :models', ['models' => __('models.classes.app_users')]) }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
|
@ -21,7 +21,12 @@ Route::prefix('bo')->name('bo.')->middleware(['admin-secure', 'throttle:credenti
|
|||
Route::middleware('auth:backend')->group(function () {
|
||||
Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
|
||||
|
||||
// * APP_USERS
|
||||
Route::resource('app-users', AppUserController::class)->except('show');
|
||||
Route::put('/app-users/create/new', [AppUserController::class, 'store'])->name('app-users.store');
|
||||
Route::post('/app-users/{appuser}/change-order', [AppUserController::class, 'changeOrder'])
|
||||
->name('app-users.change-order');
|
||||
Route::post('/app-users/import', [AppUserController::class, 'import'])->name('app-users.import');
|
||||
|
||||
// * DIRECTORIES
|
||||
Route::resource('directories', DirectoriesController::class)->except('show');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue