diff --git a/app/Console/Commands/UserCreate.php b/app/Console/Commands/UserCreate.php
index d9cee85..bafeb10 100644
--- a/app/Console/Commands/UserCreate.php
+++ b/app/Console/Commands/UserCreate.php
@@ -173,12 +173,12 @@ class UserCreate extends Command
$tmp = $this->choice(
'Select his role',
[
- RoleEnum::conceptor->name,
- RoleEnum::admin->name,
- RoleEnum::visitor->name,
- RoleEnum::marketing->name,
+ Str::ucFirst(RoleEnum::conceptor->label()),
+ Str::ucFirst(RoleEnum::admin->label()),
+ Str::ucFirst(RoleEnum::visitor->label()),
+ Str::ucFirst(RoleEnum::marketing->label())
],
- RoleEnum::visitor->name,
+ Str::ucFirst(RoleEnum::marketing->label()),
);
if ($tmp === Str::ucFirst(RoleEnum::conceptor->label())) {
$tmp = RoleEnum::conceptor;
@@ -189,7 +189,7 @@ class UserCreate extends Command
if ($tmp === Str::ucFirst(RoleEnum::visitor->label())) {
$tmp = RoleEnum::visitor;
}
- if ($tmp === RoleEnum::marketing->name) {
+ if ($tmp === Str::ucFirst(RoleEnum::marketing->label())) {
$tmp = RoleEnum::marketing;
}
$validator = Validator::make(['role' => $tmp], [
diff --git a/app/Enums/Claims/ClaimMessageType.php b/app/Enums/Claims/ClaimMessageType.php
index 5c2aef9..3b2e965 100644
--- a/app/Enums/Claims/ClaimMessageType.php
+++ b/app/Enums/Claims/ClaimMessageType.php
@@ -8,14 +8,14 @@ enum ClaimMessageType: int
{
use BaseEnum;
- case auto = 1;
- case human = 2;
+ case system = 1;
+ case human = 2;
/**
* Optionnal labels definition
*/
private const LABELS = [
- self::auto->name => 'Automatique',
- self::human->name => 'Humain',
+ self::system->name => 'Système',
+ self::human->name => 'Humain',
];
}
diff --git a/app/Enums/Claims/ClaimResponseType.php b/app/Enums/Claims/ClaimResponseType.php
new file mode 100644
index 0000000..c8575eb
--- /dev/null
+++ b/app/Enums/Claims/ClaimResponseType.php
@@ -0,0 +1,51 @@
+name => 'Non défini',
+ self::manual->name => 'Manuelle',
+ self::mail->name => 'Courrier',
+ self::email->name => 'E-mail',
+ self::phone->name => 'Téléphone',
+ self::other->name => 'Autre',
+ ];
+
+ /**
+ * Optionnal labels definition.
+ */
+ private const COLORS = [
+ self::none->name => '#b8b8b8',
+ self::manual->name => '#a7a7a7',
+ self::mail->name => '#757575',
+ self::email->name => '#5e5e5e',
+ self::phone->name => '#414141',
+ self::other->name => '#2b2b2b',
+ ];
+
+ /**
+ * Get Class.
+ *
+ * @return string
+ */
+ public function color(): string
+ {
+ return self::COLORS[$this->name];
+ }
+}
diff --git a/app/Enums/Claims/ClaimStatus.php b/app/Enums/Claims/ClaimStatus.php
index 068a16d..29ca37b 100644
--- a/app/Enums/Claims/ClaimStatus.php
+++ b/app/Enums/Claims/ClaimStatus.php
@@ -9,17 +9,37 @@ enum ClaimStatus: int
use BaseEnum;
case untreated = 1;
- case treated = 2;
- case sentDigital = 3;
- case sentMarketing = 4;
+ case sentDigital = 2;
+ case sentMarketing = 3;
+ case treated = 4;
/**
* Optionnal labels definition
*/
private const LABELS = [
self::untreated->name => 'Non traitée',
- self::treated->name => 'Traitée',
self::sentDigital->name => 'Transférée au service Digital',
self::sentMarketing->name => 'Retournée au Marketing',
+ self::treated->name => 'Traitée',
];
+
+ /**
+ * Optionnal labels definition.
+ */
+ private const COLORS = [
+ self::untreated->name => '#5a5a5a',
+ self::sentDigital->name => '#0033c0',
+ self::sentMarketing->name => '#69077c',
+ self::treated->name => '#188618',
+ ];
+
+ /**
+ * Get Class.
+ *
+ * @return string
+ */
+ public function color(): string
+ {
+ return self::COLORS[$this->name];
+ }
}
diff --git a/app/Enums/Claims/ClaimType.php b/app/Enums/Claims/ClaimType.php
index c44bd65..bab2dca 100644
--- a/app/Enums/Claims/ClaimType.php
+++ b/app/Enums/Claims/ClaimType.php
@@ -20,4 +20,23 @@ enum ClaimType: int
self::br->name => 'BR',
self::rgpd->name => 'RGPD',
];
+
+ /**
+ * Optionnal labels definition.
+ */
+ private const COLORS = [
+ self::classic->name => '#08818a',
+ self::br->name => '#9021f8',
+ self::rgpd->name => '#c2237a',
+ ];
+
+ /**
+ * Get Class.
+ *
+ * @return string
+ */
+ public function color(): string
+ {
+ return self::COLORS[$this->name];
+ }
}
diff --git a/app/Enums/Users/RoleEnum.php b/app/Enums/Users/RoleEnum.php
index 4a30c1e..b72f1cb 100644
--- a/app/Enums/Users/RoleEnum.php
+++ b/app/Enums/Users/RoleEnum.php
@@ -10,8 +10,7 @@ enum RoleEnum: int
case conceptor = 1;
case admin = 2;
- case visitor = 3;
- case marketing = 4;
+ case marketing = 3;
/**
* Optionnal labels definition.
@@ -19,7 +18,6 @@ enum RoleEnum: int
private const LABELS = [
self::conceptor->name => 'Concepteur',
self::admin->name => 'Administrateur',
- self::visitor->name => 'Visiteur',
self::marketing->name => 'Marketing',
];
}
diff --git a/app/Events/ClaimModelChanged.php b/app/Events/ClaimModelChanged.php
new file mode 100644
index 0000000..9b0b937
--- /dev/null
+++ b/app/Events/ClaimModelChanged.php
@@ -0,0 +1,55 @@
+claim = $claim;
+ $this->field = $field;
+ $this->label = $label;
+ $this->user = $user;
+ $this->content = $content;
+ }
+}
diff --git a/app/Http/Controllers/Bo/ActivityLogsController.php b/app/Http/Controllers/Bo/ActivityLogsController.php
index 7dbf191..a88b9ef 100644
--- a/app/Http/Controllers/Bo/ActivityLogsController.php
+++ b/app/Http/Controllers/Bo/ActivityLogsController.php
@@ -13,6 +13,14 @@ class ActivityLogsController extends Controller
use ChangesModelOrder;
use UpdateModelPublished;
+ /**
+ * Create the controller instance.
+ */
+ public function __construct()
+ {
+ $this->authorizeResource(ActivityLog::class);
+ }
+
/**
* Display a listing of the resource.
*
diff --git a/app/Http/Controllers/Bo/AnswerController.php b/app/Http/Controllers/Bo/AnswerController.php
index c44b595..074d1a8 100644
--- a/app/Http/Controllers/Bo/AnswerController.php
+++ b/app/Http/Controllers/Bo/AnswerController.php
@@ -13,6 +13,14 @@ use Illuminate\Support\Str;
class AnswerController extends Controller
{
+ /**
+ * Create the controller instance.
+ */
+ public function __construct()
+ {
+ $this->authorizeResource(Answer::class);
+ }
+
/**
* Display a listing of the resource.
*
diff --git a/app/Http/Controllers/Bo/BrandController.php b/app/Http/Controllers/Bo/BrandController.php
index d70e1d9..c8accf0 100644
--- a/app/Http/Controllers/Bo/BrandController.php
+++ b/app/Http/Controllers/Bo/BrandController.php
@@ -13,6 +13,14 @@ use Illuminate\Support\Str;
class BrandController extends Controller
{
+ /**
+ * Create the controller instance.
+ */
+ public function __construct()
+ {
+ $this->authorizeResource(Brand::class);
+ }
+
/**
* Display a listing of the resource.
*
@@ -126,18 +134,4 @@ class BrandController extends Controller
));
});
}
-
- /**
- * Store a newly created resource in storage.
- *
- * @return \Illuminate\Http\JsonResponse
- */
- public function jsonPaginate(): \Illuminate\Http\JsonResponse
- {
- return DB::transaction(function () {
- /** @var \App\Models\Brand */
- $brandModels = Brand::paginate(12);
- return \response()->json($brandModels ?? 500);
- });
- }
}
diff --git a/app/Http/Controllers/Bo/ClaimController.php b/app/Http/Controllers/Bo/ClaimController.php
new file mode 100644
index 0000000..a617b01
--- /dev/null
+++ b/app/Http/Controllers/Bo/ClaimController.php
@@ -0,0 +1,189 @@
+authorizeResource(Claim::class);
+ }
+
+ /**
+ * Display a listing of the resource.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return \Illuminate\Contracts\View\View
+ */
+ public function index(Request $request): \Illuminate\Contracts\View\View
+ {
+ /** @var \Illuminate\Database\Eloquent\Builder $claimModels */
+ $claimModels = Claim::query()->when(
+ $request->filled('brand'),
+ fn($q) => $q->whereHas('brand', fn($q) => $q->where('id', $request->brand))
+ );
+
+ /** @var string $search Search field */
+ $search = $request->search;
+ if ($search) {
+ $this->searchQuery(
+ $claimModels,
+ $search,
+ null,
+ 'first_name',
+ 'last_name',
+ 'email',
+ );
+ }
+ $searchFields = \implode(', ', [
+ trans('validation.attributes.first_name'),
+ trans('validation.attributes.last_name'),
+ trans('validation.attributes.email'),
+ ]);
+
+ /** Sort columns with a query */
+ $this->sortQuery($claimModels);
+
+ /** Custom pagination */
+ $claimModels = $this->paginate($claimModels);
+
+ return view('bo.pages.claims.index', compact('claimModels', 'search', 'searchFields'));
+ }
+
+ /**
+ * Show the form for editing the specified resource.
+ *
+ * @param App\Models\Claim $claim
+ * @return \Illuminate\Contracts\View\View
+ */
+ public function edit(Claim $claim): \Illuminate\Contracts\View\View
+ {
+ $customerClaimModels = !is_null($claim->customer) ? $this->paginate(Claim::query()
+ ->whereNotNull('customer_id')
+ ->whereHas('brand', fn($q) => $q->whereKey($claim->brand->getKey()))
+ ->whereHas('customer', fn($q) => $q->whereKey($claim->customer->getKey()))
+ ->whereNot('id', $claim->getKey())
+ ->whereNot('status', ClaimStatus::treated)) : collect();
+ $brandModels = Brand::query()->orderBy('name', 'ASC')->paginate($this->jsonItemPerPagination);
+ $claimSubjectModels = ClaimSubject::query()
+ ->whereHas('brand', fn($q) => $q->whereKey($claim->brand->getKey()))
+ ->orderBy('label', 'ASC')
+ ->paginate($this->jsonItemPerPagination);
+ $claimMessageModels = ClaimMessage::getAllClaimMessages($claim->getKey());
+ $claimTemplateModels = ClaimMailTemplate::query()
+ ->whereHas('brand', fn($q) => $q->whereKey($claim->brand->getKey()))
+ ->orderBy('label', 'ASC')
+ ->paginate($this->jsonItemPerPagination);
+
+ return view('bo.pages.claims.edit', [
+ 'claimModel' => $claim->load(['brand', 'claimSubject']),
+ 'customerClaimModels' => $customerClaimModels,
+ 'brandModels' => $brandModels,
+ 'claimSubjectModels' => $claimSubjectModels,
+ 'claimMessageModels' => $claimMessageModels,
+ 'claimTemplateModels' => $claimTemplateModels,
+ ]);
+ }
+
+ /**
+ * Update the specified resource.
+ *
+ * @param \App\Http\Requests\Bo\Claims\UpdateClaimRequest $request
+ * @param \App\Models\Claim $claim
+ * @return \Illuminate\Http\JsonResponse
+ */
+ public function update(UpdateClaimRequest $request, Claim $claim): \Illuminate\Http\JsonResponse
+ {
+ return DB::transaction(function () use ($request, $claim) {
+ $claim->fill($request->validated());
+
+ if ($claim->saveOrFail()) {
+ $claimMessageModels = ClaimMessage::getAllClaimMessages($claim->getKey());
+ return response()->json($claimMessageModels);
+ }
+ return response()->json([], 500);
+ });
+ }
+
+ /**
+ * Get a paginate resource.
+ * Needed to overheight the controller method and add a brand condition.
+ *
+ * @param \App\Http\Requests\Bo\PaginateModelsRequest $request
+ * @return \Illuminate\Http\JsonResponse
+ */
+ public function jsonClaimPaginateModels(PaginateModelsRequest $request): \Illuminate\Http\JsonResponse
+ {
+ /** @var \Illuminate\Database\Eloquent\Model $models */
+ $models = $request->targetModel::query()
+ ->whereHas('brand', fn($q) => $q->whereKey($request->route()->parameter('brand')))
+ ->where($request->input('fieldName') ?? 'name', 'like', "%{$request->input('search')}%")
+ ->orderBy($request->input('fieldName') ?? 'name', 'ASC')
+ ->paginate($request->input('paginate') ?? 10);
+ return \response()->json($models);
+ }
+
+ /**
+ * Send the claim answer.
+ *
+ * @param \App\Http\Requests\Bo\Claims\SendClaimAnswerRequest $request
+ * @param \App\Models\Claim $claim
+ * @return \Illuminate\Http\JsonResponse
+ */
+ public function answer(SendClaimAnswerRequest $request, Claim $claim): \Illuminate\Http\JsonResponse
+ {
+ return DB::transaction(function () use ($request, $claim) {
+ /** @var \App\Models\User $userModel */
+ $userModel = auth()->user();
+ $enum = ClaimResponseType::manual;
+ $claim->response_type = $enum;
+ $claim->status = ClaimStatus::treated;
+
+ if ($claim->saveOrFail()) {
+ // Send the response to the claim author.
+ Mail::to($claim->email)->send(new ClaimAnswerMail($claim, $request->validated()['content']));
+
+ // Create custom event with content message.
+ // @phpcs:disable Generic.Files.LineLength.TooLong
+ $content = sprintf(
+ "%s %s %s %s
%s",
+ $userModel->first_name,
+ $userModel->last_name,
+ trans('a modifié le :field en', ['field' => trans('validation.custom.response_type')]),
+ $claim->response_type->label(),
+ clean($request->validated()['content']),
+ );
+ event(new ClaimModelChanged($claim, '', '', null, $content));
+ // @phpcs:enable
+
+ // Return conversation.
+ $claimMessageModels = ClaimMessage::getAllClaimMessages($claim->getKey());
+ return response()->json($claimMessageModels);
+ } //end if
+ return response()->json([], 500);
+ });
+ }
+}
diff --git a/app/Http/Controllers/Bo/ClaimMessageController.php b/app/Http/Controllers/Bo/ClaimMessageController.php
new file mode 100644
index 0000000..2d8660f
--- /dev/null
+++ b/app/Http/Controllers/Bo/ClaimMessageController.php
@@ -0,0 +1,54 @@
+authorize('store', ClaimMessage::class);
+
+ return DB::transaction(function () use ($request) {
+ $claimMessage = new ClaimMessage();
+ $claimMessage->fill($request->validated());
+ if ($claimMessage->saveOrFail()) {
+ $claimMessageModels = ClaimMessage::getAllClaimMessages($claimMessage->claim->getKey());
+ return response()->json($claimMessageModels);
+ }
+ return response()->json([], 500);
+ });
+ }
+
+ /**
+ * Update a specified resource.
+ *
+ * @param \App\Http\Requests\Bo\ClaimMessages\UpdateMessageRequest $request
+ * @param \App\Models\ClaimMessage $claim_message
+ * @return \Illuminate\Http\JsonResponse
+ */
+ public function update(UpdateMessageRequest $request, ClaimMessage $claim_message): \Illuminate\Http\JsonResponse
+ {
+ $this->authorize('update', ClaimMessage::class);
+
+ $model = ClaimMessage::findOrFail($claim_message->getKey());
+ $model->content = $request->validated()['content'];
+ $model->saveOrFail();
+
+ return response()->json();
+ }
+}
diff --git a/app/Http/Controllers/Bo/CustomerController.php b/app/Http/Controllers/Bo/CustomerController.php
index c1f3ec3..4050a3c 100644
--- a/app/Http/Controllers/Bo/CustomerController.php
+++ b/app/Http/Controllers/Bo/CustomerController.php
@@ -23,6 +23,14 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
class CustomerController extends Controller
{
+ /**
+ * Create the controller instance.
+ */
+ public function __construct()
+ {
+ $this->authorizeResource(Customer::class);
+ }
+
/**
* View all customers.
*
@@ -195,6 +203,7 @@ class CustomerController extends Controller
*/
public function export(): \Illuminate\Contracts\View\View
{
+ $this->authorize('export', Customer::class);
$brands = Brand::all();
return view('bo.pages.customers.export', compact(
'brands'
diff --git a/app/Http/Controllers/Bo/QuestionController.php b/app/Http/Controllers/Bo/QuestionController.php
index 81d6e49..3ed8a48 100644
--- a/app/Http/Controllers/Bo/QuestionController.php
+++ b/app/Http/Controllers/Bo/QuestionController.php
@@ -18,6 +18,14 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
class QuestionController extends Controller
{
+ /**
+ * Create the controller instance.
+ */
+ public function __construct()
+ {
+ $this->authorizeResource(Question::class);
+ }
+
/**
* Display a listing of the resource.
*
@@ -27,11 +35,11 @@ class QuestionController extends Controller
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $query */
- $query = Question::query();
+ $query = Question::query()->when(
+ $request->filled('brand'),
+ fn($q) => $q->whereHas('brand', fn($q) => $q->where('id', $request->brand))
+ );
- if ($request->brand) {
- $query = $query->where('brand_id', '=', $request->brand);
- }
if ($request->search) {
$this->searchQuery(
$query,
@@ -60,11 +68,10 @@ class QuestionController extends Controller
*/
public function create(Question $question): \Illuminate\Contracts\View\View
{
- $brandModels = Brand::all();
-
+ $brandModels = Brand::query()->orderBy('name', 'ASC')->paginate($this->jsonItemPerPagination);
return view('bo.pages.questions.create', [
'questionModel' => $question,
- 'brandModels' => $brandModels
+ 'brandModels' => $brandModels
]);
}
@@ -104,9 +111,8 @@ class QuestionController extends Controller
*/
public function edit(Question $question): \Illuminate\Contracts\View\View
{
- $brandModels = Brand::all();
+ $brandModels = Brand::query()->orderBy('name', 'ASC')->paginate($this->jsonItemPerPagination);
$question->load('brand');
-
return view('bo.pages.questions.edit', [
'questionModel' => $question,
'brandModels' => $brandModels
@@ -183,6 +189,7 @@ class QuestionController extends Controller
*/
public function export(): \Illuminate\Contracts\View\View
{
+ $this->authorize('export', Question::class);
$brands = Brand::all();
return view('bo.pages.questions.export', compact('brands'));
}
diff --git a/app/Http/Controllers/Bo/ServiceController.php b/app/Http/Controllers/Bo/ServiceController.php
index d7b5270..001bd42 100644
--- a/app/Http/Controllers/Bo/ServiceController.php
+++ b/app/Http/Controllers/Bo/ServiceController.php
@@ -17,6 +17,14 @@ use Illuminate\Support\Str;
class ServiceController extends Controller
{
+ /**
+ * Create the controller instance.
+ */
+ public function __construct()
+ {
+ $this->authorizeResource(Service::class);
+ }
+
/**
* Display a listing of the resource.
*
@@ -26,11 +34,11 @@ class ServiceController extends Controller
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $query */
- $query = Service::query();
+ $query = Service::query()->when(
+ $request->filled('brand'),
+ fn($q) => $q->whereHas('brand', fn($q) => $q->where('id', $request->brand))
+ );
- if ($request->brand) {
- $query = $query->where('brand_id', '=', $request->brand);
- }
if ($request->search) {
$this->searchQuery(
$query,
@@ -58,8 +66,7 @@ class ServiceController extends Controller
*/
public function create(Service $service): \Illuminate\Contracts\View\View
{
- $brandModels = Brand::all();
-
+ $brandModels = Brand::query()->orderBy('name', 'ASC')->paginate($this->jsonItemPerPagination);
return view('bo.pages.services.create', [
'serviceModel' => $service,
'brandModels' => $brandModels
@@ -104,8 +111,7 @@ class ServiceController extends Controller
*/
public function edit(Service $service): \Illuminate\Contracts\View\View
{
- $brandModels = Brand::all();
-
+ $brandModels = Brand::query()->orderBy('name', 'ASC')->paginate($this->jsonItemPerPagination);
return view('bo.pages.services.edit', [
'serviceModel' => $service,
'brandModels' => $brandModels
diff --git a/app/Http/Controllers/Bo/SingleOptinController.php b/app/Http/Controllers/Bo/SingleOptinController.php
index f34b86c..f2fdfbe 100644
--- a/app/Http/Controllers/Bo/SingleOptinController.php
+++ b/app/Http/Controllers/Bo/SingleOptinController.php
@@ -11,6 +11,14 @@ use Illuminate\Support\Str;
class SingleOptinController extends Controller
{
+ /**
+ * Create the controller instance.
+ */
+ public function __construct()
+ {
+ $this->authorizeResource(SingleOptin::class);
+ }
+
/**
* Display a listing of the resource.
*
diff --git a/app/Http/Controllers/Bo/StatsController.php b/app/Http/Controllers/Bo/StatsController.php
index dd2aecb..4b35f52 100644
--- a/app/Http/Controllers/Bo/StatsController.php
+++ b/app/Http/Controllers/Bo/StatsController.php
@@ -7,10 +7,11 @@ use App\Http\Requests\Bo\StatsByBrandRequest;
use App\Http\Requests\Bo\StatsByQuestionRequest;
use App\Models\Brand;
use App\Models\BrandStat;
-use App\Models\CustomerAnswer;
+use App\Models\ModelAnswer;
use App\Models\Question;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
+use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Schema;
use League\Csv\Writer;
@@ -24,6 +25,7 @@ class StatsController extends Controller
*/
public function viewStatsByBrand(StatsByBrandRequest $request)
{
+ Gate::authorize('viewStatsByBrand');
$stats = null;
if ($request->post()) {
$stats = BrandStat::query()->whereDate('created_at', '>=', $request->start)
@@ -85,6 +87,7 @@ class StatsController extends Controller
*/
public function viewByQuestion(StatsByQuestionRequest $request): \Illuminate\Contracts\View\View
{
+ Gate::authorize('viewByQuestion');
$question = null;
$answers = null;
$answersByDays = null;
@@ -152,8 +155,10 @@ class StatsController extends Controller
*/
private function answersByDays(Collection $answers, Carbon $start, Carbon $end): \Illuminate\Support\Collection
{
+ Gate::authorize('answersByDays');
// * Totalize by date all answers.
- $answersByDays = CustomerAnswer::query()->whereDate('created_at', '>=', $start)
+ $answersByDays = ModelAnswer::query()
+ ->whereDate('created_at', '>=', $start)
->whereDate('created_at', '<=', $end)
->whereIn('answer_id', $answers->pluck('id'))
->get()->map(function ($custAnswer) {
diff --git a/app/Http/Controllers/Bo/UsersController.php b/app/Http/Controllers/Bo/UserController.php
similarity index 99%
rename from app/Http/Controllers/Bo/UsersController.php
rename to app/Http/Controllers/Bo/UserController.php
index 1613af2..72f632e 100644
--- a/app/Http/Controllers/Bo/UsersController.php
+++ b/app/Http/Controllers/Bo/UserController.php
@@ -11,7 +11,7 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
-class UsersController extends Controller
+class UserController extends Controller
{
use UpdateModelPublished;
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php
index 768c25f..e083748 100644
--- a/app/Http/Controllers/Controller.php
+++ b/app/Http/Controllers/Controller.php
@@ -4,11 +4,12 @@ namespace App\Http\Controllers;
use App\Enums\Pagination\ItemsPerPaginationEnum;
use App\Enums\Theme\BootstrapThemeEnum;
+use App\Http\Requests\Bo\PaginateModelsRequest;
+use App\Http\Requests\Bo\ThemeRequest;
use App\Lib\Helpers\ToolboxHelper;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
-use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Schema;
@@ -20,6 +21,9 @@ class Controller extends BaseController
use AuthorizesRequests;
use ValidatesRequests;
+ /** @var integer $itemPerPagination */
+ public $jsonItemPerPagination = 5;
+
/**
* Build Search query on specified fields
* splitting search into words or using whole sentence
@@ -210,16 +214,32 @@ class Controller extends BaseController
return $query;
}
+ /**
+ * Get a paginate resource.
+ *
+ * @param \App\Http\Requests\Bo\PaginateModelsRequest $request
+ * @return \Illuminate\Http\JsonResponse
+ */
+ public function jsonPaginateModels(PaginateModelsRequest $request): \Illuminate\Http\JsonResponse
+ {
+ /** @var \Illuminate\Database\Eloquent\Model $models */
+ $models = $request->targetModel::query()
+ ->where($request->input('fieldName') ?? 'name', 'like', "%{$request->input('search')}%")
+ ->orderBy($request->input('fieldName') ?? 'name', 'ASC')
+ ->paginate($request->input('paginate') ?? 10);
+ return \response()->json($models);
+ }
+
/**
* Set the bootstrap theme or light (default).
*
- * @param \Illuminate\Http\Request $request
+ * @param \App\Http\Requests\Bo\ThemeRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
- protected function setTheme(Request $request): \Illuminate\Http\RedirectResponse
+ protected function setTheme(ThemeRequest $request): \Illuminate\Http\RedirectResponse
{
$theme = ToolboxHelper::getValidatedEnum(
- $request->theme ?: Cache::get('theme', BootstrapThemeEnum::light->value()),
+ $request->validated('theme') ?: Cache::get('theme', BootstrapThemeEnum::light->value()),
'theme',
'\App\Http\Controllers\BootstrapThemeEnum',
);
diff --git a/app/Http/Requests/Bo/ClaimMessages/StoreMessageRequest.php b/app/Http/Requests/Bo/ClaimMessages/StoreMessageRequest.php
new file mode 100644
index 0000000..48e9e62
--- /dev/null
+++ b/app/Http/Requests/Bo/ClaimMessages/StoreMessageRequest.php
@@ -0,0 +1,66 @@
+check();
+ }
+
+ /**
+ * Prepare the data for validation.
+ *
+ * @return void
+ */
+ protected function prepareForValidation(): void
+ {
+ /** @var \App\Models\User $userModel */
+ $userModel = auth('backend')->user();
+
+ $this->merge([
+ 'user_id' => $userModel->getKey(),
+ 'type' => ClaimMessageType::human->value(),
+ ]);
+ }
+
+ /**
+ * Get the validation rules that apply to the request.
+ *
+ * @return array
+ */
+ public function rules(): array
+ {
+ return [
+ 'claim_id' => 'required|numeric|exists:claims,id',
+ 'user_id' => 'required|numeric|exists:users,id',
+ 'content' => 'required|string|between:3,255',
+ 'type' => ['required', new Enum(ClaimMessageType::class)],
+ ];
+ }
+
+ /**
+ * Get custom attributes for validator errors.
+ *
+ * @return array|null>
+ */
+ public function attributes(): array
+ {
+ return [
+ 'claim_id' => trans('models.classes.claims'),
+ 'user_id' => trans('models.classes.users'),
+ 'content' => trans('validation.attributes.content'),
+ 'type' => trans('validation.custom.type'),
+ ];
+ }
+}
diff --git a/app/Http/Requests/Bo/ClaimMessages/UpdateMessageRequest.php b/app/Http/Requests/Bo/ClaimMessages/UpdateMessageRequest.php
new file mode 100644
index 0000000..9230745
--- /dev/null
+++ b/app/Http/Requests/Bo/ClaimMessages/UpdateMessageRequest.php
@@ -0,0 +1,44 @@
+check();
+ }
+
+ /**
+ * Get the validation rules that apply to the request.
+ *
+ * @return array
+ */
+ public function rules(): array
+ {
+ return [
+ 'claim_message_id' => 'required|numeric|exists:claim_messages,id',
+ 'content' => 'required|string|between:3,255',
+ ];
+ }
+
+ /**
+ * Get custom attributes for validator errors.
+ *
+ * @return array|null>
+ */
+ public function attributes(): array
+ {
+ return [
+ 'claim_message_id' => trans('models.classes.claim_messages'),
+ 'content' => trans('validation.attributes.content'),
+ ];
+ }
+}
diff --git a/app/Http/Requests/Bo/Claims/SendClaimAnswerRequest.php b/app/Http/Requests/Bo/Claims/SendClaimAnswerRequest.php
new file mode 100644
index 0000000..590d7c4
--- /dev/null
+++ b/app/Http/Requests/Bo/Claims/SendClaimAnswerRequest.php
@@ -0,0 +1,44 @@
+check();
+ }
+
+ /**
+ * Get the validation rules that apply to the request.
+ *
+ * @return array
+ */
+ public function rules(): array
+ {
+ return [
+ 'claim_id' => 'required|numeric|exists:claims,id',
+ 'content' => 'required|string|between:3,500',
+ ];
+ }
+
+ /**
+ * Get custom attributes for validator errors.
+ *
+ * @return array|null>
+ */
+ public function attributes(): array
+ {
+ return [
+ 'claim_id' => trans('models.classes.claims'),
+ 'content' => trans('validation.attributes.content'),
+ ];
+ }
+}
diff --git a/app/Http/Requests/Bo/Claims/UpdateClaimRequest.php b/app/Http/Requests/Bo/Claims/UpdateClaimRequest.php
new file mode 100644
index 0000000..4214450
--- /dev/null
+++ b/app/Http/Requests/Bo/Claims/UpdateClaimRequest.php
@@ -0,0 +1,54 @@
+check();
+ }
+
+ /**
+ * Get the validation rules that apply to the request.
+ *
+ * @return array
+ */
+ public function rules(): array
+ {
+ return [
+ 'brand_id' => 'required|numeric|exists:brands,id',
+ 'subject_id' => 'required|numeric|exists:claim_subjects,id',
+ 'type' => ['required', new Enum(ClaimType::class)],
+ 'status' => ['required', new Enum(ClaimStatus::class)],
+ 'response_type' => ['present', 'nullable', new Enum(ClaimResponseType::class)],
+ ];
+ }
+
+ /**
+ * Get custom attributes for validator errors.
+ *
+ * @return array|null>
+ */
+ public function attributes(): array
+ {
+ return [
+ 'brand_id' => trans('models.classes.brands'),
+ 'subject_id' => trans('models.classes.claim_subjects'),
+ 'type' => trans('validation.custom.type'),
+ 'status' => trans('validation.custom.status'),
+ 'response_type' => trans('validation.custom.response_type'),
+ ];
+ }
+}
diff --git a/app/Http/Requests/Bo/PaginateModelsRequest.php b/app/Http/Requests/Bo/PaginateModelsRequest.php
new file mode 100644
index 0000000..ace8877
--- /dev/null
+++ b/app/Http/Requests/Bo/PaginateModelsRequest.php
@@ -0,0 +1,52 @@
+|string>
+ */
+ public function rules(): array
+ {
+ return [
+ 'targetModel' => [
+ 'required',
+ 'string',
+ 'starts_with:App\\Models\\',
+ // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
+ function ($attribute, $value, $fail) {
+ if (!class_exists($value)) {
+ $fail("Le modèle spécifié n'existe pas.");
+ return;
+ }
+ if (!is_subclass_of($value, \Illuminate\Database\Eloquent\Model::class)) {
+ $fail("Le modèle spécifié n'est pas un modèle Eloquent.");
+ }
+ },
+ ],
+ 'page' => 'required|integer|min:1',
+ 'paginate' => 'required|integer|min:1',
+ 'fieldName' => 'required|string|alpha_dash|max:255',
+ ];
+ }
+
+ /**
+ * Get custom attributes for validator errors.
+ *
+ * @return array|null>
+ */
+ public function attributes(): array
+ {
+ return [
+ 'targetModel' => trans('validation.custom.targetModel'),
+ 'page' => trans('validation.custom.page'),
+ 'paginate' => trans('validation.custom.paginate'),
+ 'fieldName' => trans('validation.custom.fieldName'),
+ ];
+ }
+}
diff --git a/app/Http/Requests/Bo/Questions/StoreQuestionRequest.php b/app/Http/Requests/Bo/Questions/StoreQuestionRequest.php
index fa6e9c0..1bc827f 100644
--- a/app/Http/Requests/Bo/Questions/StoreQuestionRequest.php
+++ b/app/Http/Requests/Bo/Questions/StoreQuestionRequest.php
@@ -18,18 +18,6 @@ class StoreQuestionRequest extends FormRequest
return auth('backend')->check();
}
- /**
- * Prepare the data for validation.
- *
- * @return void
- */
- protected function prepareForValidation(): void
- {
- $this->merge([
- 'brand_id' => collect($this->brand)->pluck('id')->first()
- ]);
- }
-
/**
* Get the validation rules that apply to the request.
*
diff --git a/app/Http/Requests/Bo/Services/StoreServiceRequest.php b/app/Http/Requests/Bo/Services/StoreServiceRequest.php
index d436929..e87f37f 100644
--- a/app/Http/Requests/Bo/Services/StoreServiceRequest.php
+++ b/app/Http/Requests/Bo/Services/StoreServiceRequest.php
@@ -16,18 +16,6 @@ class StoreServiceRequest extends FormRequest
return auth('backend')->check();
}
- /**
- * Prepare the data for validation.
- *
- * @return void
- */
- protected function prepareForValidation(): void
- {
- $this->merge([
- 'brand_id' => collect($this->brand)->pluck('id')->first()
- ]);
- }
-
/**
* Get the validation rules that apply to the request.
*
diff --git a/app/Http/Requests/Bo/ThemeRequest.php b/app/Http/Requests/Bo/ThemeRequest.php
new file mode 100644
index 0000000..8b16052
--- /dev/null
+++ b/app/Http/Requests/Bo/ThemeRequest.php
@@ -0,0 +1,34 @@
+|string>
+ */
+ public function rules(): array
+ {
+ return [
+ 'theme' => ['required', new Enum(BootstrapThemeEnum::class)],
+ ];
+ }
+
+ /**
+ * Get custom attributes for validator errors.
+ *
+ * @return array|null>
+ */
+ public function attributes(): array
+ {
+ return [
+ 'theme' => trans('validation.custom.theme'),
+ ];
+ }
+}
diff --git a/app/Http/Requests/Bo/Users/UpdateUserRequest.php b/app/Http/Requests/Bo/Users/UpdateUserRequest.php
index 5dede0b..1b4dc56 100644
--- a/app/Http/Requests/Bo/Users/UpdateUserRequest.php
+++ b/app/Http/Requests/Bo/Users/UpdateUserRequest.php
@@ -11,11 +11,11 @@ class UpdateUserRequest extends StoreUserRequest
*
* @return void
*/
- protected function prepareForValidation()
+ protected function prepareForValidation(): void
{
$this->merge([
- 'published' => $this->published ? true : false,
- 'password' => $this->password ? $this->password : $this->route('user')->password,
+ 'published' => $this->published ? true : false,
+ 'password' => $this->password ? $this->password : $this->route('user')->password,
'password_confirmation' => $this->password_confirmation ?
$this->password_confirmation :
$this->route('user')->password
@@ -30,7 +30,7 @@ class UpdateUserRequest extends StoreUserRequest
public function rules(): array
{
return array_merge(parent::rules(), [
- 'email' => [
+ 'email' => [
'required',
'email:rfc,strict,dns,spoof,filter',
'unique:users,email,' . $this->route('user')->id . ',id',
diff --git a/app/Listeners/AddClaimMessageSystem.php b/app/Listeners/AddClaimMessageSystem.php
new file mode 100644
index 0000000..086568f
--- /dev/null
+++ b/app/Listeners/AddClaimMessageSystem.php
@@ -0,0 +1,123 @@
+createClaimMessage($event);
+
+ // Assign content based on whether there is a custom message or default handling.
+ $message->content = $event->content ? $event->content : $this->generateMessageContent($event);
+
+ $message->saveOrFail();
+ }
+
+ /**
+ * Create a new ClaimMessage instance.
+ *
+ * @param \App\Events\ClaimModelChanged $event
+ * @return \App\Models\ClaimMessage
+ */
+ private function createClaimMessage(ClaimModelChanged $event): ClaimMessage
+ {
+ return new ClaimMessage([
+ 'claim_id' => $event->claim->getKey(),
+ 'user_id' => null,
+ 'type' => ClaimMessageType::system,
+ ]);
+ }
+
+ /**
+ * Generate the message content based on the event data.
+ *
+ * @param \App\Events\ClaimModelChanged $event
+ * @return string
+ */
+ private function generateMessageContent(ClaimModelChanged $event): string
+ {
+ // Check for Enum type and generate content accordingly.
+ $castType = $event->claim->getCasts()[$event->field] ?? null;
+ if ($castType && enum_exists($castType) && str_starts_with($castType, "App\\Enums\\Claims\\")) {
+ return $this->generateEnumMessageContent($event);
+ }
+
+ // Default field message content.
+ return $this->generateDefaultFieldMessageContent($event);
+ }
+
+ /**
+ * Generate message content for Enum type fields.
+ *
+ * @param \App\Events\ClaimModelChanged $event
+ * @return string
+ */
+ private function generateEnumMessageContent(ClaimModelChanged $event): string
+ {
+ $enumLabel = $event->claim->{$event->field}->label();
+ $enumColor = $event->claim->{$event->field}->color();
+ $baseMessage = trans(':field est passé à', ['field' => $event->label]);
+
+ // If the user is available, include user details in the message.
+ if ($event->user) {
+ return sprintf(
+ "%s %s %s %s",
+ $event->user->first_name,
+ $event->user->last_name,
+ trans('a modifié le :field en', ['field' => $event->label]),
+ $enumColor,
+ $enumLabel,
+ );
+ }
+
+ // User is not available, return a simple enum change message.
+ return sprintf(
+ "%s : %s",
+ $baseMessage,
+ $enumColor,
+ $enumLabel,
+ );
+ }
+
+ /**
+ * Generate message content for default field types.
+ *
+ * @param \App\Events\ClaimModelChanged $event
+ * @return string
+ */
+ private function generateDefaultFieldMessageContent(ClaimModelChanged $event): string
+ {
+ $field = $event->claim->{$event->field};
+ $baseMessage = trans(':field est passé à', ['field' => $event->label]);
+ $fieldLabel = $field->label ?? $field->name;
+
+ // If the user is available, include user details in the message.
+ if ($event->user) {
+ return sprintf(
+ "%s %s %s %s",
+ $event->user->first_name,
+ $event->user->last_name,
+ trans('a modifié le :field en', ['field' => $event->label]),
+ $fieldLabel,
+ );
+ }
+
+ // User is not available, return a simple field change message.
+ return sprintf(
+ "%s : %s",
+ $baseMessage,
+ $fieldLabel,
+ );
+ }
+}
diff --git a/app/Mail/ClaimAnswerMail.php b/app/Mail/ClaimAnswerMail.php
new file mode 100644
index 0000000..69a2d27
--- /dev/null
+++ b/app/Mail/ClaimAnswerMail.php
@@ -0,0 +1,70 @@
+claimModel = $claimModel;
+ $this->answer = $answer;
+ }
+
+ /**
+ * Build the message.
+ *
+ * @return $this
+ */
+ public function build()
+ {
+ return $this
+ ->from("no-reply@{$this->claimModel->brand->domain}")
+ ->subject(sprintf(
+ 'Réponse réclamation %s - %s',
+ $this->claimModel->reference,
+ $this->claimModel->brand->name
+ ))
+ ->markdown('mail.send-claim-answer')
+ ->text('mail.send-claim-answer-plain')
+ ->with([
+ 'customHeader' => view('vendor.mail.html.header-claim-answer', [
+ 'brandModel' => $this->claimModel->brand,
+ ])->render(),
+ 'customFooter' => view('vendor.mail.html.footer-claim-answer', [
+ 'brandModel' => $this->claimModel->brand,
+ ])->render(),
+ 'claimModel' => $this->claimModel,
+ 'answer' => $this->answer,
+ ]);
+ }
+}
diff --git a/app/Models/Claim.php b/app/Models/Claim.php
index c7fc7bf..219fd70 100644
--- a/app/Models/Claim.php
+++ b/app/Models/Claim.php
@@ -2,29 +2,33 @@
namespace App\Models;
+use App\Enums\Claims\ClaimResponseType;
use App\Enums\Claims\ClaimStatus;
use App\Enums\Claims\ClaimType;
+use App\Events\ClaimModelChanged;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Str;
/**
- * @property integer $id Claim id.
- * @property string $reference Claim reference.
- * @property string $first_name Claimant\'s first name.
- * @property string $last_name Claimant\'s last name.
- * @property string $email Claimant\'s email.
- * @property string|null $address Claimant\'s address.
- * @property string|null $city Claimant\'s city.
- * @property string|null $postcode Claimant\'s postcode.
- * @property string|null $file Claimant\'s file.
- * @property string $message Claimant\'s message.
- * @property \App\Enums\Claims\ClaimType $type Claim type (ClaimType enum).
- * @property \App\Enums\Claims\ClaimStatus $status Claim status (ClaimStatus enum).
- * @property \App\Models\Brand $brand_id Claim associated Brand.
- * @property \App\Models\ClaimSubject $subject_id Claim associated Subject.
- * @property \App\Models\Customer|null $customer_id Claim associated Customer.
- * @property-read \Illuminate\Support\Carbon $created_at Claim created date.
- * @property-read \Illuminate\Support\Carbon $updated_at Claim updated date.
+ * @property integer $id Claim id.
+ * @property string $reference Claim reference.
+ * @property string $first_name Claimant\'s first name.
+ * @property string $last_name Claimant\'s last name.
+ * @property string $email Claimant\'s email.
+ * @property string|null $address Claimant\'s address.
+ * @property string|null $city Claimant\'s city.
+ * @property string|null $postcode Claimant\'s postcode.
+ * @property string|null $file Claimant\'s file.
+ * @property string $message Claimant\'s message.
+ * @property \App\Enums\Claims\ClaimResponseType $response_type Claim type (ClaimResponseType enum).
+ * @property \App\Enums\Claims\ClaimStatus $status Claim status (ClaimStatus enum).
+ * @property \App\Enums\Claims\ClaimType $type Claim type (ClaimType enum).
+ * @property \App\Models\Brand $brand_id Claim associated Brand.
+ * @property \App\Models\ClaimSubject $subject_id Claim associated Subject.
+ * @property \App\Models\Customer|null $customer_id Claim associated Customer.
+ * @property-read \Illuminate\Support\Carbon $created_at Claim created date.
+ * @property-read \Illuminate\Support\Carbon $updated_at Claim updated date.
*/
class Claim extends Model
{
@@ -45,8 +49,9 @@ class Claim extends Model
'postcode',
'file',
'message',
- 'type',
+ 'response_type',
'status',
+ 'type',
'brand_id',
'subject_id',
'customer_id',
@@ -58,8 +63,9 @@ class Claim extends Model
* @var array
*/
protected $casts = [
- 'type' => ClaimType::class,
- 'status' => ClaimStatus::class,
+ 'response_type' => ClaimResponseType::class,
+ 'status' => ClaimStatus::class,
+ 'type' => ClaimType::class,
];
/**
@@ -73,6 +79,56 @@ class Claim extends Model
$model->reference = self::encodeIntegerToBase36($model->getKey());
$model->saveOrFail();
});
+ static::updated(function (self $model) {
+ $user = auth()->user();
+ if (!$user instanceof \App\Models\User) {
+ $user = null;
+ }
+
+ if (isset($model->getChanges()['brand_id'])) {
+ event(new ClaimModelChanged(
+ $model->load('brand'),
+ 'brand',
+ Str::singular(trans('models.classes.brands')),
+ $user,
+ ));
+ }
+ if (isset($model->getChanges()['subject_id'])) {
+ event(new ClaimModelChanged(
+ $model->load('claimSubject'),
+ 'claimSubject',
+ trans('models.classes.claim_subjects'),
+ $user,
+ ));
+ }
+ if (isset($model->getChanges()['status'])) {
+ event(new ClaimModelChanged(
+ $model,
+ 'status',
+ trans('validation.custom.status'),
+ $user,
+ ));
+ }
+ if (isset($model->getChanges()['type'])) {
+ event(new ClaimModelChanged(
+ $model,
+ 'type',
+ trans('validation.custom.type'),
+ $user,
+ ));
+ }
+ if (
+ isset($model->getChanges()['response_type'])
+ && !$model->response_type->equals(ClaimResponseType::manual)
+ ) {
+ event(new ClaimModelChanged(
+ $model,
+ 'response_type',
+ trans('validation.custom.response_type'),
+ $user,
+ ));
+ }
+ });
}
// * RELATIONS
@@ -94,7 +150,7 @@ class Claim extends Model
*/
public function claimSubject(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
- return $this->belongsTo(ClaimSubject::class);
+ return $this->belongsTo(ClaimSubject::class, 'subject_id');
}
/**
@@ -140,4 +196,17 @@ class Claim extends Model
{
return base_convert(strtolower($str), 36, 10);
}
+
+ /**
+ * Get formated address.
+ *
+ * @return string
+ */
+ public function getFormatedAddress(): string
+ {
+ return implode(', ', array_filter([
+ $this->address,
+ trim(implode(' ', array_filter([$this->postcode, $this->city])))
+ ]));
+ }
}
diff --git a/app/Models/ClaimMessage.php b/app/Models/ClaimMessage.php
index e28435d..4fa2854 100644
--- a/app/Models/ClaimMessage.php
+++ b/app/Models/ClaimMessage.php
@@ -59,4 +59,22 @@ class ClaimMessage extends Model
{
return $this->belongsTo(User::class);
}
+
+
+ // * METHODS
+
+ /**
+ * Get all messages from a specific claim.
+ *
+ * @param integer $claimModelKey
+ * @return \Illuminate\Database\Eloquent\Collection
+ */
+ public static function getAllClaimMessages(int $claimModelKey): \Illuminate\Database\Eloquent\Collection
+ {
+ return self::query()
+ ->with('user')
+ ->whereHas('claim', fn($q) => $q->whereKey($claimModelKey))
+ ->orderby('created_at', 'ASC')
+ ->get();
+ }
}
diff --git a/app/Policies/ActivityLogPolicy.php b/app/Policies/ActivityLogPolicy.php
new file mode 100644
index 0000000..fb24e32
--- /dev/null
+++ b/app/Policies/ActivityLogPolicy.php
@@ -0,0 +1,32 @@
+login($service->brand));
}
+
+ /**
+ * Export Customers.
+ *
+ * @param \App\Models\User $authUser
+ * @return boolean
+ */
+ public function export(User $authUser): bool
+ {
+ return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
+ }
}
diff --git a/app/Policies/QuestionPolicy.php b/app/Policies/QuestionPolicy.php
index 9a55808..3bb2627 100644
--- a/app/Policies/QuestionPolicy.php
+++ b/app/Policies/QuestionPolicy.php
@@ -2,60 +2,67 @@
namespace App\Policies;
+use App\Enums\Users\RoleEnum;
use App\Models\Question;
use App\Models\Service;
-use App\Policies\Rules\UserStaticRules as USR;
+use App\Models\User;
+use App\Policies\Rules\UserStaticRules;
class QuestionPolicy
{
/**
* View a Question.
*
+ * @param \App\Models\User $authUser
* @return boolean
*/
- public function view(): bool
+ public function view(User $authUser): bool
{
- return USR::everyOne();
+ return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* ViewAny a Question.
*
+ * @param \App\Models\User $authUser
* @return boolean
*/
- public function viewAny(): bool
+ public function viewAny(User $authUser): bool
{
- return USR::everyOne();
+ return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* Create a Question.
*
+ * @param \App\Models\User $authUser
* @return boolean
*/
- public function create(): bool
+ public function create(User $authUser): bool
{
- return USR::everyOne();
+ return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* Update a Question.
*
+ * @param \App\Models\User $authUser
* @return boolean
*/
- public function update(): bool
+ public function update(User $authUser): bool
{
- return USR::everyOne();
+ return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* Delete a Question.
*
+ * @param \App\Models\User $authUser
* @return boolean
*/
- public function delete(): bool
+ public function delete(User $authUser): bool
{
- return USR::everyOne();
+ return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
@@ -69,4 +76,15 @@ class QuestionPolicy
{
return $service->brand->id === $question->brand_id;
}
+
+ /**
+ * Export Customers.
+ *
+ * @param \App\Models\User $authUser
+ * @return boolean
+ */
+ public function export(User $authUser): bool
+ {
+ return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
+ }
}
diff --git a/app/Policies/ServicePolicy.php b/app/Policies/ServicePolicy.php
index 77d3c36..bec80ae 100644
--- a/app/Policies/ServicePolicy.php
+++ b/app/Policies/ServicePolicy.php
@@ -2,48 +2,54 @@
namespace App\Policies;
-use App\Policies\Rules\UserStaticRules as USR;
+use App\Enums\Users\RoleEnum;
+use App\Models\User;
+use App\Policies\Rules\UserStaticRules;
class ServicePolicy
{
/**
* View an Answer.
*
+ * @param \App\Models\User $authUser
* @return boolean
*/
- public function view(): bool
+ public function view(User $authUser): bool
{
- return USR::everyOne();
+ return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* ViewAny an Service.
*
+ * @param \App\Models\User $authUser
* @return boolean
*/
- public function viewAny(): bool
+ public function viewAny(User $authUser): bool
{
- return USR::everyOne();
+ return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* Create an Service.
*
+ * @param \App\Models\User $authUser
* @return boolean
*/
- public function create(): bool
+ public function create(User $authUser): bool
{
- return USR::everyOne();
+ return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
* Update an Service.
*
+ * @param \App\Models\User $authUser
* @return boolean
*/
- public function update(): bool
+ public function update(User $authUser): bool
{
- return USR::everyOne();
+ return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
@@ -53,6 +59,6 @@ class ServicePolicy
*/
public function delete(): bool
{
- return USR::noOne();
+ return UserStaticRules::noOne();
}
}
diff --git a/app/Policies/SingleOptinPolicy.php b/app/Policies/SingleOptinPolicy.php
index a9cd08d..ca7ab28 100644
--- a/app/Policies/SingleOptinPolicy.php
+++ b/app/Policies/SingleOptinPolicy.php
@@ -2,7 +2,9 @@
namespace App\Policies;
-use App\Policies\Rules\UserStaticRules as USR;
+use App\Enums\Users\RoleEnum;
+use App\Models\User;
+use App\Policies\Rules\UserStaticRules;
class SingleOptinPolicy
{
@@ -13,17 +15,18 @@ class SingleOptinPolicy
*/
public function view(): bool
{
- return USR::noOne();
+ return UserStaticRules::noOne();
}
/**
* ViewAny an Answer.
*
+ * @param \App\Models\User $authUser
* @return boolean
*/
- public function viewAny(): bool
+ public function viewAny(User $authUser): bool
{
- return USR::everyOne();
+ return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
/**
@@ -33,7 +36,7 @@ class SingleOptinPolicy
*/
public function create(): bool
{
- return USR::noOne();
+ return UserStaticRules::noOne();
}
/**
@@ -43,16 +46,17 @@ class SingleOptinPolicy
*/
public function update(): bool
{
- return USR::noOne();
+ return UserStaticRules::noOne();
}
/**
* Delete an Answer.
*
+ * @param \App\Models\User $authUser
* @return boolean
*/
- public function delete(): bool
+ public function delete(User $authUser): bool
{
- return USR::everyOne();
+ return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
}
}
diff --git a/app/Policies/StatisticPolicy.php b/app/Policies/StatisticPolicy.php
new file mode 100644
index 0000000..a5f69ab
--- /dev/null
+++ b/app/Policies/StatisticPolicy.php
@@ -0,0 +1,43 @@
+role);
}
@@ -40,7 +40,7 @@ class UserPolicy
*/
public function create(User $authUser): bool
{
- return UserStaticRules::atLeastRole($authUser, RoleEnum::admin);
+ return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor);
}
/**
@@ -53,7 +53,7 @@ class UserPolicy
public function update(User $authUser, User $user): bool
{
return $authUser->getRouteKey() === $user->getRouteKey() or
- (UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and
+ (UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and
UserStaticRules::atLeastRole($authUser, $user->role));
}
@@ -67,7 +67,7 @@ class UserPolicy
public function delete(User $authUser, User $user): bool
{
return $authUser->getRouteKey() !== $user->getRouteKey() and
- UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and
+ UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and
UserStaticRules::atLeastRole($authUser, $user->role);
}
@@ -81,7 +81,7 @@ class UserPolicy
public function restore(User $authUser, User $user): bool
{
return $authUser->getRouteKey() !== $user->getRouteKey() and
- UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and
+ UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and
UserStaticRules::atLeastRole($authUser, $user->role);
}
@@ -95,7 +95,7 @@ class UserPolicy
public function forceDelete(User $authUser, User $user): bool
{
return $authUser->getRouteKey() !== $user->getRouteKey() and
- UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and
+ UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and
UserStaticRules::atLeastRole($authUser, $user->role);
}
@@ -109,7 +109,7 @@ class UserPolicy
public function duplicate(User $authUser, User $user): bool
{
return $authUser->getRouteKey() !== $user->getRouteKey() and
- UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and
+ UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and
UserStaticRules::atLeastRole($authUser, $user->role);
}
@@ -123,7 +123,7 @@ class UserPolicy
public function changePublished(User $authUser, User $user): bool
{
return $authUser->getRouteKey() !== $user->getRouteKey() and
- UserStaticRules::atLeastRole($authUser, RoleEnum::admin) and
+ UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and
UserStaticRules::atLeastRole($authUser, $user->role);
}
}
diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php
index b50eaea..1baf8c4 100644
--- a/app/Providers/AuthServiceProvider.php
+++ b/app/Providers/AuthServiceProvider.php
@@ -6,6 +6,7 @@ use App\Enums\Users\RoleEnum;
use App\Lib\Helper;
use App\Models\Service;
use App\Models\User;
+use App\Policies\StatisticPolicy;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
@@ -35,6 +36,10 @@ class AuthServiceProvider extends ServiceProvider
return $user->role === RoleEnum::conceptor;
});
+ Gate::define('viewStatsByBrand', [StatisticPolicy::class, 'viewStatsByBrand']);
+ Gate::define('viewByQuestion', [StatisticPolicy::class, 'viewByQuestion']);
+ Gate::define('answersByDays', [StatisticPolicy::class, 'answersByDays']);
+
Auth::viaRequest('api-hmac', function (Request $request) {
/**
diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
index 66ab757..c4133a5 100644
--- a/app/Providers/EventServiceProvider.php
+++ b/app/Providers/EventServiceProvider.php
@@ -2,6 +2,8 @@
namespace App\Providers;
+use App\Events\ClaimModelChanged;
+use App\Listeners\AddClaimMessageSystem;
use App\Models\User;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
@@ -20,9 +22,8 @@ class EventServiceProvider extends ServiceProvider
* @var array>
*/
protected $listen = [
- Registered::class => [
- SendEmailVerificationNotification::class,
- ],
+ Registered::class => [SendEmailVerificationNotification::class],
+ ClaimModelChanged::class => [AddClaimMessageSystem::class],
];
/**
diff --git a/database/factories/ClaimFactory.php b/database/factories/ClaimFactory.php
index e46c9e8..66944b0 100644
--- a/database/factories/ClaimFactory.php
+++ b/database/factories/ClaimFactory.php
@@ -2,6 +2,7 @@
namespace Database\Factories;
+use App\Enums\Claims\ClaimResponseType;
use App\Enums\Claims\ClaimStatus;
use App\Enums\Claims\ClaimType;
use App\Models\Brand;
@@ -27,18 +28,19 @@ class ClaimFactory extends Factory
public function definition(): array
{
return [
- 'first_name' => $this->faker->firstName(),
- 'last_name' => $this->faker->lastName(),
- 'email' => $this->faker->email(),
- 'address' => $this->faker->optional()->address(),
- 'city' => $this->faker->optional()->city(),
- 'postcode' => $this->faker->optional()->postcode(),
- 'message' => $this->faker->sentence(10),
- 'type' => collect(ClaimType::toArray())->random()->value,
- 'status' => collect(ClaimStatus::toArray())->random()->value,
- 'brand_id' => $this->faker->randomElement(Brand::pluck('id')),
- 'subject_id' => $this->faker->randomElement(ClaimSubject::pluck('id')),
- 'customer_id' => $this->faker->boolean(50) ? $this->faker->randomElement(Customer::pluck('id')) : null,
+ 'first_name' => $this->faker->firstName(),
+ 'last_name' => $this->faker->lastName(),
+ 'email' => $this->faker->email(),
+ 'address' => $this->faker->optional()->address(),
+ 'city' => $this->faker->optional()->city(),
+ 'postcode' => $this->faker->optional()->postcode(),
+ 'message' => $this->faker->sentence(10),
+ 'response_type' => ClaimResponseType::none,
+ 'type' => collect(ClaimType::toArray())->random()->value,
+ 'status' => collect(ClaimStatus::toArray())->random()->value,
+ 'brand_id' => $this->faker->randomElement(Brand::pluck('id')),
+ 'subject_id' => $this->faker->randomElement(ClaimSubject::pluck('id')),
+ 'customer_id' => $this->faker->boolean(50) ? $this->faker->randomElement(Customer::pluck('id')) : null,
];
}
}
diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php
index d6ebccc..814b1f5 100644
--- a/database/factories/UserFactory.php
+++ b/database/factories/UserFactory.php
@@ -20,24 +20,11 @@ class UserFactory extends Factory
'first_name' => $this->faker->firstname(),
'last_name' => $this->faker->lastname(),
'email' => $this->faker->unique()->safeEmail(),
- 'email_verified_at' => now(),
- 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi',
'remember_token' => Str::random(10),
'role' => \collect(RoleEnum::toArray())->random()->value,
'published' => $published,
'published_at' => ($published) ? now() : null,
+ 'last_connection' => ($published) ? now() : null,
];
}
-
- /**
- * Indicate that the model's email address should be unverified.
- *
- * @return static
- */
- public function unverified(): static
- {
- return $this->state(fn() => [
- 'email_verified_at' => null,
- ]);
- }
}
diff --git a/database/migrations/2025_07_24_113251_create_claims_table.php b/database/migrations/2025_07_24_113251_create_claims_table.php
index 21193d8..969e73f 100644
--- a/database/migrations/2025_07_24_113251_create_claims_table.php
+++ b/database/migrations/2025_07_24_113251_create_claims_table.php
@@ -1,5 +1,6 @@
string('postcode')->nullable()->comment('Claimant\'s postcode.');
$table->string('file')->nullable()->comment('Claimant\'s file.');
$table->text('message')->comment('Claimant\'s message.');
- $table->unsignedTinyInteger('type')->default(ClaimType::classic)
- ->comment('Claim type (ClaimType enum).');
+ $table->unsignedTinyInteger('response_type')->default(ClaimResponseType::none)
+ ->comment('Claim response type (ClaimResponseType enum).');
$table->unsignedTinyInteger('status')->default(ClaimStatus::untreated)
->comment('Claim status (ClaimStatus enum).');
+ $table->unsignedTinyInteger('type')->default(ClaimType::classic)
+ ->comment('Claim type (ClaimType enum).');
$table->foreignId('brand_id')->comment('Claim associated Brand.')->constrained('brands')
->onUpdate('cascade')->onDelete('cascade');
$table->foreignId('subject_id')->comment('Claim associated Subject.')->constrained('claim_subjects')
diff --git a/database/migrations/2025_07_25_112127_alter_users_for_saml.php b/database/migrations/2025_07_25_112127_alter_users_for_saml.php
index b3daaa9..57b04f3 100644
--- a/database/migrations/2025_07_25_112127_alter_users_for_saml.php
+++ b/database/migrations/2025_07_25_112127_alter_users_for_saml.php
@@ -16,7 +16,7 @@ return new class extends Migration
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('email_verified_at');
$table->dropColumn('password');
- $table->date('last_connection')->nullable()->after('published_at');
+ $table->timestamp('last_connection')->nullable()->after('published_at');
});
}
diff --git a/package-lock.json b/package-lock.json
index 06ac1a9..8ba17d9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -14,6 +14,7 @@
"@types/bootstrap": "^5.2.7",
"@types/node": "^20.8.2",
"@types/toastify-js": "^1.12.1",
+ "@types/vue-select": "^3.16.5",
"@vitejs/plugin-legacy": "latest",
"@vitejs/plugin-vue": "latest",
"@vue/compiler-sfc": "latest",
@@ -42,6 +43,7 @@
"vite-plugin-eslint": "latest",
"vite-plugin-stylelint": "latest",
"vue": "latest",
+ "vue-select": "^4.0.0-beta.6",
"vue-tsc": "1.6.0"
}
},
@@ -399,19 +401,21 @@
}
},
"node_modules/@babel/helper-string-parser": {
- "version": "7.22.5",
- "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz",
- "integrity": "sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw==",
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz",
+ "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==",
"dev": true,
+ "license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-validator-identifier": {
- "version": "7.22.20",
- "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz",
- "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==",
+ "version": "7.27.1",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz",
+ "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==",
"dev": true,
+ "license": "MIT",
"engines": {
"node": ">=6.9.0"
}
@@ -468,10 +472,14 @@
}
},
"node_modules/@babel/parser": {
- "version": "7.23.0",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz",
- "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==",
+ "version": "7.28.0",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.28.0.tgz",
+ "integrity": "sha512-jVZGvOxOuNSsuQuLRTh13nU0AogFlw32w/MT+LV6D3sP5WdbW61E77RnkbaO2dUvmPAYrBDJXGn5gGS6tH4j8g==",
"dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/types": "^7.28.0"
+ },
"bin": {
"parser": "bin/babel-parser.js"
},
@@ -1698,14 +1706,14 @@
}
},
"node_modules/@babel/types": {
- "version": "7.23.0",
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz",
- "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==",
+ "version": "7.28.2",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.2.tgz",
+ "integrity": "sha512-ruv7Ae4J5dUYULmeXw1gmb7rYRz57OWCPM57pHojnLq/3Z1CK2lNSLTCVjxVk1F/TZHwOZZrOWi0ur95BbLxNQ==",
"dev": true,
+ "license": "MIT",
"dependencies": {
- "@babel/helper-string-parser": "^7.22.5",
- "@babel/helper-validator-identifier": "^7.22.20",
- "to-fast-properties": "^2.0.0"
+ "@babel/helper-string-parser": "^7.27.1",
+ "@babel/helper-validator-identifier": "^7.27.1"
},
"engines": {
"node": ">=6.9.0"
@@ -2560,6 +2568,59 @@
"integrity": "sha512-9CTM+LKFmS0+Ii+RH55XPKcmNxCjLticj8kxeCxa7PnSVCZPQurb9XtKQtoMl/fv7WaqUpRezDcFuY8n92CtUg==",
"dev": true
},
+ "node_modules/@types/vue-select": {
+ "version": "3.16.8",
+ "resolved": "https://registry.npmjs.org/@types/vue-select/-/vue-select-3.16.8.tgz",
+ "integrity": "sha512-ZBovlBrWf/wnPqCmMw24ryIC7ghQLfIBmkl1qssqBGONdx7yOmi/GLwtPxll/6UwXWGNWMeokleOgVAZPis+Ag==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "vue": "^2.0.0"
+ }
+ },
+ "node_modules/@types/vue-select/node_modules/@vue/compiler-sfc": {
+ "version": "2.7.16",
+ "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-2.7.16.tgz",
+ "integrity": "sha512-KWhJ9k5nXuNtygPU7+t1rX6baZeqOYLEforUPjgNDBnLicfHCoi48H87Q8XyLZOrNNsmhuwKqtpDQWjEFe6Ekg==",
+ "dev": true,
+ "dependencies": {
+ "@babel/parser": "^7.23.5",
+ "postcss": "^8.4.14",
+ "source-map": "^0.6.1"
+ },
+ "optionalDependencies": {
+ "prettier": "^1.18.2 || ^2.0.0"
+ }
+ },
+ "node_modules/@types/vue-select/node_modules/prettier": {
+ "version": "2.8.8",
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
+ "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "bin": {
+ "prettier": "bin-prettier.js"
+ },
+ "engines": {
+ "node": ">=10.13.0"
+ },
+ "funding": {
+ "url": "https://github.com/prettier/prettier?sponsor=1"
+ }
+ },
+ "node_modules/@types/vue-select/node_modules/vue": {
+ "version": "2.7.16",
+ "resolved": "https://registry.npmjs.org/vue/-/vue-2.7.16.tgz",
+ "integrity": "sha512-4gCtFXaAA3zYZdTp5s4Hl2sozuySsgz4jy1EnpBHNfpMa9dK1ZCG7viqBPCwXtmgc8nHqUsAu3G4gtmXkkY3Sw==",
+ "deprecated": "Vue 2 has reached EOL and is no longer actively maintained. See https://v2.vuejs.org/eol/ for more details.",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@vue/compiler-sfc": "2.7.16",
+ "csstype": "^3.1.0"
+ }
+ },
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "6.7.4",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.7.4.tgz",
@@ -3312,9 +3373,9 @@
"dev": true
},
"node_modules/bootstrap": {
- "version": "5.3.2",
- "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.2.tgz",
- "integrity": "sha512-D32nmNWiQHo94BKHLmOrdjlL05q1c8oxbtBphQFb9Z5to6eGRDCm0QgeaZ4zFBHzfg2++rqa2JkqCcxDy0sH0g==",
+ "version": "5.3.7",
+ "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.7.tgz",
+ "integrity": "sha512-7KgiD8UHjfcPBHEpDNg+zGz8L3LqR3GVwqZiBRFX04a1BCArZOz1r2kjly2HQ0WokqTO0v1nF+QAt8dsW4lKlw==",
"dev": true,
"funding": [
{
@@ -3326,6 +3387,7 @@
"url": "https://opencollective.com/bootstrap"
}
],
+ "license": "MIT",
"peerDependencies": {
"@popperjs/core": "^2.11.8"
}
@@ -6780,15 +6842,6 @@
"integrity": "sha512-AD5ih2NlSssTCwsMznbvwMZpJ1cbhkGd2uueNxzv2jDlEeZdU04JQfRnggJQ8DrcVBGjAsCKwFBbDlVNtEMlzw==",
"dev": true
},
- "node_modules/to-fast-properties": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
- "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==",
- "dev": true,
- "engines": {
- "node": ">=4"
- }
- },
"node_modules/to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
@@ -7468,6 +7521,16 @@
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true
},
+ "node_modules/vue-select": {
+ "version": "4.0.0-beta.6",
+ "resolved": "https://registry.npmjs.org/vue-select/-/vue-select-4.0.0-beta.6.tgz",
+ "integrity": "sha512-K+zrNBSpwMPhAxYLTCl56gaMrWZGgayoWCLqe5rWwkB8aUbAUh7u6sXjIR7v4ckp2WKC7zEEUY27g6h1MRsIHw==",
+ "dev": true,
+ "license": "MIT",
+ "peerDependencies": {
+ "vue": "3.x"
+ }
+ },
"node_modules/vue-template-compiler": {
"version": "2.7.14",
"resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.7.14.tgz",
diff --git a/package.json b/package.json
index 67b4e5b..047696b 100644
--- a/package.json
+++ b/package.json
@@ -21,6 +21,7 @@
"@types/bootstrap": "^5.2.7",
"@types/node": "^20.8.2",
"@types/toastify-js": "^1.12.1",
+ "@types/vue-select": "^3.16.5",
"@vitejs/plugin-legacy": "latest",
"@vitejs/plugin-vue": "latest",
"@vue/compiler-sfc": "latest",
@@ -49,6 +50,7 @@
"vite-plugin-eslint": "latest",
"vite-plugin-stylelint": "latest",
"vue": "latest",
+ "vue-select": "^4.0.0-beta.6",
"vue-tsc": "1.6.0"
}
}
diff --git a/resources/assets/images/logo_ldc.jpg b/resources/assets/images/logo_ldc.jpg
new file mode 100644
index 0000000..7132c2e
Binary files /dev/null and b/resources/assets/images/logo_ldc.jpg differ
diff --git a/resources/assets/images/logo_ldc.png b/resources/assets/images/logo_ldc.png
deleted file mode 100644
index a775f6d..0000000
Binary files a/resources/assets/images/logo_ldc.png and /dev/null differ
diff --git a/resources/lang/en/models.php b/resources/lang/en/models.php
index dad862e..365a044 100644
--- a/resources/lang/en/models.php
+++ b/resources/lang/en/models.php
@@ -2,28 +2,30 @@
return [
'classes' => [
- 'user' => 'user',
- 'activity_log' => 'activity log|activity logs',
- 'services' => 'Services',
- 'brands' => 'Brands',
- 'brand' => 'Brand',
- 'customers' => 'Customers',
- 'questions' => 'Questions',
- 'answers' => 'Answers',
- 'singleoptins' => 'Single Opt-ins'
+ 'user' => 'user',
+ 'activity_log' => 'activity log|activity logs',
+ 'services' => 'Services',
+ 'brands' => 'Brands',
+ 'customers' => 'Customers',
+ 'questions' => 'Questions',
+ 'answers' => 'Answers',
+ 'singleoptins' => 'Single Opt-ins',
+ 'claims' => 'Claims',
+ 'claim_subjects' => 'Subjects',
+ 'claim_mail_templates' => 'Templates',
],
'common' => [
- 'title' => 'Title',
- 'name' => 'Name',
- 'email' => 'Email',
- 'content' => 'Content',
+ 'title' => 'Title',
+ 'name' => 'Name',
+ 'email' => 'Email',
+ 'content' => 'Content',
'visibility' => 'Visibility',
- 'published' => 'Published',
- 'group' => 'Group',
- 'default' => 'Default',
- 'optinDate' => 'Date opt-in',
- 'question' => 'Question',
- 'answer' => 'Answer',
- 'type' => 'Type'
+ 'published' => 'Published',
+ 'group' => 'Group',
+ 'default' => 'Default',
+ 'optinDate' => 'Date opt-in',
+ 'question' => 'Question',
+ 'answer' => 'Answer',
+ 'type' => 'Type',
]
];
diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php
index b3de898..93b5672 100644
--- a/resources/lang/en/validation.php
+++ b/resources/lang/en/validation.php
@@ -222,11 +222,15 @@ return [
'year' => 'year',
],
'custom' => [
- 'event' => 'event',
- 'model' => 'target element',
- 'order' => 'order',
- 'publication' => 'publication',
- 'activated' => 'activated',
- 'target' => 'target',
+ 'event' => 'event',
+ 'model' => 'target element',
+ 'order' => 'order',
+ 'publication' => 'publication',
+ 'activated' => 'activated',
+ 'target' => 'target',
+ 'response_type' => 'response type',
+ 'reference' => 'reference',
+ 'type' => 'type',
+ 'status' => 'status',
],
];
diff --git a/resources/lang/fr/models.php b/resources/lang/fr/models.php
index 4de8b2c..2ae3fd2 100644
--- a/resources/lang/fr/models.php
+++ b/resources/lang/fr/models.php
@@ -2,28 +2,30 @@
return [
'classes' => [
- 'user' => 'utilisateur',
- 'activity_log' => 'journal d\'activité|journaux d\'activité',
- 'services' => 'Services',
- 'brands' => 'Marques',
- 'brand' => 'Marque',
- 'questions' => 'Questions',
- 'answers' => 'Réponses',
- 'customers' => 'Clients',
- 'singleoptins' => 'Opt-ins uniques'
+ 'user' => 'utilisateur',
+ 'activity_log' => 'journal d\'activité|journaux d\'activité',
+ 'services' => 'Services',
+ 'brands' => 'Marques',
+ 'questions' => 'Questions',
+ 'answers' => 'Réponses',
+ 'customers' => 'Clients',
+ 'singleoptins' => 'Opt-ins uniques',
+ 'claims' => 'Réclamations',
+ 'claim_subjects' => 'Sujets',
+ 'claim_mail_templates' => 'Modèles',
],
'common' => [
- 'title' => 'Titre',
- 'name' => 'Nom',
- 'email' => 'E-mail',
- 'content' => 'Contenu',
+ 'title' => 'Titre',
+ 'name' => 'Nom',
+ 'email' => 'E-mail',
+ 'content' => 'Contenu',
'visibility' => 'Visibilitée',
- 'published' => 'Publié',
- 'group' => 'Groupe',
- 'default' => 'Par défaut',
- 'optinDate' => 'Date opt-in',
- 'question' => 'Question',
- 'type' => 'Type',
- 'answer' => 'Réponse'
+ 'published' => 'Publié',
+ 'group' => 'Groupe',
+ 'default' => 'Par défaut',
+ 'optinDate' => 'Date opt-in',
+ 'question' => 'Question',
+ 'type' => 'Type',
+ 'answer' => 'Réponse',
]
];
diff --git a/resources/lang/fr/validation.php b/resources/lang/fr/validation.php
index d66800e..e2c8940 100644
--- a/resources/lang/fr/validation.php
+++ b/resources/lang/fr/validation.php
@@ -222,11 +222,15 @@ return [
'year' => 'année',
],
'custom' => [
- 'event' => 'évènement',
- 'model' => 'élément ciblé',
- 'order' => 'order',
- 'publication' => 'publication',
- 'activated' => 'activé',
- 'target' => 'cible',
+ 'event' => 'évènement',
+ 'model' => 'élément ciblé',
+ 'order' => 'order',
+ 'publication' => 'publication',
+ 'activated' => 'activé',
+ 'target' => 'cible',
+ 'response_type' => 'type de réponse',
+ 'reference' => 'référence',
+ 'type' => 'type',
+ 'status' => 'status',
],
];
diff --git a/resources/sass/bo/base/_common.scss b/resources/sass/bo/base/_common.scss
index 4eb609e..9783ac7 100644
--- a/resources/sass/bo/base/_common.scss
+++ b/resources/sass/bo/base/_common.scss
@@ -64,3 +64,11 @@ main {
border-radius: 0 0 0.375rem !important;
}
}
+
+#sidebar-menu > .sticky-top {
+ top: 4rem !important;
+}
+
+.claim-modal-content {
+ max-height: 20rem;
+}
diff --git a/resources/sass/bo/bo.scss b/resources/sass/bo/bo.scss
index eb37f2b..ca97517 100644
--- a/resources/sass/bo/bo.scss
+++ b/resources/sass/bo/bo.scss
@@ -10,7 +10,3 @@
@import "./base/bootstrap-overload";
@import "./base/fonts";
@import "./base/common";
-
-#sidebar-menu > .sticky-top {
- top: 4rem !important;
-}
diff --git a/resources/sass/bo/pages/.gitkeep b/resources/sass/bo/pages/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/resources/sass/bo/partials/.gitkeep b/resources/sass/bo/partials/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/resources/sass/bo/vendor/_bootstrap.scss b/resources/sass/bo/vendor/_bootstrap.scss
index 52f2a1a..85c6a32 100644
--- a/resources/sass/bo/vendor/_bootstrap.scss
+++ b/resources/sass/bo/vendor/_bootstrap.scss
@@ -37,6 +37,7 @@
@import "~/bootstrap/scss/card";
@import "~/bootstrap/scss/breadcrumb";
@import "~/bootstrap/scss/badge";
+@import "~/bootstrap/scss/modal";
// 6. Optionally include utilities API last to generate classes based on the Sass map in `_utilities.scss`
@import "~/bootstrap/scss/utilities/api";
diff --git a/resources/ts/bo/components/BelongsToManyDropdownComponent.vue b/resources/ts/bo/components/BelongsToManyDropdownComponent.vue
deleted file mode 100644
index bda8283..0000000
--- a/resources/ts/bo/components/BelongsToManyDropdownComponent.vue
+++ /dev/null
@@ -1,255 +0,0 @@
-
-
-
-
- {{ message }}
-
-
-
-
-
-
-
-
- {{ parseValidationInput(`${name}[${String(index)}][name]`, allErrors) }}
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/resources/ts/bo/components/ClaimActionsComponent.vue b/resources/ts/bo/components/ClaimActionsComponent.vue
new file mode 100644
index 0000000..231a841
--- /dev/null
+++ b/resources/ts/bo/components/ClaimActionsComponent.vue
@@ -0,0 +1,494 @@
+
+
+
+
+
+ |
+
+
+
+ {{ errors.methods.parseValidationInput('brand_id', allErrors) }}
+
+ |
+
+
+ {{ brandLabel }}
+ |
+
+ {{ selectParameters.brand.name }}
+ |
+
+
+
+
+ |
+
+
+
+ {{ errors.methods.parseValidationInput('subject_id', allErrors) }}
+
+ |
+
+
+ {{ trans.methods.__("models.classes.claim_subjects") }}
+ |
+
+ {{ selectParameters.subject?.label }}
+ |
+
+
+
+
+ |
+
+
+
+
+
+
+ {{ errors.methods.parseValidationInput(`${enumField.name}`, allErrors) }}
+
+ |
+
+
+ {{ ucfirst(trans.methods.__(`validation.custom.${enumField.name}`)) }}
+ |
+
+ {{ Object.values(enumField.associatedEnum).find(item => item.value == selectParameters.enums[enumField.name])?.label }}
+ |
+
+
+
+
+
+
+
+
diff --git a/resources/ts/bo/components/ClaimConversationComponent.vue b/resources/ts/bo/components/ClaimConversationComponent.vue
new file mode 100644
index 0000000..53938b5
--- /dev/null
+++ b/resources/ts/bo/components/ClaimConversationComponent.vue
@@ -0,0 +1,263 @@
+
+
+
+
+
+
+
+
+
+ {{ errors.methods.parseValidationInput('content', allErrors) }}
+
+
+
+
+
+
+
+
diff --git a/resources/ts/bo/components/ClaimManualResponseComponent.vue b/resources/ts/bo/components/ClaimManualResponseComponent.vue
new file mode 100644
index 0000000..ef782bf
--- /dev/null
+++ b/resources/ts/bo/components/ClaimManualResponseComponent.vue
@@ -0,0 +1,271 @@
+
+
+
+
+
diff --git a/resources/ts/bo/components/ClaimMessageCollapseComponent.vue b/resources/ts/bo/components/ClaimMessageCollapseComponent.vue
new file mode 100644
index 0000000..d492328
--- /dev/null
+++ b/resources/ts/bo/components/ClaimMessageCollapseComponent.vue
@@ -0,0 +1,98 @@
+
+
+
+ {{ text }}
+
+
+
+
+
+
+
+
diff --git a/resources/ts/bo/components/ClaimMessageComponent.vue b/resources/ts/bo/components/ClaimMessageComponent.vue
new file mode 100644
index 0000000..d982d7b
--- /dev/null
+++ b/resources/ts/bo/components/ClaimMessageComponent.vue
@@ -0,0 +1,346 @@
+
+
+
+
+
+
+ {{ trans.methods.__('Chargement...') }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ errors.methods.parseValidationInput('content', allErrors) }}
+
+
+
+
+
+ {{ trans.methods.__('Message système à :date', {
+ date: getFormatedTime(String(claimMessageModel.created_at)),
+ }) }}
+
+
+ {{ trans.methods.__(':user à :date', {
+ user: claimMessageModel.user ? `${claimMessageModel.user?.first_name} ${claimMessageModel.user?.last_name}` : trans.methods.__('Utilisateur supprimé'),
+ date: getFormatedTime(String(claimMessageModel.created_at)),
+ }) }}
+
+
+ {{ trans.methods.__('- Mis à jour le :date', {
+ date: getFormatedDate(String(showDates ? new Date() : claimMessageModel.updated_at)),
+ }) }}
+
+
+
+
+
+
+
+
diff --git a/resources/ts/bo/components/ClaimWrapperComponent.vue b/resources/ts/bo/components/ClaimWrapperComponent.vue
new file mode 100644
index 0000000..3ba36e7
--- /dev/null
+++ b/resources/ts/bo/components/ClaimWrapperComponent.vue
@@ -0,0 +1,123 @@
+
+
+
+
+
diff --git a/resources/ts/bo/components/ImageInputComponent.vue b/resources/ts/bo/components/ImageInputComponent.vue
index 7dcb098..70671ee 100644
--- a/resources/ts/bo/components/ImageInputComponent.vue
+++ b/resources/ts/bo/components/ImageInputComponent.vue
@@ -1,140 +1,157 @@
-