Compare commits
283 commits
resolve_er
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5634d4d232 | ||
|
|
9a1a07307b | ||
|
|
8410447a29 | ||
|
|
f0fb7a26f3 | ||
|
|
f55ca959b8 | ||
|
|
d622f543e9 | ||
|
|
1f1c684008 | ||
|
|
e8c5472d45 | ||
|
|
4ff19d9277 | ||
|
|
7dfd80cf23 | ||
|
|
e19d810a2f | ||
|
|
ab998c975d | ||
|
|
9706922312 | ||
|
|
ebb52b5968 | ||
|
|
6c783247a7 | ||
|
|
6cf790feab | ||
|
|
57c7613455 | ||
|
|
eddeb4f7f6 | ||
|
|
d9d1fea624 | ||
|
|
22d79cfb11 | ||
|
|
22bc49baab | ||
|
|
adb2a8b21c | ||
|
|
7246d7894d | ||
|
|
10b75031e7 | ||
|
|
68a48fdf5a | ||
|
|
a7debacd65 | ||
|
|
dd10d4ba3a | ||
|
|
a7bd6d6420 | ||
|
|
8cfc409d5c | ||
|
|
bc7a1020bc | ||
|
|
e828c8bf66 | ||
|
|
f28dbdd1df | ||
|
|
965226fae6 | ||
|
|
bd9b7cd32e | ||
|
|
8c67989526 | ||
|
|
2212b0ae08 | ||
|
|
c2b25c3503 | ||
|
|
f106c17588 | ||
|
|
8e9d117918 | ||
|
|
0dbb483fc4 | ||
|
|
980717f37c | ||
|
|
020fcdaa03 | ||
|
|
095f80eac1 | ||
|
|
6a973703c4 | ||
|
|
9a853088b1 | ||
|
|
0ec3be521d | ||
|
|
6854af708b | ||
|
|
8f1c920e26 | ||
|
|
efe5e8ace6 | ||
|
|
91f4773c60 | ||
|
|
6b5b4ec619 | ||
|
|
4edd92e572 | ||
|
|
da03fbe273 | ||
|
|
b7f7b7c55d | ||
|
|
49d37a8fa6 | ||
|
|
195a5fcb3e | ||
|
|
e0af4a243a | ||
|
|
0c4d376c22 | ||
|
|
6fabb998ed | ||
|
|
04bd156849 | ||
|
|
a43037d2f9 | ||
|
|
ef57fe9fe5 | ||
|
|
62901a015e | ||
|
|
004af70c30 | ||
|
|
c88f3e8d52 | ||
|
|
fb78d5a77d | ||
|
|
292456bf14 | ||
|
|
a43c6c95b1 | ||
|
|
9b2248b146 | ||
|
|
9ea4786aa8 | ||
|
|
b77c0908f6 | ||
|
|
721e2200f6 | ||
|
|
cbabb40f83 | ||
|
|
e71c0546c5 | ||
|
|
ebeccffac6 | ||
|
|
870986faa4 | ||
|
|
da65fcd12c | ||
|
|
e0e6147576 | ||
|
|
c7493abea0 | ||
|
|
95b69e9496 | ||
|
|
a3123a2bf2 | ||
|
|
33ea75a5ed | ||
|
|
3e09baf6f3 | ||
|
|
1794076c91 | ||
|
|
d5f1891764 | ||
|
|
098e40576e | ||
|
|
3b93ec45c9 | ||
|
|
3b7ca55d73 | ||
|
|
18b66793a0 | ||
|
|
7ee8a2be82 | ||
|
|
7e9cba3d2a | ||
|
|
4e275c3b37 | ||
|
|
87cc2dec86 | ||
|
|
ea41e19724 | ||
|
|
37beca9c5e | ||
|
|
7aa279e9e4 | ||
|
|
65772aeb1d | ||
|
|
ea6ac998d8 | ||
|
|
b14305553f | ||
|
|
aa9483a155 | ||
|
|
9bc3d9e5e0 | ||
|
|
f99dac8aab | ||
|
|
90f27bf560 | ||
|
|
ccc4ed596a | ||
|
|
3f4342f3bb | ||
|
|
e67e4b3cef | ||
|
|
c09214f59a | ||
|
|
950b2babdc | ||
|
|
481c732f3e | ||
|
|
887837dcaf | ||
|
|
13cc9d1394 | ||
|
|
b97f7f575e | ||
|
|
4bdcf60dfa | ||
|
|
17ee6de791 | ||
|
|
460029cf83 | ||
|
|
e54c491c2d | ||
|
|
51f77d3be8 | ||
|
|
435d5626ee | ||
|
|
50ba8eaf8a | ||
|
|
365b839f53 | ||
|
|
f2a65c85b0 | ||
|
|
1a2fe21212 | ||
|
|
4434538cc3 | ||
|
|
d702c02bdb | ||
|
|
b1a6dfb72c | ||
|
|
ec62c6d4b5 | ||
|
|
0f31e03169 | ||
|
|
849420f966 | ||
|
|
844928e945 | ||
|
|
3560e6c7f6 | ||
|
|
cc339201f0 | ||
|
|
e47d9a75e6 | ||
|
|
4d777f6281 | ||
|
|
a3529361b7 | ||
|
|
93a4d54a9e | ||
|
|
46bfa5ef1f | ||
|
|
005378de41 | ||
|
|
ed4b227f9a | ||
|
|
aa3f507483 | ||
|
|
8a34a30ab4 | ||
|
|
88abac9a5d | ||
|
|
9172d75e5d | ||
|
|
4a0c556937 | ||
|
|
085028a465 | ||
|
|
21abe7d761 | ||
|
|
f9ed83ff60 | ||
|
|
df912545e1 | ||
|
|
1ffb5e5bdd | ||
|
|
c6fcd7cfa6 | ||
|
|
8f0a139663 | ||
|
|
7ee190f1d3 | ||
|
|
3d81cd77ce | ||
|
|
fba178b598 | ||
|
|
c6e5c5eeb7 | ||
|
|
3c035aec9d | ||
|
|
1f02f86610 | ||
|
|
efb3914e4f | ||
|
|
dd230c4516 | ||
|
|
6dd7278c4f | ||
|
|
b0f4c37153 | ||
|
|
25ab578c93 | ||
|
|
2d0b300a52 | ||
|
|
52386bbfd4 | ||
|
|
748a5018af | ||
|
|
fbf4a2f96c | ||
|
|
7089b11c5f | ||
|
|
de14d846c5 | ||
|
|
d6ed7c1f04 | ||
|
|
5477affb97 | ||
|
|
77a7871f3d | ||
|
|
c63f2b62e9 | ||
|
|
4c8f5f20f7 | ||
|
|
09d84e31fb | ||
|
|
3e199d0f68 | ||
|
|
7564600ace | ||
|
|
88457bb44a | ||
|
|
ba6f7f8e7b | ||
|
|
f1eddb1cc2 | ||
|
|
7116c5d41f | ||
|
|
bc0d61d438 | ||
|
|
aa49e077bd | ||
|
|
a484335112 | ||
|
|
658fedd3eb | ||
|
|
31510149af | ||
|
|
420947f8e0 | ||
|
|
17c10a1618 | ||
|
|
fb8720d41b | ||
|
|
08afe201f8 | ||
|
|
db39f78281 | ||
|
|
ea29760b95 | ||
|
|
afd8f09d02 | ||
|
|
33cf4f1c93 | ||
|
|
83d4d5442f | ||
|
|
e66af8dc92 | ||
|
|
e595c7e145 | ||
|
|
e1944924c1 | ||
|
|
3a0cc47fa8 | ||
|
|
3a2b5a0af9 | ||
|
|
ca7057ce77 | ||
|
|
0dd283b68d | ||
|
|
7c028a4505 | ||
|
|
b21dd4d260 | ||
|
|
4838b54b4c | ||
|
|
911ee5df4b | ||
|
|
bbfd4360f2 | ||
|
|
3a51ccb0f3 | ||
|
|
1c3f20782b | ||
|
|
673494aeda | ||
|
|
1bd04e2e52 | ||
|
|
aa17aab45f | ||
|
|
ec47d2610f | ||
|
|
560ef30cd8 | ||
|
|
b2908aac9f | ||
|
|
0da4a6fa13 | ||
|
|
b6720bae3d | ||
|
|
a58bf2ff3b | ||
|
|
2b94d780b6 | ||
|
|
74edc5c785 | ||
|
|
781161c5e4 | ||
|
|
2d70ff9f29 | ||
|
|
17a01e1f7a | ||
|
|
e3d828a9e5 | ||
|
|
d17678342e | ||
|
|
b646cb41fe | ||
|
|
5bd7673a18 | ||
|
|
2faf043f68 | ||
|
|
66c889b02a | ||
|
|
74600ef3a7 | ||
|
|
35e18112b9 | ||
|
|
f10b46a012 | ||
|
|
523715a3c1 | ||
|
|
c8b4f97c88 | ||
|
|
65b92edc99 | ||
|
|
2ee245be4c | ||
|
|
766a990361 | ||
|
|
a23509fa09 | ||
|
|
6c8cc25bae | ||
|
|
3c529a7bc0 | ||
|
|
c8d179e7b3 | ||
|
|
8e4d6d4198 | ||
|
|
a3c2697c86 | ||
|
|
c6d89101b4 | ||
|
|
ad43378b52 | ||
|
|
f40f2e2aa5 | ||
|
|
b55d812aaa | ||
|
|
ab08bad87e | ||
|
|
e8b920a8cd | ||
|
|
cb779c83b8 | ||
|
|
a393b24392 | ||
|
|
cd89f6b443 | ||
|
|
d9b316eae4 | ||
|
|
722369cf61 | ||
|
|
0cc315d2ef | ||
|
|
7559a47044 | ||
|
|
55fef3421e | ||
|
|
97d8111f4b | ||
|
|
4354f6a445 | ||
|
|
abdbbae843 | ||
|
|
f150e96d39 | ||
|
|
d2324145a4 | ||
|
|
b6c74efd3d | ||
|
|
57a437db48 | ||
|
|
f3cb8e7974 | ||
|
|
91c1fe5532 | ||
|
|
29a837ff61 | ||
|
|
bbe4478c09 | ||
|
|
28ee9f593d | ||
|
|
eb2d4e5267 | ||
|
|
c19d5829e6 | ||
|
|
c1fb743e34 | ||
|
|
1d07c93799 | ||
|
|
32cb11622c | ||
|
|
911d7a2f6d | ||
|
|
32be1746b5 | ||
|
|
a5d4c58604 | ||
|
|
0d6f34b05a | ||
|
|
606ca09608 | ||
|
|
6523875860 | ||
|
|
83b7e42b90 | ||
|
|
6f20a6b8db | ||
|
|
88f3da4c92 | ||
|
|
bd3133f06c | ||
|
|
bb2cbc5ad8 |
152 changed files with 10046 additions and 2787 deletions
14
.env.example
14
.env.example
|
|
@ -30,19 +30,17 @@ MAIL_PASSWORD=null
|
||||||
MAIL_ENCRYPTION=null
|
MAIL_ENCRYPTION=null
|
||||||
MAIL_FROM_ADDRESS=noreply-sw@ldc.fr
|
MAIL_FROM_ADDRESS=noreply-sw@ldc.fr
|
||||||
MAIL_FROM_NAME="${APP_NAME}"
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
MAIL_LIST_SERVICEWEB=equipe.web@ldc.fr
|
MAIL_LIST_SERVICEWEB=digital@ldc.fr
|
||||||
MAIL_ADMIN=equipe.web@ldc.fr
|
MAIL_ADMIN=digital@ldc.fr
|
||||||
|
|
||||||
# Sentry
|
# Sentry
|
||||||
SENTRY_LARAVEL_DSN=
|
SENTRY_LARAVEL_DSN=
|
||||||
|
|
||||||
# ADMIN SECURE
|
# UWIL ADMIN SECURE
|
||||||
# - API ENDPOINT (Optional)
|
# - LIST SEPARATED WITH ',' (Required)
|
||||||
LDC_WEB_API_ENDPOINT=
|
UWIL_ADMIN_SECURE_CIDR_LIST=""
|
||||||
# - API KEY
|
|
||||||
LDC_WEB_API_KEY=
|
|
||||||
# - LIST SEPARATED WITH ',' (Optional)
|
# - LIST SEPARATED WITH ',' (Optional)
|
||||||
LDC_WEB_CIDR_MANUAL_ALLOWED_LIST=
|
UWIL_ADMIN_SECURE_CIDR_PROJECT_ALLOWED_LIST=
|
||||||
|
|
||||||
# GITLAB API
|
# GITLAB API
|
||||||
GITLAB_URL=
|
GITLAB_URL=
|
||||||
|
|
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -22,3 +22,7 @@ Homestead.yaml
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
storage/samlidp/*
|
storage/samlidp/*
|
||||||
|
.npmrc
|
||||||
|
.zshrc
|
||||||
|
.npm/
|
||||||
|
.composer/
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ include:
|
||||||
file: 'security/security.yml'
|
file: 'security/security.yml'
|
||||||
- project: 'ldc-web/shared-ci'
|
- project: 'ldc-web/shared-ci'
|
||||||
ref: 'main'
|
ref: 'main'
|
||||||
file: 'build/build.yml'
|
file: "build/docker-multistage.yml"
|
||||||
- project: 'ldc-web/shared-ci'
|
- project: 'ldc-web/shared-ci'
|
||||||
ref: 'main'
|
ref: 'main'
|
||||||
file: 'test/test.yml'
|
file: 'test/test.yml'
|
||||||
|
|
|
||||||
44
Dockerfile
44
Dockerfile
|
|
@ -1,5 +1,43 @@
|
||||||
FROM registry.s-web.fr/ldc-web/projets/ldc-web-images-docker/ldcweb-production-8.3:latest
|
FROM composer:2.9.2 AS vendor
|
||||||
COPY --chown=www-data:www-data . /app/srcs
|
|
||||||
|
ARG GITLAB_USER
|
||||||
|
ARG GITLAB_PASSWORD
|
||||||
|
|
||||||
|
COPY database/ database/
|
||||||
|
|
||||||
|
COPY composer.json composer.json
|
||||||
|
COPY composer.lock composer.lock
|
||||||
|
|
||||||
|
RUN composer config gitlab-token.lab.s-web.fr ${GITLAB_USER} ${GITLAB_PASSWORD}
|
||||||
|
RUN composer install \
|
||||||
|
--ignore-platform-reqs \
|
||||||
|
--no-interaction \
|
||||||
|
--no-plugins \
|
||||||
|
--no-scripts \
|
||||||
|
--no-dev \
|
||||||
|
--prefer-dist
|
||||||
|
|
||||||
|
FROM node:20.18 AS frontend
|
||||||
|
|
||||||
|
ARG GITLAB_PASSWORD
|
||||||
|
|
||||||
|
RUN mkdir -p /app/public/build
|
||||||
|
|
||||||
|
COPY package*.json tsconfig.json vite.config.ts .eslintrc.json .stylelintrc.json /app/
|
||||||
|
COPY resources/ /app/resources/
|
||||||
|
WORKDIR /app
|
||||||
|
RUN npm config set @uwil:registry https://lab.s-web.fr/api/v4/groups/ldc-web/-/packages/npm/
|
||||||
|
RUN npm config set -- '//lab.s-web.fr/api/v4/groups/ldc-web/-/packages/npm/:_authToken' "${GITLAB_PASSWORD}"
|
||||||
|
RUN npm ci --no-audit --no-fund --loglevel=error && npm run prod
|
||||||
|
|
||||||
|
FROM registry.s-web.fr/ldc-web/projets/ldc-web-images-docker/uwil-production-8.5:${PHP_8_5_TAG}
|
||||||
|
|
||||||
|
ARG USER=www-data
|
||||||
|
|
||||||
|
COPY --chown=${USER}:${USER} . /app/srcs
|
||||||
|
COPY --from=vendor --chown=${USER}:${USER} /app/vendor/ /app/srcs/vendor/
|
||||||
|
COPY --from=frontend --chown=${USER}:${USER} /app/public/build/ /app/srcs/public/build/
|
||||||
|
|
||||||
USER root
|
USER root
|
||||||
RUN chmod -R 755 /app/srcs/storage
|
RUN chmod -R 755 /app/srcs/storage
|
||||||
USER www-data
|
USER ${USER}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,16 @@
|
||||||
|
|
||||||
PROD : support.uwil.fr
|
PROD : support.uwil.fr
|
||||||
|
|
||||||
|
RE7 : support-web.re7-s-web.fr
|
||||||
|
|
||||||
## Gitlab Intégration
|
## Gitlab Intégration
|
||||||
Le token de groupe pour l'intégration est valable 1 an max
|
Le token de groupe pour l'intégration est valable 11 mois
|
||||||
|
|
||||||
Il faut le renouveler ici : https://lab.s-web.fr/groups/ldc-web/projets/-/settings/access_tokens et le nommer SW Intégration
|
Il faut le renouveler ici : https://lab.s-web.fr/groups/ldc-web/projets/-/settings/access_tokens et le nommer SW Intégration
|
||||||
|
|
||||||
|
Role : Guest
|
||||||
|
Scope : api
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
- App\Models\Message:booted(): investigate why this make errors on prod,
|
- App\Models\Message:booted(): investigate why this make errors on prod,
|
||||||
|
|
|
||||||
4633
_ide_helper.php
Normal file
4633
_ide_helper.php
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -117,7 +117,7 @@ class CreateUser extends Command
|
||||||
{
|
{
|
||||||
while (is_null($this->email)) {
|
while (is_null($this->email)) {
|
||||||
try {
|
try {
|
||||||
$tmp = $this->ask('Type the wanted user email', 'equipe.web@ldc.fr');
|
$tmp = $this->ask('Type the wanted user email', 'digital@ldc.fr');
|
||||||
$validator = Validator::make(['email' => $tmp], [
|
$validator = Validator::make(['email' => $tmp], [
|
||||||
'email' => 'required|unique:users,email|email:rfc,dns'
|
'email' => 'required|unique:users,email|email:rfc,dns'
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
38
app/Console/Commands/ExportTicketsState.php
Normal file
38
app/Console/Commands/ExportTicketsState.php
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Jobs\ExportTicketsState as JobsExportTicketsState;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class ExportTicketsState extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'tickets:export-state';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Export the state of tickets to a CSV file';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$this->info('Running the Job, this could take some time.');
|
||||||
|
$job = new JobsExportTicketsState();
|
||||||
|
$job->handle();
|
||||||
|
$this->info('Job completed');
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -19,7 +19,7 @@ class TestMail extends Command
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $description = 'Send test email to equipe.web@ldc.fr';
|
protected $description = 'Send test email to digital@ldc.fr';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
|
|
@ -29,7 +29,7 @@ class TestMail extends Command
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
Mail::raw(sprintf('UWIL mail-test from %s %s', \config('app.name'), \config('app.url')), function ($msg) {
|
Mail::raw(sprintf('UWIL mail-test from %s %s', \config('app.name'), \config('app.url')), function ($msg) {
|
||||||
$msg->to('equipe.web@ldc.fr')->subject('Test Email');
|
$msg->to('digital@ldc.fr')->subject('Test Email');
|
||||||
});
|
});
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
334
app/Console/Commands/UpdateGitlabDatas.php
Normal file
334
app/Console/Commands/UpdateGitlabDatas.php
Normal file
|
|
@ -0,0 +1,334 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Enums\Tickets\TicketStatusEnum;
|
||||||
|
use App\Models\GitlabIssues;
|
||||||
|
use App\Models\GitlabLabels;
|
||||||
|
use App\Models\GitlabMilestones;
|
||||||
|
use App\Models\GitlabProjects;
|
||||||
|
use App\Models\Ticket;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use GrahamCampbell\GitLab\Facades\GitLab;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
class UpdateGitlabDatas extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'app:update-gitlab-datas {--is-cron}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Fetch some Gitlab datas';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
$isCron = $this->option('is-cron');
|
||||||
|
|
||||||
|
$groupId = 23;
|
||||||
|
|
||||||
|
$this->updateProjectsByGroup($groupId);
|
||||||
|
|
||||||
|
$this->updateLabelsByGroup($groupId);
|
||||||
|
|
||||||
|
$projects = GitlabProjects::all();
|
||||||
|
|
||||||
|
foreach ($projects as $project) {
|
||||||
|
$this->updateMilestonesByProject($project);
|
||||||
|
$this->updateIssuesByProject($project, $isCron);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->syncTicketStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updateProjectsByGroup function
|
||||||
|
*
|
||||||
|
* @param integer $groupId
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function updateProjectsByGroup(int $groupId): void
|
||||||
|
{
|
||||||
|
$allProjects = [];
|
||||||
|
$page = 1;
|
||||||
|
do {
|
||||||
|
$projects = GitLab::groups()->projects($groupId, [
|
||||||
|
'order_by' => 'created_at',
|
||||||
|
'sort' => 'asc',
|
||||||
|
'per_page' => 100,
|
||||||
|
'page' => $page,
|
||||||
|
'include_subgroups' => true
|
||||||
|
]);
|
||||||
|
$allProjects = array_merge($allProjects, $projects);
|
||||||
|
$page++;
|
||||||
|
} while (!empty($projects));
|
||||||
|
|
||||||
|
$this->info(sprintf(
|
||||||
|
"Fetched %d projects in group %d.",
|
||||||
|
count($allProjects),
|
||||||
|
$groupId
|
||||||
|
));
|
||||||
|
|
||||||
|
foreach ($allProjects as $project) {
|
||||||
|
GitlabProjects::upsert(
|
||||||
|
[
|
||||||
|
'name' => $project['name'],
|
||||||
|
'url' => $project['web_url'],
|
||||||
|
'is_archived' => $project['archived'],
|
||||||
|
'gitlab_id' => $project['id']
|
||||||
|
],
|
||||||
|
['gitlab_id']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info("Gitlab Projects upsert complete.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updateLabelsByGroup function
|
||||||
|
*
|
||||||
|
* @param integer $groupId
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function updateLabelsByGroup(int $groupId): void
|
||||||
|
{
|
||||||
|
$allLabels = [];
|
||||||
|
$page = 1;
|
||||||
|
do {
|
||||||
|
$labels = GitLab::groups()->labels($groupId, [
|
||||||
|
'per_page' => 100,
|
||||||
|
'page' => $page,
|
||||||
|
]);
|
||||||
|
$allLabels = array_merge($allLabels, $labels);
|
||||||
|
$page++;
|
||||||
|
} while (!empty($labels));
|
||||||
|
|
||||||
|
$this->info(sprintf(
|
||||||
|
"Fetched %d labels in group %d.",
|
||||||
|
count($allLabels),
|
||||||
|
$groupId
|
||||||
|
));
|
||||||
|
|
||||||
|
foreach ($allLabels as $project) {
|
||||||
|
GitlabLabels::upsert(
|
||||||
|
[
|
||||||
|
'name' => $project['name'],
|
||||||
|
'gitlab_id' => $project['id']
|
||||||
|
],
|
||||||
|
['gitlab_id']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info("Gitlab labels upsert complete.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updateIssuesByProject function
|
||||||
|
*
|
||||||
|
* @param GitlabProjects $project
|
||||||
|
* @param boolean $isCron
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function updateIssuesByProject(GitlabProjects $project, bool $isCron = false): void
|
||||||
|
{
|
||||||
|
$projectId = $project->gitlab_id;
|
||||||
|
$allIssues = [];
|
||||||
|
$page = 1;
|
||||||
|
|
||||||
|
do {
|
||||||
|
$params = [
|
||||||
|
'order_by' => 'created_at',
|
||||||
|
'sort' => 'asc',
|
||||||
|
'per_page' => 100,
|
||||||
|
'page' => $page,
|
||||||
|
'state' => 'all',
|
||||||
|
];
|
||||||
|
if ($isCron) {
|
||||||
|
$params = array_merge($params, ['updated_after' => now()->subDay()]);
|
||||||
|
}
|
||||||
|
$issues = GitLab::projects()->issues($projectId, $params);
|
||||||
|
$allIssues = array_merge($allIssues, $issues);
|
||||||
|
$page++;
|
||||||
|
} while (!empty($issues));
|
||||||
|
|
||||||
|
$this->info(sprintf(
|
||||||
|
"Fetched %d issues in project %d.",
|
||||||
|
count($allIssues),
|
||||||
|
$projectId
|
||||||
|
));
|
||||||
|
|
||||||
|
foreach ($allIssues as $issue) {
|
||||||
|
GitlabIssues::upsert(
|
||||||
|
[
|
||||||
|
'title' => $issue['title'],
|
||||||
|
'url' => $issue['web_url'],
|
||||||
|
'estimate_time' => $issue['time_stats']['time_estimate'] ?? 0,
|
||||||
|
'spent_time' => $issue['time_stats']['total_time_spent'] ?? 0,
|
||||||
|
'is_closed' => $issue['state'] === 'closed',
|
||||||
|
'gitlab_id' => $issue['id'],
|
||||||
|
'gitlab_iid' => $issue['iid'],
|
||||||
|
'milestone_iid' => $issue['milestone']['iid'] ?? null,
|
||||||
|
'gitlab_project_id' => $projectId,
|
||||||
|
'g_created_at' => Carbon::parse($issue['created_at'])->format('Y-m-d'),
|
||||||
|
'g_updated_at' => Carbon::parse($issue['updated_at'])->format('Y-m-d'),
|
||||||
|
'g_closed_at' => !is_null($issue['closed_at'])
|
||||||
|
? Carbon::parse($issue['closed_at'])->format('Y-m-d')
|
||||||
|
: null,
|
||||||
|
'g_due_date' => !is_null($issue['due_date'])
|
||||||
|
? Carbon::parse($issue['due_date'])->format('Y-m-d')
|
||||||
|
: null
|
||||||
|
],
|
||||||
|
['gitlab_id']
|
||||||
|
);
|
||||||
|
|
||||||
|
$issueModel = GitlabIssues::where('gitlab_id', $issue['id'])->firstOrFail();
|
||||||
|
$labelIds = [];
|
||||||
|
|
||||||
|
foreach ($issue['labels'] as $labelName) {
|
||||||
|
$label = Cache::remember("gitlab_label_{$labelName}", 300, function () use ($labelName) {
|
||||||
|
return GitlabLabels::where('name', $labelName)->first();
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($label) {
|
||||||
|
$labelIds[] = $label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$issueModel->gitlabLabels()->sync($labelIds);
|
||||||
|
}//end foreach
|
||||||
|
|
||||||
|
$this->info("Gitlab issues upsert complete.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* updateMilestonesByProject function
|
||||||
|
*
|
||||||
|
* @param GitlabProjects $project
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function updateMilestonesByProject(GitlabProjects $project): void
|
||||||
|
{
|
||||||
|
$projectId = $project->gitlab_id;
|
||||||
|
$allMilestones = [];
|
||||||
|
$page = 1;
|
||||||
|
|
||||||
|
do {
|
||||||
|
$milestones = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
$milestones = GitLab::milestones()->all($projectId, [
|
||||||
|
'per_page' => 100,
|
||||||
|
'page' => $page
|
||||||
|
]);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
if ($e->getCode() === 404) {
|
||||||
|
if ($project->delete()) {
|
||||||
|
Log::warning(sprintf(
|
||||||
|
"Project not found (%s), it has been deleted.",
|
||||||
|
$projectId
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
Log::warning(sprintf(
|
||||||
|
"Project not found (%s).",
|
||||||
|
$projectId
|
||||||
|
));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log::error(sprintf(
|
||||||
|
'API Error for project %s, Message: %d',
|
||||||
|
$projectId,
|
||||||
|
$e->getMessage()
|
||||||
|
));
|
||||||
|
report($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$allMilestones = array_merge($allMilestones, $milestones);
|
||||||
|
$page++;
|
||||||
|
} while (!empty($milestones));
|
||||||
|
|
||||||
|
$this->info(sprintf(
|
||||||
|
"Fetched %d milestones in project %d.",
|
||||||
|
count($allMilestones),
|
||||||
|
$projectId
|
||||||
|
));
|
||||||
|
|
||||||
|
foreach ($allMilestones as $milestone) {
|
||||||
|
GitlabMilestones::upsert(
|
||||||
|
[
|
||||||
|
'title' => $milestone['title'],
|
||||||
|
'url' => $milestone['web_url'],
|
||||||
|
'is_closed' => $milestone['state'] === 'closed',
|
||||||
|
'gitlab_id' => $milestone['id'],
|
||||||
|
'gitlab_iid' => $milestone['iid'],
|
||||||
|
'gitlab_project_id' => $projectId,
|
||||||
|
'g_created_at' => Carbon::parse($milestone['created_at'])->format('Y-m-d'),
|
||||||
|
'g_updated_at' => Carbon::parse($milestone['updated_at'])->format('Y-m-d'),
|
||||||
|
'g_start_date' => !is_null($milestone['start_date'])
|
||||||
|
? Carbon::parse($milestone['start_date'])->format('Y-m-d')
|
||||||
|
: null,
|
||||||
|
'g_due_date' => !is_null($milestone['due_date'])
|
||||||
|
? Carbon::parse($milestone['due_date'])->format('Y-m-d')
|
||||||
|
: null
|
||||||
|
],
|
||||||
|
['gitlab_id']
|
||||||
|
);
|
||||||
|
}//end foreach
|
||||||
|
|
||||||
|
$this->info("Gitlab milestones upsert complete.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Synchronizes ticket statuses based on GitLab issue labels.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function syncTicketStatus(): void
|
||||||
|
{
|
||||||
|
$tickets = Ticket::whereNotNull('gitlab_issue')->whereNot('status', TicketStatusEnum::archived)->get();
|
||||||
|
|
||||||
|
foreach ($tickets as $ticket) {
|
||||||
|
$gitlabIssue = GitlabIssues::where('url', $ticket->gitlab_issue)->with('gitlabLabels')->first();
|
||||||
|
|
||||||
|
$gitlabIssueLabels = $gitlabIssue ? $gitlabIssue->gitlabLabels->pluck('name') : [];
|
||||||
|
|
||||||
|
if ($gitlabIssueLabels) {
|
||||||
|
match (true) {
|
||||||
|
$gitlabIssueLabels->contains('g-wip') => $this->updateTicketStatus($ticket, TicketStatusEnum::inDev),
|
||||||
|
$gitlabIssueLabels->contains('g-production') => $this->updateTicketStatus($ticket, TicketStatusEnum::production),
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the ticket status only if it has changed.
|
||||||
|
*
|
||||||
|
* @param Ticket $ticket The ticket to update.
|
||||||
|
* @param TicketStatusEnum $status The new status to apply.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
private function updateTicketStatus(Ticket $ticket, TicketStatusEnum $status): void
|
||||||
|
{
|
||||||
|
if ($ticket->status !== $status && $ticket->status !== TicketStatusEnum::waiting) {
|
||||||
|
$ticket->status = $status;
|
||||||
|
$ticket->saveOrFail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Console;
|
namespace App\Console;
|
||||||
|
|
||||||
use App\Jobs\AutoCloseOldTickets;
|
use App\Jobs\AutoCloseOldTickets;
|
||||||
|
use App\Jobs\ExportTicketsState;
|
||||||
use App\Jobs\WarnBeforeAutoCloseTicket;
|
use App\Jobs\WarnBeforeAutoCloseTicket;
|
||||||
use Illuminate\Console\Scheduling\Schedule;
|
use Illuminate\Console\Scheduling\Schedule;
|
||||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||||
|
|
@ -24,8 +25,10 @@ class Kernel extends ConsoleKernel
|
||||||
*/
|
*/
|
||||||
protected function schedule(Schedule $schedule)
|
protected function schedule(Schedule $schedule)
|
||||||
{
|
{
|
||||||
|
$schedule->job(ExportTicketsState::class)->weekly()->fridays()->at('14:00');
|
||||||
$schedule->job(AutoCloseOldTickets::class)->dailyAt('08:00');
|
$schedule->job(AutoCloseOldTickets::class)->dailyAt('08:00');
|
||||||
$schedule->job(WarnBeforeAutoCloseTicket::class)->dailyAt('08:05');
|
$schedule->job(WarnBeforeAutoCloseTicket::class)->dailyAt('08:05');
|
||||||
|
$schedule->command('app:update-gitlab-datas --is-cron')->hourly()->between('7:00', '19:00');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
13
app/Dto/BrevoWebHookDto.php
Normal file
13
app/Dto/BrevoWebHookDto.php
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Dto;
|
||||||
|
|
||||||
|
final readonly class BrevoWebHookDto
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public readonly string $plainTextContent,
|
||||||
|
public readonly ?string $brand
|
||||||
|
) {}
|
||||||
|
}
|
||||||
|
|
@ -12,6 +12,8 @@ enum InvoiceStatusEnum: int
|
||||||
case refused = 2;
|
case refused = 2;
|
||||||
case canceled = 3;
|
case canceled = 3;
|
||||||
case archived = 4;
|
case archived = 4;
|
||||||
|
case awaiting_signature = 5;
|
||||||
|
case awaiting_invoicing = 6;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optionnal labels definition.
|
* Optionnal labels definition.
|
||||||
|
|
@ -21,5 +23,7 @@ enum InvoiceStatusEnum: int
|
||||||
self::refused->name => "Refusé (par le client ou aucune réponse de sa part)",
|
self::refused->name => "Refusé (par le client ou aucune réponse de sa part)",
|
||||||
self::canceled->name => "Annulé (supprimé)",
|
self::canceled->name => "Annulé (supprimé)",
|
||||||
self::archived->name => "Archivé (validé et envoyé à la comptabilité)",
|
self::archived->name => "Archivé (validé et envoyé à la comptabilité)",
|
||||||
|
self::awaiting_signature->name => "En attente de signature",
|
||||||
|
self::awaiting_invoicing->name => "En attente de facturation",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ enum TicketFileTypeEnum: int
|
||||||
case docx = '.docx';
|
case docx = '.docx';
|
||||||
case xlsx = '.xlsx';
|
case xlsx = '.xlsx';
|
||||||
case csv = '.csv';
|
case csv = '.csv';
|
||||||
|
case svg = '.svg';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optionnal labels definition
|
* Optionnal labels definition
|
||||||
|
|
@ -29,6 +30,7 @@ enum TicketFileTypeEnum: int
|
||||||
self::docx->name => "Fichier docx",
|
self::docx->name => "Fichier docx",
|
||||||
self::xlsx->name => "Fichier xlsx",
|
self::xlsx->name => "Fichier xlsx",
|
||||||
self::csv->name => "Fichier csv",
|
self::csv->name => "Fichier csv",
|
||||||
|
self::svg->name => "Fichier svg",
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -43,6 +45,7 @@ enum TicketFileTypeEnum: int
|
||||||
self::docx->name => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
self::docx->name => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||||
self::xlsx->name => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
self::xlsx->name => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
self::csv->name => 'text/csv',
|
self::csv->name => 'text/csv',
|
||||||
|
self::svg->name => 'image/svg+xml',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ enum TicketStatusEnum: int
|
||||||
case recetteValidated = 7;
|
case recetteValidated = 7;
|
||||||
case production = 8;
|
case production = 8;
|
||||||
case archived = 9;
|
case archived = 9;
|
||||||
|
case inDev = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optionnal labels definition
|
* Optionnal labels definition
|
||||||
|
|
@ -24,13 +25,14 @@ enum TicketStatusEnum: int
|
||||||
private const LABELS = [
|
private const LABELS = [
|
||||||
self::new->name => "Nouveau",
|
self::new->name => "Nouveau",
|
||||||
self::estimateTodo->name => "Étude chef(s) de projet",
|
self::estimateTodo->name => "Étude chef(s) de projet",
|
||||||
self::takenInAccount->name => "Pris en compte",
|
self::takenInAccount->name => "À planifier",
|
||||||
self::waiting->name => "En attente de réponse",
|
self::waiting->name => "En attente de réponse",
|
||||||
self::waitingValidation->name => "En attente de validation",
|
self::waitingValidation->name => "En attente de validation",
|
||||||
self::recette->name => "En recettage",
|
self::recette->name => "En recettage",
|
||||||
self::recetteValidated->name => "Recettage validé",
|
self::recetteValidated->name => "Recettage validé",
|
||||||
self::production->name => "En production",
|
self::production->name => "En production",
|
||||||
self::archived->name => "Archivé",
|
self::archived->name => "Archivé",
|
||||||
|
self::inDev->name => "En cours de développement",
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -46,6 +48,7 @@ enum TicketStatusEnum: int
|
||||||
self::recetteValidated->name => 'text-success',
|
self::recetteValidated->name => 'text-success',
|
||||||
self::production->name => 'text-success',
|
self::production->name => 'text-success',
|
||||||
self::archived->name => 'text-secondary',
|
self::archived->name => 'text-secondary',
|
||||||
|
self::inDev->name => 'text-discovery',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ enum TicketTypeEnum: int
|
||||||
case newsletter = 4;
|
case newsletter = 4;
|
||||||
case qrcode = 5;
|
case qrcode = 5;
|
||||||
case advice = 6;
|
case advice = 6;
|
||||||
|
case complaints = 7;
|
||||||
|
case mailing = 8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optionnal labels definition
|
* Optionnal labels definition
|
||||||
|
|
@ -25,6 +27,8 @@ enum TicketTypeEnum: int
|
||||||
self::newsletter->name => "Demande newsletter",
|
self::newsletter->name => "Demande newsletter",
|
||||||
self::qrcode->name => "Demande de QR Code",
|
self::qrcode->name => "Demande de QR Code",
|
||||||
self::advice->name => "Conseil - Accompagnement",
|
self::advice->name => "Conseil - Accompagnement",
|
||||||
|
self::complaints->name => "Réclamations consommateurs",
|
||||||
|
self::mailing->name => "Demande mail en masse",
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -37,6 +41,8 @@ enum TicketTypeEnum: int
|
||||||
self::newsletter->name => "bg-warning",
|
self::newsletter->name => "bg-warning",
|
||||||
self::qrcode->name => "bg-secondary",
|
self::qrcode->name => "bg-secondary",
|
||||||
self::advice->name => "bg-info",
|
self::advice->name => "bg-info",
|
||||||
|
self::complaints->name => "bg-dark",
|
||||||
|
self::mailing->name => "bg-discovery",
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Enums\Users;
|
|
||||||
|
|
||||||
use App\Traits\Enums\BaseEnum;
|
|
||||||
|
|
||||||
enum GitlabUsersEnum: int
|
|
||||||
{
|
|
||||||
use BaseEnum;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Each user is associated to his ID on gitlab.
|
|
||||||
*
|
|
||||||
* 24 is Nicolas Demangeat
|
|
||||||
*/
|
|
||||||
case default = 24;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optionnal labels definition
|
|
||||||
*/
|
|
||||||
private const LABELS = [
|
|
||||||
self::default->name => "Default",
|
|
||||||
];
|
|
||||||
}
|
|
||||||
30
app/Events/BrevoWebhookCallReceived.php
Normal file
30
app/Events/BrevoWebhookCallReceived.php
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use Domain\Models\ValueObjects\Email;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
|
||||||
|
readonly class BrevoWebhookCallReceived
|
||||||
|
{
|
||||||
|
use Dispatchable;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public Email $from,
|
||||||
|
public Email $to,
|
||||||
|
public string $htmlRawContent
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return array<int, \Illuminate\Broadcasting\Channel>
|
||||||
|
*/
|
||||||
|
public function broadcastOn(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new PrivateChannel('default'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
34
app/Events/TicketCreated.php
Normal file
34
app/Events/TicketCreated.php
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Events;
|
||||||
|
|
||||||
|
use App\Models\Site;
|
||||||
|
use App\Models\Ticket;
|
||||||
|
use Illuminate\Broadcasting\PrivateChannel;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class TicketCreated implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Dispatchable;
|
||||||
|
use SerializesModels;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public readonly Site $siteReceivingTicket,
|
||||||
|
public readonly Ticket $ticket,
|
||||||
|
public readonly string $byUserName
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the channels the event should broadcast on.
|
||||||
|
*
|
||||||
|
* @return array<int, \Illuminate\Broadcasting\Channel>
|
||||||
|
*/
|
||||||
|
public function broadcastOn(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new PrivateChannel('default'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
58
app/Http/Controllers/Bo/BrevoWebhookController.php
Normal file
58
app/Http/Controllers/Bo/BrevoWebhookController.php
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
|
use App\Events\BrevoWebhookCallReceived;
|
||||||
|
use App\Http\Requests\Bo\BrevoWebhookRequest;
|
||||||
|
use Domain\Models\ValueObjects\Email;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
use \Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
|
class BrevoWebhookController extends BaseController
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly LoggerInterface $logger,
|
||||||
|
private readonly Dispatcher $dispatcher
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function webhookCallReceived(BrevoWebhookRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$fromEmail = $request->getFromAddress();
|
||||||
|
$toEmail = $request->getToAddress();
|
||||||
|
$formContent = $request->getRawHtmlBody();
|
||||||
|
|
||||||
|
if (!$this->isFromLdc($fromEmail)) {
|
||||||
|
$this->logger->warning(
|
||||||
|
'Received a brevo webhook call from a non ldc email.',
|
||||||
|
[
|
||||||
|
'from' => $fromEmail,
|
||||||
|
'to' => $toEmail,
|
||||||
|
'content' => base64_encode($formContent)
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json(
|
||||||
|
['ok' => false],
|
||||||
|
Response::HTTP_BAD_REQUEST
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->dispatcher->dispatch(
|
||||||
|
new BrevoWebhookCallReceived(
|
||||||
|
from: $fromEmail,
|
||||||
|
to: $toEmail,
|
||||||
|
htmlRawContent: $formContent,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json(['ok' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isFromLdc(Email $email): bool
|
||||||
|
{
|
||||||
|
return substr(strrchr($email->value, "@"), 1) === 'ldc.fr';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -25,12 +25,27 @@ class InvoiceController extends Controller
|
||||||
*/
|
*/
|
||||||
public function index(Request $request): \Illuminate\Contracts\View\View
|
public function index(Request $request): \Illuminate\Contracts\View\View
|
||||||
{
|
{
|
||||||
|
// If no sorting is requested, apply the default orderByDesc.
|
||||||
/** @var \Illuminate\Database\Eloquent\Builder $invoiceModels */
|
/** @var \Illuminate\Database\Eloquent\Builder $invoiceModels */
|
||||||
$invoiceModels = Invoice::query()->orderByDesc('created_at');
|
$invoiceModels = (!request()->query('sort_col') && !request()->query('sort_way'))
|
||||||
|
? Invoice::query()->orderByDesc('created_at')
|
||||||
|
: Invoice::query();
|
||||||
|
|
||||||
$status = intval($request->status);
|
$status = intval($request->status);
|
||||||
$invoiceModels = $invoiceModels->when($status, function ($query) use ($status) {
|
|
||||||
$query->where('status', $status);
|
switch ($status) {
|
||||||
});
|
case InvoiceStatusEnum::awaiting_signature->value:
|
||||||
|
$invoiceModels->whereNotNull('sent_client_date')->whereNull('signed_date');
|
||||||
|
break;
|
||||||
|
case InvoiceStatusEnum::awaiting_invoicing->value:
|
||||||
|
$invoiceModels->whereNotNull('sent_client_date')->whereNotNull('signed_date')->whereNull('sent_accounting_date');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if ($status !== 0) {
|
||||||
|
$invoiceModels->where('status', $status);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/** @var string $search Search field */
|
/** @var string $search Search field */
|
||||||
$search = $request->search;
|
$search = $request->search;
|
||||||
|
|
@ -75,7 +90,7 @@ class InvoiceController extends Controller
|
||||||
*/
|
*/
|
||||||
public function create(Invoice $invoice): \Illuminate\Contracts\View\View
|
public function create(Invoice $invoice): \Illuminate\Contracts\View\View
|
||||||
{
|
{
|
||||||
$packageModels = Package::get();
|
$packageModels = Package::where('published', true)->get();
|
||||||
$taskRowModel = Invoice::getTaskStructure();
|
$taskRowModel = Invoice::getTaskStructure();
|
||||||
$siteModels = Site::orderBy('name', 'ASC')->get();
|
$siteModels = Site::orderBy('name', 'ASC')->get();
|
||||||
$companyModels = Company::get();
|
$companyModels = Company::get();
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,15 @@ class PackageController extends Controller
|
||||||
/** @var \Illuminate\Database\Eloquent\Builder $packageModels */
|
/** @var \Illuminate\Database\Eloquent\Builder $packageModels */
|
||||||
$packageModels = Package::query();
|
$packageModels = Package::query();
|
||||||
|
|
||||||
|
$status = $request->status;
|
||||||
|
if ($status === null) {
|
||||||
|
$packageModels->where('published', true);
|
||||||
|
} elseif ($status === '0') {
|
||||||
|
$packageModels->where('published', false);
|
||||||
|
} elseif ($status === '1') {
|
||||||
|
$packageModels->where('published', true);
|
||||||
|
}
|
||||||
|
|
||||||
/** @var string $search Search field */
|
/** @var string $search Search field */
|
||||||
$search = $request->search;
|
$search = $request->search;
|
||||||
if ($search) {
|
if ($search) {
|
||||||
|
|
@ -42,7 +51,7 @@ class PackageController extends Controller
|
||||||
/** Custom pagination */
|
/** Custom pagination */
|
||||||
$packageModels = $this->customPaginate($packageModels, $request->pagination);
|
$packageModels = $this->customPaginate($packageModels, $request->pagination);
|
||||||
|
|
||||||
return view('bo.pages.packages.index', compact('packageModels', 'search', 'searchFields'));
|
return view('bo.pages.packages.index', compact('packageModels', 'search', 'searchFields', 'status'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -153,4 +162,16 @@ class PackageController extends Controller
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change model published.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Package $package
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function changePublished(Package $package)
|
||||||
|
{
|
||||||
|
$package->update(['published' => !$package->getOriginal('published')]);
|
||||||
|
return redirect()->back()->with('success', trans(__('crud.messages.publish_status_saved')));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,193 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Bo;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Http\Requests\Bo\Projects\StoreProjectRequest;
|
|
||||||
use App\Http\Requests\Bo\Projects\UpdateProjectRequest;
|
|
||||||
use App\Lib\Helpers\ToolboxHelper;
|
|
||||||
use App\Models\Project;
|
|
||||||
use App\Models\Site;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class ProjectController extends Controller
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 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 $projectModels */
|
|
||||||
$projectModels = Project::query();
|
|
||||||
|
|
||||||
/** @var string $search Search field */
|
|
||||||
$search = $request->search;
|
|
||||||
if ($search) {
|
|
||||||
$this->searchQuery(
|
|
||||||
$projectModels,
|
|
||||||
$search,
|
|
||||||
null,
|
|
||||||
'name',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$searchFields = trans('Nom');
|
|
||||||
|
|
||||||
/** Sort columns with a query */
|
|
||||||
$this->sortQuery($projectModels);
|
|
||||||
|
|
||||||
/** Custom pagination */
|
|
||||||
$projectModels = $this->customPaginate($projectModels, $request->pagination);
|
|
||||||
|
|
||||||
return view('bo.pages.projects.index', compact('projectModels', 'search', 'searchFields'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Crud show view
|
|
||||||
*
|
|
||||||
* @param \App\Models\Project $project
|
|
||||||
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
|
||||||
*/
|
|
||||||
public function show(Project $project)
|
|
||||||
{
|
|
||||||
return view('bo.pages.projects.show', [
|
|
||||||
'projectModel' => $project
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the form for creating a new resource.
|
|
||||||
*
|
|
||||||
* @param \App\Models\Project $project
|
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
*/
|
|
||||||
public function create(Project $project): \Illuminate\Contracts\View\View
|
|
||||||
{
|
|
||||||
$siteModels = Site::orderBy('name', 'ASC')->get();
|
|
||||||
|
|
||||||
return view('bo.pages.projects.create', [
|
|
||||||
'projectModel' => $project,
|
|
||||||
'siteModels' => $siteModels
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a newly created resource in storage.
|
|
||||||
*
|
|
||||||
* @param \App\Http\Requests\Bo\Projects\StoreProjectRequest $request
|
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
*/
|
|
||||||
public function store(StoreProjectRequest $request): \Illuminate\Http\RedirectResponse
|
|
||||||
{
|
|
||||||
return DB::transaction(function () use ($request) {
|
|
||||||
$project = new Project();
|
|
||||||
$project->fill($request->validated());
|
|
||||||
|
|
||||||
if ($project->saveOrFail()) {
|
|
||||||
return redirect()
|
|
||||||
->route('bo.projects.edit', $project)
|
|
||||||
->with('success', trans(
|
|
||||||
'crud.messages.has_been_created',
|
|
||||||
['model' => Str::singular(trans('models.classes.projects'))]
|
|
||||||
));
|
|
||||||
}
|
|
||||||
return redirect()
|
|
||||||
->back()
|
|
||||||
->with('error', trans(
|
|
||||||
'crud.messages.cannot_be_created',
|
|
||||||
['model' => Str::singular(trans('models.classes.projects'))]
|
|
||||||
));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show the form for editing the specified resource.
|
|
||||||
*
|
|
||||||
* @param \App\Models\Project $project
|
|
||||||
* @return \Illuminate\Contracts\View\View
|
|
||||||
*/
|
|
||||||
public function edit(Project $project): \Illuminate\Contracts\View\View
|
|
||||||
{
|
|
||||||
$siteModels = Site::orderBy('name', 'ASC')->get();
|
|
||||||
|
|
||||||
return view('bo.pages.projects.edit', [
|
|
||||||
'projectModel' => $project,
|
|
||||||
'siteModels' => $siteModels
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the specified resource in storage.
|
|
||||||
*
|
|
||||||
* @param \App\Http\Requests\Bo\Projects\UpdateProjectRequest $request
|
|
||||||
* @param \App\Models\Project $project
|
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
*/
|
|
||||||
public function update(UpdateProjectRequest $request, Project $project): \Illuminate\Http\RedirectResponse
|
|
||||||
{
|
|
||||||
return DB::transaction(function () use ($request, $project) {
|
|
||||||
$project->fill($request->validated());
|
|
||||||
if ($project->saveOrFail()) {
|
|
||||||
return redirect()
|
|
||||||
->route('bo.projects.edit', $project)
|
|
||||||
->with('success', trans(
|
|
||||||
'crud.messages.has_been_updated',
|
|
||||||
['model' => Str::singular(trans('models.classes.projects'))]
|
|
||||||
));
|
|
||||||
} //end if
|
|
||||||
return redirect()
|
|
||||||
->back()
|
|
||||||
->with('error', trans(
|
|
||||||
'crud.messages.cannot_be_updated',
|
|
||||||
['model' => Str::singular(trans('models.classes.projects'))]
|
|
||||||
));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the specified resource from storage.
|
|
||||||
*
|
|
||||||
* @param \App\Models\Project $project
|
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
*/
|
|
||||||
public function destroy(Project $project): \Illuminate\Http\RedirectResponse
|
|
||||||
{
|
|
||||||
return DB::transaction(function () use ($project) {
|
|
||||||
if ($project->deleteOrFail()) {
|
|
||||||
return redirect()
|
|
||||||
->route('bo.projects.index')
|
|
||||||
->with('success', trans(
|
|
||||||
'crud.messages.has_been_deleted',
|
|
||||||
['model' => Str::singular(trans('models.classes.projects'))]
|
|
||||||
));
|
|
||||||
}
|
|
||||||
return redirect()
|
|
||||||
->back()
|
|
||||||
->with('error', trans(
|
|
||||||
':crud.messages.cannot_be_deleted',
|
|
||||||
['model' => Str::singular(trans('models.classes.projects'))]
|
|
||||||
));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a paginate resource.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Http\Request $request
|
|
||||||
* @return Illuminate\Http\JsonResponse
|
|
||||||
*/
|
|
||||||
public function jsonPaginate(Request $request): \Illuminate\Http\JsonResponse
|
|
||||||
{
|
|
||||||
return DB::transaction(function () use ($request) {
|
|
||||||
$model = $request->targetModel;
|
|
||||||
$search = $request->search;
|
|
||||||
$models = $model::where("name", "LIKE", "%{$search}%")->orderBy("name", "ASC");
|
|
||||||
|
|
||||||
return ToolboxHelper::jsonPaginate($this->customPaginate($models, $request->pagination));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -28,11 +28,11 @@ class SiteController extends Controller
|
||||||
|
|
||||||
if ($user->isAdmin()) {
|
if ($user->isAdmin()) {
|
||||||
/** @var \Illuminate\Database\Eloquent\Builder $siteModels */
|
/** @var \Illuminate\Database\Eloquent\Builder $siteModels */
|
||||||
$siteModels = Site::query();
|
$siteModels = Site::query()->with(['invoices', 'tickets']);
|
||||||
} else {
|
} else {
|
||||||
/** @var \Illuminate\Database\Eloquent\Builder $siteModels */
|
/** @var \Illuminate\Database\Eloquent\Builder $siteModels */
|
||||||
$siteModels = Site::whereHas('users', function (\Illuminate\Database\Eloquent\Builder $query) use ($user) {
|
$siteModels = Site::whereHas('users', function (\Illuminate\Database\Eloquent\Builder $query) use ($user) {
|
||||||
$query->where('id', $user->id);
|
$query->where('id', $user->id)->with(['invoices', 'tickets']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,44 +2,48 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Bo;
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
use App\Enums\Tickets\TicketStatusEnum;
|
use App\Models\Site;
|
||||||
use App\Enums\Tickets\TicketTypeEnum;
|
use App\Models\User;
|
||||||
use App\Enums\Users\GitlabUsersEnum;
|
use App\Models\Ticket;
|
||||||
|
use App\Mail\NewTicket;
|
||||||
|
use App\Models\Message;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Jobs\UpdateIssueLabels;
|
||||||
|
use App\Lib\Helpers\ToolboxHelper;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use App\Events\NotifySubscriptions;
|
use App\Events\NotifySubscriptions;
|
||||||
use App\Events\TicketStatusChanged;
|
use App\Events\TicketStatusChanged;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\Bo\AssignTicketToUserRequest;
|
use App\Http\Requests\Bo\LinkTicket;
|
||||||
use App\Http\Requests\Bo\ChangeTicketStatus;
|
use Illuminate\Support\Facades\Mail;
|
||||||
use App\Http\Requests\Bo\CreateMessage;
|
use App\Enums\Tickets\TicketTypeEnum;
|
||||||
use App\Http\Requests\Bo\SortTickets;
|
use App\Http\Requests\Bo\SortTickets;
|
||||||
use App\Http\Requests\Bo\StoreTicket;
|
use App\Http\Requests\Bo\StoreTicket;
|
||||||
use App\Http\Requests\Bo\UpdateChangeOrderRequest;
|
|
||||||
use App\Http\Requests\Bo\UpdateMessage;
|
|
||||||
use App\Http\Requests\Bo\UpdateTicket;
|
use App\Http\Requests\Bo\UpdateTicket;
|
||||||
use App\Http\Requests\Bo\LinkTicket;
|
|
||||||
use App\Lib\Helpers\FileStorageHelper;
|
use App\Lib\Helpers\FileStorageHelper;
|
||||||
use App\Lib\Helpers\ToolboxHelper;
|
use App\Enums\Tickets\TicketStatusEnum;
|
||||||
use App\Mail\NewTicket;
|
use App\Events\TicketCreated;
|
||||||
use App\Models\Message;
|
use App\Http\Requests\Bo\CreateMessage;
|
||||||
use App\Models\Site;
|
use App\Http\Requests\Bo\UpdateMessage;
|
||||||
use App\Models\Ticket;
|
use Illuminate\Support\Facades\Session;
|
||||||
use App\Models\User;
|
|
||||||
use GrahamCampbell\GitLab\Facades\GitLab;
|
use GrahamCampbell\GitLab\Facades\GitLab;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Http\Request;
|
use App\Http\Requests\Bo\ChangeTicketStatus;
|
||||||
use Illuminate\Support\Arr;
|
use App\Http\Requests\Bo\UpdateChangeOrderRequest;
|
||||||
use Illuminate\Support\Facades\DB;
|
use App\Http\Requests\Bo\AssignTicketToUserRequest;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use App\Http\Requests\Bo\UpdateTicketPriorityRequest;
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class TicketController extends Controller
|
class TicketController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* TicketController
|
* TicketController
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct(
|
||||||
{
|
public readonly Dispatcher $dispatcher
|
||||||
|
) {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->authorizeResource(Ticket::class, 'ticket');
|
$this->authorizeResource(Ticket::class, 'ticket');
|
||||||
}
|
}
|
||||||
|
|
@ -212,7 +216,7 @@ class TicketController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$ticket->user()->associate(auth()->user());
|
$ticket->user()->associate($user);
|
||||||
$ticket->site()->associate($site);
|
$ticket->site()->associate($site);
|
||||||
$ticket->saveOrFail();
|
$ticket->saveOrFail();
|
||||||
|
|
||||||
|
|
@ -222,11 +226,11 @@ class TicketController extends Controller
|
||||||
|
|
||||||
$user->subscriptions()->toggle($ticket->id);
|
$user->subscriptions()->toggle($ticket->id);
|
||||||
|
|
||||||
if (config('mail.MAIL_ADMIN')) {
|
$this->dispatcher->dispatch(new TicketCreated(
|
||||||
Mail::to(config('mail.MAIL_ADMIN'))->send(new NewTicket($ticket));
|
siteReceivingTicket: $site,
|
||||||
} else {
|
ticket: $ticket,
|
||||||
throw new \ErrorException('Missing MAIL_ADMIN in .env');
|
byUserName: $user->name
|
||||||
}
|
));
|
||||||
|
|
||||||
return redirect()->route('bo.ticket.show', $ticket)
|
return redirect()->route('bo.ticket.show', $ticket)
|
||||||
->with('success', trans('Ticket enregistré !'));
|
->with('success', trans('Ticket enregistré !'));
|
||||||
|
|
@ -312,6 +316,10 @@ class TicketController extends Controller
|
||||||
*/
|
*/
|
||||||
public function changeStatus(ChangeTicketStatus $request, Ticket $ticket)
|
public function changeStatus(ChangeTicketStatus $request, Ticket $ticket)
|
||||||
{
|
{
|
||||||
|
if ($ticket->gitlab_issue) {
|
||||||
|
\dispatch(new UpdateIssueLabels($ticket, $request->status));
|
||||||
|
}
|
||||||
|
|
||||||
$ticket->fill($request->validated());
|
$ticket->fill($request->validated());
|
||||||
$ticket->saveOrFail();
|
$ticket->saveOrFail();
|
||||||
|
|
||||||
|
|
@ -338,15 +346,14 @@ class TicketController extends Controller
|
||||||
|
|
||||||
/** @var \App\Models\User */
|
/** @var \App\Models\User */
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
// Subscribe to ticket.
|
||||||
if ($request->subscribe) {
|
if ($request->subscribe) {
|
||||||
if (!$user->subscriptions()->find($ticket->id)) {
|
$user->subscriptions()->syncWithoutDetaching([$ticket->id]);
|
||||||
$user->subscriptions()->attach($ticket->id);
|
} else {
|
||||||
}
|
|
||||||
} elseif ($user->subscriptions()->find($ticket->id)) {
|
|
||||||
$user->subscriptions()->detach($ticket->id);
|
$user->subscriptions()->detach($ticket->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store files if any.
|
||||||
if (isset($filesMessage) and $filesMessage) {
|
if (isset($filesMessage) and $filesMessage) {
|
||||||
foreach ($filesMessage as $key => $singleFile) {
|
foreach ($filesMessage as $key => $singleFile) {
|
||||||
if ($key === 0) {
|
if ($key === 0) {
|
||||||
|
|
@ -364,7 +371,7 @@ class TicketController extends Controller
|
||||||
|
|
||||||
return back()
|
return back()
|
||||||
->with('success', trans('Votre message à été ajouté'));
|
->with('success', trans('Votre message à été ajouté'));
|
||||||
});
|
}, 5);
|
||||||
} catch (\ErrorException $e) {
|
} catch (\ErrorException $e) {
|
||||||
report($e);
|
report($e);
|
||||||
Session::flash('error', trans('Une erreur est survenue'));
|
Session::flash('error', trans('Une erreur est survenue'));
|
||||||
|
|
@ -517,9 +524,9 @@ class TicketController extends Controller
|
||||||
return back()->with('error', trans('Le ticket que vous avez renseigné ne fait pas partie du même site.'));
|
return back()->with('error', trans('Le ticket que vous avez renseigné ne fait pas partie du même site.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$ticket->linkedTicket()->where('linked_ticket_id', $linkedTicket->id)->exists()) {
|
if (!$ticket->linkedTickets()->where('linked_ticket_id', $linkedTicket->id)->exists()) {
|
||||||
$ticket->linkedTicket()->attach($linkedTicket->id);
|
$ticket->linkedTickets()->attach($linkedTicket->id);
|
||||||
$linkedTicket->linkedTicket()->attach($ticket->id);
|
$linkedTicket->linkedTickets()->attach($ticket->id);
|
||||||
return back()->with('success', trans('Les tickets ont été liés avec succès.'));
|
return back()->with('success', trans('Les tickets ont été liés avec succès.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -536,8 +543,8 @@ class TicketController extends Controller
|
||||||
*/
|
*/
|
||||||
public function unlinkTicket(Ticket $ticket, Ticket $linkedTicket)
|
public function unlinkTicket(Ticket $ticket, Ticket $linkedTicket)
|
||||||
{
|
{
|
||||||
$ticket->linkedTicket()->detach($linkedTicket->id);
|
$ticket->linkedTickets()->detach($linkedTicket->id);
|
||||||
$linkedTicket->linkedTicket()->detach($ticket->id);
|
$linkedTicket->linkedTickets()->detach($ticket->id);
|
||||||
|
|
||||||
return back()->with('warning', trans('Le lien entre les tickets à été supprimé.'));
|
return back()->with('warning', trans('Le lien entre les tickets à été supprimé.'));
|
||||||
}
|
}
|
||||||
|
|
@ -745,17 +752,26 @@ class TicketController extends Controller
|
||||||
*/
|
*/
|
||||||
public function createGitlabIssue(Ticket $ticket)
|
public function createGitlabIssue(Ticket $ticket)
|
||||||
{
|
{
|
||||||
|
$userGitlabId = auth()->user()->gitlab_id;
|
||||||
$gitlabRepoId = $ticket->site->gitlab_project_id;
|
$gitlabRepoId = $ticket->site->gitlab_project_id;
|
||||||
|
|
||||||
|
if (GitLab::projects()->show($gitlabRepoId)['archived']) {
|
||||||
|
return back()->with('error', \trans("Ce projet GitLab est archivé et ne peut pas être utilisé."));
|
||||||
|
}
|
||||||
|
|
||||||
$description = \sprintf("%s<br>", $ticket->text);
|
$description = \sprintf("%s<br>", $ticket->text);
|
||||||
$cLabel = match ($ticket->type) {
|
$cLabel = match ($ticket->type) {
|
||||||
TicketTypeEnum::bug => 'c-bug',
|
TicketTypeEnum::bug => 'c-bug,g-to-dispatch',
|
||||||
TicketTypeEnum::evolution, TicketTypeEnum::newsletter => 'c-feature',
|
TicketTypeEnum::evolution,
|
||||||
|
TicketTypeEnum::mailing => 'c-feature',
|
||||||
|
TicketTypeEnum::newsletter => 'c-feature,g-to-estimate',
|
||||||
};
|
};
|
||||||
|
|
||||||
$assigneeId = match ($ticket->type) {
|
$assigneeId = match ($ticket->type) {
|
||||||
TicketTypeEnum::bug => GitlabUsersEnum::default->value,
|
TicketTypeEnum::bug => $userGitlabId,
|
||||||
TicketTypeEnum::evolution,
|
TicketTypeEnum::evolution,
|
||||||
TicketTypeEnum::newsletter => $ticket->site->projectManager?->gitlab_id ?? GitlabUsersEnum::default->value
|
TicketTypeEnum::mailing,
|
||||||
|
TicketTypeEnum::newsletter => $ticket->site->projectManager?->gitlab_id
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -766,7 +782,7 @@ class TicketController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$issue = GitLab::issues()->create($gitlabRepoId, [
|
$data = [
|
||||||
'title' => sprintf(
|
'title' => sprintf(
|
||||||
'ts-%s : %s',
|
'ts-%s : %s',
|
||||||
$ticket->id,
|
$ticket->id,
|
||||||
|
|
@ -777,8 +793,13 @@ class TicketController extends Controller
|
||||||
'c-support',
|
'c-support',
|
||||||
$cLabel
|
$cLabel
|
||||||
]),
|
]),
|
||||||
'assignee_id' => $assigneeId,
|
];
|
||||||
]);
|
|
||||||
|
if ($assigneeId) {
|
||||||
|
$data['assignee_id'] = $assigneeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
$issue = GitLab::issues()->create($gitlabRepoId, $data);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
\report($e);
|
\report($e);
|
||||||
return back()->with('error', \trans("Une erreur est survenue"));
|
return back()->with('error', \trans("Une erreur est survenue"));
|
||||||
|
|
@ -806,7 +827,7 @@ class TicketController extends Controller
|
||||||
*/
|
*/
|
||||||
private function formatGitlabFiles(Ticket $ticket, array $uploadedFile, int $fileNb)
|
private function formatGitlabFiles(Ticket $ticket, array $uploadedFile, int $fileNb)
|
||||||
{
|
{
|
||||||
if (Str::endsWith($ticket->file, ['jpg', 'png', 'jpeg', 'pptx', 'docx', 'xslx', 'csv'])) {
|
if (Str::endsWith($ticket->file, ['jpg', 'png', 'jpeg', 'pptx', 'docx', 'xslx', 'csv', 'svg'])) {
|
||||||
$file = \sprintf(
|
$file = \sprintf(
|
||||||
"",
|
"",
|
||||||
$fileNb,
|
$fileNb,
|
||||||
|
|
@ -879,4 +900,34 @@ class TicketController extends Controller
|
||||||
return redirect()->back()->with('success', trans('crud.messages.order_changed'));
|
return redirect()->back()->with('success', trans('crud.messages.order_changed'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update ticket priority.
|
||||||
|
*
|
||||||
|
* @param UpdateTicketPriorityRequest $request
|
||||||
|
* @param Ticket $ticket
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function changePriority(UpdateTicketPriorityRequest $request, Ticket $ticket)
|
||||||
|
{
|
||||||
|
$newPriority = $request->validated('priority');
|
||||||
|
|
||||||
|
return DB::transaction(function () use ($ticket, $newPriority) {
|
||||||
|
// Update all tickets who will be moved with this priority update.
|
||||||
|
$request = Ticket::query()
|
||||||
|
->where('site_id', $ticket->site_id)
|
||||||
|
->whereNot('status', TicketStatusEnum::archived)
|
||||||
|
->whereNot('id', $ticket->id)
|
||||||
|
->whereBetween('order', [min($ticket->order, $newPriority), max($ticket->order, $newPriority)]);
|
||||||
|
$ticket->order < $newPriority ? $request->decrement('order', 1) : $request->increment('order', 1);
|
||||||
|
|
||||||
|
// Update the ticket.
|
||||||
|
$ticket->order = $newPriority;
|
||||||
|
if (!$ticket->saveOrFail()) {
|
||||||
|
return back()->with('error', trans('crud.messages.order_not_changed'));
|
||||||
|
};
|
||||||
|
|
||||||
|
return redirect()->back()->with('success', trans('crud.messages.order_changed'));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,16 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers\Bo;
|
namespace App\Http\Controllers\Bo;
|
||||||
|
|
||||||
use App\Http\Controllers\Bo\Auth\ForgotPasswordController;
|
use App\Models\Site;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\Bo\Users\StoreUserRequest;
|
use App\Http\Requests\Bo\Users\StoreUserRequest;
|
||||||
use App\Http\Requests\Bo\Users\UpdateUserRequest;
|
use App\Http\Requests\Bo\Users\UpdateUserRequest;
|
||||||
use App\Models\Site;
|
use App\Http\Controllers\Bo\Auth\ForgotPasswordController;
|
||||||
use App\Models\User;
|
use App\Http\Requests\Bo\Users\FavouriteSiteRequest;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class UserController extends Controller
|
class UserController extends Controller
|
||||||
{
|
{
|
||||||
|
|
@ -72,8 +73,9 @@ class UserController extends Controller
|
||||||
public function store(StoreUserRequest $request): \Illuminate\Http\RedirectResponse
|
public function store(StoreUserRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
{
|
{
|
||||||
return DB::transaction(function () use ($request) {
|
return DB::transaction(function () use ($request) {
|
||||||
$user = new User();
|
$user = User::query()->onlyTrashed()->where('email', $request->validated('email'))->first() ?? new User();
|
||||||
$user->fill($request->safe()->except('sites'));
|
$user->fill($request->safe()->except('sites'));
|
||||||
|
$user->deleted_at = null;
|
||||||
|
|
||||||
if ($user->saveOrFail()) {
|
if ($user->saveOrFail()) {
|
||||||
$user->sites()->attach(collect($request->validated('sites'))->pluck('id'));
|
$user->sites()->attach(collect($request->validated('sites'))->pluck('id'));
|
||||||
|
|
@ -170,9 +172,35 @@ class UserController extends Controller
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function passwordReset(): \Illuminate\Contracts\View\View
|
public function settings(): \Illuminate\Contracts\View\View
|
||||||
{
|
{
|
||||||
return view('bo.pages.users.passwordReset');
|
return view('bo.pages.users.settings');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Favourite site submit
|
||||||
|
*
|
||||||
|
* @param \App\Http\Requests\Bo\Users\FavouriteSiteRequest $request
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function favouriteSiteSubmit(FavouriteSiteRequest $request): \Illuminate\Http\RedirectResponse
|
||||||
|
{
|
||||||
|
/** @var \App\Models\User */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$user->favourite_site_id = $request->favourite_site_id;
|
||||||
|
$user->saveOrFail();
|
||||||
|
|
||||||
|
return redirect()->back()->with("success", trans('crud.messages.favourite_site_changed'));
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
\report($e);
|
||||||
|
return redirect()->back()->with('error', trans('crud.messages.favourite_site_not_changed'));
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
\report($e);
|
||||||
|
return redirect()->back()->with('error', trans('crud.messages.favourite_site_not_changed'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -216,13 +216,13 @@ class Controller extends BaseController
|
||||||
Session::remove("$rName.sort_col");
|
Session::remove("$rName.sort_col");
|
||||||
Session::remove("$rName.sort_way");
|
Session::remove("$rName.sort_way");
|
||||||
}
|
}
|
||||||
if (request()->sort_col and request()->sort_way and Schema::hasColumn($table, request()->sort_col)) {
|
|
||||||
if (
|
if (
|
||||||
!isset($ignore) or
|
request()->sort_col &&
|
||||||
(isset($ignore) and !in_array(request()->sort_col, $ignore))
|
request()->sort_way &&
|
||||||
|
Schema::hasColumn($table, request()->sort_col) &&
|
||||||
|
(!isset($ignore) || (isset($ignore) && !in_array(request()->sort_col, $ignore)))
|
||||||
) {
|
) {
|
||||||
$query = $query->orderBy(\sprintf("$table.%s", request()->sort_col), request()->sort_way);
|
$query = $query->orderBy("$table." . request()->sort_col, request()->sort_way);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class RedirectIfAuthenticated
|
||||||
switch ($guard) {
|
switch ($guard) {
|
||||||
case 'backend':
|
case 'backend':
|
||||||
if (!$request->routeIs('bo.*') && !$request->routeIs('login')) {
|
if (!$request->routeIs('bo.*') && !$request->routeIs('login')) {
|
||||||
continue;
|
continue 2;
|
||||||
}
|
}
|
||||||
return \redirect()->route('bo.dashboard');
|
return \redirect()->route('bo.dashboard');
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ class VerifyCsrfToken extends Middleware
|
||||||
* @var array<int, string>
|
* @var array<int, string>
|
||||||
*/
|
*/
|
||||||
protected $except = [
|
protected $except = [
|
||||||
'/csp-report'
|
'/csp-report',
|
||||||
|
'/brevo-in'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
50
app/Http/Requests/Bo/BrevoWebhookRequest.php
Normal file
50
app/Http/Requests/Bo/BrevoWebhookRequest.php
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo;
|
||||||
|
|
||||||
|
use Domain\Models\ValueObjects\Email;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Support\Facades\Config;
|
||||||
|
|
||||||
|
class BrevoWebhookRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFromAddress(): Email
|
||||||
|
{
|
||||||
|
return new Email($this->string('items.0.From.Address'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getToAddress(): Email
|
||||||
|
{
|
||||||
|
return new Email((string) $this->input('items.0.To.0.Address'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRawHtmlBody(): string
|
||||||
|
{
|
||||||
|
return $this->string('items.0.RawHtmlBody');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
$expectedFormAddress = Config::string('mail.brevo_webook.expected_from_address');
|
||||||
|
|
||||||
|
return [
|
||||||
|
'items' => ['required', 'array', 'min:1'],
|
||||||
|
'items.0.From.Address' => ['required', 'email:rfc,spoof'],
|
||||||
|
'items.0.To.*.Address' => ['required', 'email:rfc,spoof', "in:{$expectedFormAddress}"],
|
||||||
|
'items.0.RawHtmlBody' => ['required', 'string', 'min:10'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -37,6 +37,8 @@ class CreateMessage extends FormRequest
|
||||||
*/
|
*/
|
||||||
protected function prepareForValidation()
|
protected function prepareForValidation()
|
||||||
{
|
{
|
||||||
|
/** @var \App\Models\User */
|
||||||
|
$user = auth()->user();
|
||||||
$this->merge([
|
$this->merge([
|
||||||
'subscribe' => $this->subscribe ? true : false,
|
'subscribe' => $this->subscribe ? true : false,
|
||||||
'type' => $this->is_private ? MessageTypeEnum::private->value : MessageTypeEnum::public->value
|
'type' => $this->is_private ? MessageTypeEnum::private->value : MessageTypeEnum::public->value
|
||||||
|
|
@ -54,9 +56,22 @@ class CreateMessage extends FormRequest
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
return [
|
return [
|
||||||
'subscribe' => 'required|boolean',
|
'subscribe' => 'required|boolean',
|
||||||
'message' => 'required|min:' . ($user->isAdmin() ? '5' : '20'),
|
'message' => [
|
||||||
|
'required',
|
||||||
|
'min:' . ($user->isAdmin() ? '5' : '20'),
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
$forbidden = ['merci de', 'merci de'];
|
||||||
|
foreach ($forbidden as $word) {
|
||||||
|
if (stripos(strtolower($value), $word) !== false) {
|
||||||
|
$fail(
|
||||||
|
"Le champs 'Message' contient la chaine de caractère non autorisée suivante : $word"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
'file_messages' => 'sometimes|array',
|
'file_messages' => 'sometimes|array',
|
||||||
'file_messages.*' => 'mimes:pptx,docx,xlsx,csv,txt,jpeg,jpg,png,pdf|max:2048',
|
'file_messages.*' => 'mimes:pptx,docx,xlsx,csv,txt,jpeg,jpg,png,pdf,svg|max:2048',
|
||||||
'type' => ['required', new Enum(MessageTypeEnum::class)]
|
'type' => ['required', new Enum(MessageTypeEnum::class)]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,18 @@ class StorePackageRequest extends FormRequest
|
||||||
return Gate::allows('isAdmin');
|
return Gate::allows('isAdmin');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation(): void
|
||||||
|
{
|
||||||
|
$this->merge([
|
||||||
|
'published' => $this->boolean('published'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
|
|
@ -27,6 +39,7 @@ class StorePackageRequest extends FormRequest
|
||||||
return [
|
return [
|
||||||
'name' => 'required|string|min:3|max:255',
|
'name' => 'required|string|min:3|max:255',
|
||||||
'amount' => 'required|numeric|min:0|regex:/^\d+(\.\d{1,2})?$/',
|
'amount' => 'required|numeric|min:0|regex:/^\d+(\.\d{1,2})?$/',
|
||||||
|
'published' => 'required|boolean',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -40,6 +53,7 @@ class StorePackageRequest extends FormRequest
|
||||||
return [
|
return [
|
||||||
'name' => trans('Nom'),
|
'name' => trans('Nom'),
|
||||||
'amount' => trans('Montant (par jour)'),
|
'amount' => trans('Montant (par jour)'),
|
||||||
|
'published' => trans('Publication')
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Requests\Bo\Projects;
|
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
|
||||||
use Illuminate\Support\Facades\Gate;
|
|
||||||
|
|
||||||
class StoreProjectRequest extends FormRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Determine if the user is authorized to make this request.
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function authorize()
|
|
||||||
{
|
|
||||||
return Gate::allows('isAdmin');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'name' => 'required|string|min:3|max:255|unique:projects,name',
|
|
||||||
'site_id' => 'required|exists:sites,id',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Requests\Bo\Projects;
|
|
||||||
|
|
||||||
class UpdateProjectRequest extends StoreProjectRequest
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules()
|
|
||||||
{
|
|
||||||
return array_merge(parent::rules(), [
|
|
||||||
'name' => 'required|string|min:3|max:255|unique:projects,name,' . $this->route('project')->id . ',id',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -28,7 +28,7 @@ class StoreSiteRequest extends FormRequest
|
||||||
'name' => 'required|string|min:3|max:255',
|
'name' => 'required|string|min:3|max:255',
|
||||||
'users' => 'nullable|array',
|
'users' => 'nullable|array',
|
||||||
'users.*.id' => 'required|exists:users,id',
|
'users.*.id' => 'required|exists:users,id',
|
||||||
'gitlab_project_id' => 'nullable|unique:sites,gitlab_project_id',
|
'gitlab_project_id' => 'nullable',
|
||||||
'project_manager_id' => 'nullable|exists:users,id',
|
'project_manager_id' => 'nullable|exists:users,id',
|
||||||
'url_re7' => 'nullable|url',
|
'url_re7' => 'nullable|url',
|
||||||
'url_prod' => 'nullable|url'
|
'url_prod' => 'nullable|url'
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,4 @@ namespace App\Http\Requests\Bo\Sites;
|
||||||
|
|
||||||
class UpdateSiteRequest extends StoreSiteRequest
|
class UpdateSiteRequest extends StoreSiteRequest
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Get the validation rules that apply to the request.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function rules()
|
|
||||||
{
|
|
||||||
return array_merge(parent::rules(), [
|
|
||||||
'gitlab_project_id' => 'nullable|unique:sites,gitlab_project_id,' . $this->route('site')->id . ',id',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,10 +97,24 @@ class StoreTicket extends FormRequest
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
'date_mep' => 'nullable|date',
|
'date_mep' => 'nullable|date',
|
||||||
'text' => 'required|string|min:40',
|
'text' => [
|
||||||
|
'required',
|
||||||
|
'string',
|
||||||
|
'min:40',
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
$forbidden = ['merci de', 'merci de'];
|
||||||
|
foreach ($forbidden as $word) {
|
||||||
|
if (stripos(strtolower($value), $word) !== false) {
|
||||||
|
$fail(
|
||||||
|
"Le champs 'Description du ticket' contient la chaine de caractère non autorisée suivante : $word"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
'title' => 'required|string|between:3,255',
|
'title' => 'required|string|between:3,255',
|
||||||
'file_tickets' => 'sometimes|array',
|
'file_tickets' => 'sometimes|array',
|
||||||
'file_tickets.*' => 'mimes:pptx,docx,xlsx,csv,txt,jpeg,jpg,png,pdf|max:2048',
|
'file_tickets.*' => 'mimes:pptx,docx,xlsx,csv,txt,jpeg,jpg,png,pdf,svg|max:2048',
|
||||||
'is_internal' => 'required|boolean',
|
'is_internal' => 'required|boolean',
|
||||||
'labels' => 'sometimes|array',
|
'labels' => 'sometimes|array',
|
||||||
'labels.*' => [
|
'labels.*' => [
|
||||||
|
|
|
||||||
|
|
@ -39,5 +39,4 @@ class UpdateChangeOrderRequest extends FormRequest
|
||||||
'direction' => 'required|boolean',
|
'direction' => 'required|boolean',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
57
app/Http/Requests/Bo/UpdateTicketPriorityRequest.php
Normal file
57
app/Http/Requests/Bo/UpdateTicketPriorityRequest.php
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo;
|
||||||
|
|
||||||
|
use App\Models\Ticket;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class UpdateTicketPriorityRequest extends FormRequest
|
||||||
|
{
|
||||||
|
private \App\Models\Ticket $ticket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return auth()->check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation(): void
|
||||||
|
{
|
||||||
|
$this->ticket = $this->route('ticket');
|
||||||
|
$max = Ticket::query()->where('site_id', $this->ticket->site_id)->max('order');
|
||||||
|
|
||||||
|
$this->merge([
|
||||||
|
'priority' => min($this->integer('priority'), $max)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'priority' => [
|
||||||
|
'required',
|
||||||
|
'integer',
|
||||||
|
'min:1',
|
||||||
|
function ($attribute, $value, $fail) {
|
||||||
|
if ($this->ticket && intval($value) === $this->ticket->order) {
|
||||||
|
$fail("La valeur de {$attribute} doit être différente de la valeur actuelle.");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
39
app/Http/Requests/Bo/Users/FavouriteSiteRequest.php
Normal file
39
app/Http/Requests/Bo/Users/FavouriteSiteRequest.php
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Bo\Users;
|
||||||
|
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class FavouriteSiteRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return Auth::check();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
/** @var \App\Models\User|null $user */
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'favourite_site_id' => [
|
||||||
|
'nullable',
|
||||||
|
'exists:sites,id',
|
||||||
|
Rule::in($user->sites->pluck('id')),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -19,6 +19,18 @@ class StoreUserRequest extends FormRequest
|
||||||
return Gate::allows('isAdmin');
|
return Gate::allows('isAdmin');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the data for validation.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function prepareForValidation(): void
|
||||||
|
{
|
||||||
|
$this->merge([
|
||||||
|
'gitlab_id' => \boolval($this->input('gitlab_id')) ? $this->input('gitlab_id') : null
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the validation rules that apply to the request.
|
* Get the validation rules that apply to the request.
|
||||||
*
|
*
|
||||||
|
|
@ -28,7 +40,11 @@ class StoreUserRequest extends FormRequest
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => 'required|string|min:3|max:255',
|
'name' => 'required|string|min:3|max:255',
|
||||||
'email' => 'email|required|unique:users,email',
|
'email' => [
|
||||||
|
'email',
|
||||||
|
'required',
|
||||||
|
Rule::unique('users', 'email')->whereNull('deleted_at')
|
||||||
|
],
|
||||||
'role' => [
|
'role' => [
|
||||||
'required',
|
'required',
|
||||||
Rule::in(collect(RoleEnum::cases())->pluck('value')->all()),
|
Rule::in(collect(RoleEnum::cases())->pluck('value')->all()),
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ class UpdateUserRequest extends StoreUserRequest
|
||||||
{
|
{
|
||||||
return array_merge(parent::rules(), [
|
return array_merge(parent::rules(), [
|
||||||
'email' => 'email|required|unique:users,email,' . $this->route('user')->id . ',id',
|
'email' => 'email|required|unique:users,email,' . $this->route('user')->id . ',id',
|
||||||
|
'gitlab_id' => 'nullable|integer|unique:users,gitlab_id,' . $this->route('user')->id . ',id'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
117
app/Jobs/ExportTicketsState.php
Normal file
117
app/Jobs/ExportTicketsState.php
Normal file
|
|
@ -0,0 +1,117 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Enums\Tickets\TicketStatusEnum;
|
||||||
|
use App\Models\Site;
|
||||||
|
use App\Models\Ticket;
|
||||||
|
use App\Notifications\ExportTicketsStateNotification;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Notification;
|
||||||
|
|
||||||
|
class ExportTicketsState implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CSV File headers
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $header = [
|
||||||
|
"Priorité service",
|
||||||
|
"Site",
|
||||||
|
"Numéro de ticket",
|
||||||
|
"Priorité",
|
||||||
|
"Date de MEP souhaitée",
|
||||||
|
"Type de ticket",
|
||||||
|
"Titre du ticket",
|
||||||
|
"Statut du ticket",
|
||||||
|
"Chef de projet",
|
||||||
|
"Utilisateur assigné",
|
||||||
|
"Date de dernière activité",
|
||||||
|
"Date de création",
|
||||||
|
"Lien vers le ticket",
|
||||||
|
"Lien vers l'issue GitLab"
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
// L'ordre commence à 0 et reprendra à 1 pour chaque site.
|
||||||
|
$order = 0;
|
||||||
|
// Dernier site traité.
|
||||||
|
$lastSiteId = null;
|
||||||
|
// Insertion de la ligne d'en-têtes.
|
||||||
|
$csvlines[] = $this->header;
|
||||||
|
|
||||||
|
// Récupération des tickets.
|
||||||
|
Ticket::query()
|
||||||
|
->whereNotIn(
|
||||||
|
'status',
|
||||||
|
[TicketStatusEnum::archived, TicketStatusEnum::production]
|
||||||
|
)
|
||||||
|
->orderBy(Site::select('name')
|
||||||
|
->whereColumn('sites.id', 'tickets.site_id'))
|
||||||
|
->orderBy('order')->get()->each(function (Ticket $ticket) use (&$csvlines, &$lastSiteId, &$order) {
|
||||||
|
$csvlines[] = [
|
||||||
|
"",
|
||||||
|
$ticket->site->name,
|
||||||
|
$ticket->id,
|
||||||
|
$lastSiteId === $ticket->site_id ? $order + 1 : 1,
|
||||||
|
$ticket->date_mep?->format('d-m-Y') ?? 'No MEP Date',
|
||||||
|
$ticket->type->label(),
|
||||||
|
$ticket->title,
|
||||||
|
$ticket->status->label(),
|
||||||
|
$ticket->projectManager->name ?? 'No PM',
|
||||||
|
$ticket->assignedUser()->name ?? 'No Assigned User',
|
||||||
|
Carbon::create($ticket->getRawOriginal('last_activity'))->format('d-m-Y H:i:s'),
|
||||||
|
$ticket->created_at->format('d-m-Y H:i:s'),
|
||||||
|
route('bo.ticket.show', $ticket->id),
|
||||||
|
$ticket->gitlab_issue ?? 'No GitLab Issue'
|
||||||
|
];
|
||||||
|
|
||||||
|
$order = $lastSiteId === $ticket->site_id ? $order + 1 : 1;
|
||||||
|
$lastSiteId = $ticket->site_id;
|
||||||
|
});
|
||||||
|
|
||||||
|
Notification::route('mail', config('mail.MAIL_ADMIN'))
|
||||||
|
->notify(new ExportTicketsStateNotification($this->array2csv($csvlines, ";")));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* converts an array to a csv stream
|
||||||
|
*
|
||||||
|
* @param array $data
|
||||||
|
* @param string $delimiter
|
||||||
|
* @param string $enclosure
|
||||||
|
* @param string $escape_char
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function array2csv(
|
||||||
|
array $data,
|
||||||
|
string $delimiter = ',',
|
||||||
|
string $enclosure = '"',
|
||||||
|
string $escape_char = "\\"
|
||||||
|
) {
|
||||||
|
$f = fopen('php://memory', 'r+');
|
||||||
|
|
||||||
|
// UTF-8 BOM.
|
||||||
|
$BOM = "\xEF\xBB\xBF";
|
||||||
|
fwrite($f, $BOM);
|
||||||
|
|
||||||
|
foreach ($data as $item) {
|
||||||
|
fputcsv($f, $item, $delimiter, $enclosure, $escape_char);
|
||||||
|
}
|
||||||
|
rewind($f);
|
||||||
|
return stream_get_contents($f);
|
||||||
|
}
|
||||||
|
}
|
||||||
85
app/Jobs/UpdateIssueLabels.php
Normal file
85
app/Jobs/UpdateIssueLabels.php
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Models\Ticket;
|
||||||
|
use App\Enums\Tickets\TicketStatusEnum;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
use App\Traits\Controllers\HasGitlabIssue;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use App\Http\Requests\Bo\ChangeTicketStatus;
|
||||||
|
|
||||||
|
class UpdateIssueLabels implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
use HasGitlabIssue;
|
||||||
|
|
||||||
|
/** @var Ticket */
|
||||||
|
protected $ticket;
|
||||||
|
|
||||||
|
/** @var requestStatus */
|
||||||
|
protected $requestStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new job instance.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Ticket $ticket
|
||||||
|
* @param string $request
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Ticket $ticket, string $requestStatus)
|
||||||
|
{
|
||||||
|
$this->ticket = $ticket;
|
||||||
|
$this->requestStatus = $requestStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the job.
|
||||||
|
*/
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
$oldStatus = $this->ticket->status;
|
||||||
|
$requestStatus = (int) $this->requestStatus;
|
||||||
|
$gitlabIssue = $this->getGitlabIssue($this->ticket->site->gitlab_project_id, $this->ticket->gitlab_issue);
|
||||||
|
|
||||||
|
$issueLabels = $gitlabIssue['labels'];
|
||||||
|
|
||||||
|
if ($oldStatus === TicketStatusEnum::waiting && $requestStatus !== TicketStatusEnum::waiting->value) {
|
||||||
|
$issueLabels = array_values(array_diff($issueLabels, ['g-wait']));
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($requestStatus) {
|
||||||
|
case TicketStatusEnum::takenInAccount->value:
|
||||||
|
$newLabels = ['g-to-dispatch'];
|
||||||
|
$updatedLabels = array_unique(array_merge($issueLabels, $newLabels));
|
||||||
|
|
||||||
|
$updatedIssue = $this->updateGitlabIssueLabels($gitlabIssue['project_id'], $gitlabIssue['iid'], $updatedLabels);
|
||||||
|
break;
|
||||||
|
case TicketStatusEnum::waiting->value:
|
||||||
|
$newLabels = ['g-wait'];
|
||||||
|
$updatedLabels = array_unique(array_merge($issueLabels, $newLabels));
|
||||||
|
|
||||||
|
$updatedIssue = $this->updateGitlabIssueLabels($gitlabIssue['project_id'], $gitlabIssue['iid'], $updatedLabels);
|
||||||
|
break;
|
||||||
|
case TicketStatusEnum::waitingValidation->value:
|
||||||
|
$removeLabels = ['g-to-estimate'];
|
||||||
|
$updatedLabels = array_diff($issueLabels, $removeLabels);
|
||||||
|
|
||||||
|
$updatedIssue = $this->updateGitlabIssueLabels($gitlabIssue['project_id'], $gitlabIssue['iid'], $updatedLabels);
|
||||||
|
break;
|
||||||
|
case TicketStatusEnum::recetteValidated->value:
|
||||||
|
$newLabels = ['g-re7-ok', 'to-prod'];
|
||||||
|
$updatedLabels = array_unique(array_merge($issueLabels, $newLabels));
|
||||||
|
|
||||||
|
$updatedIssue = $this->updateGitlabIssueLabels($gitlabIssue['project_id'], $gitlabIssue['iid'], $updatedLabels);
|
||||||
|
break;
|
||||||
|
case TicketStatusEnum::archived->value:
|
||||||
|
$updatedIssue = $this->closeGitlabIssue($gitlabIssue['project_id'], $gitlabIssue['iid'], $issueLabels);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$updatedIssue = $this->updateGitlabIssueLabels($gitlabIssue['project_id'], $gitlabIssue['iid'], $issueLabels);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
75
app/Listeners/CreateTicketAutomatically.php
Normal file
75
app/Listeners/CreateTicketAutomatically.php
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use App\Events\BrevoWebhookCallReceived;
|
||||||
|
use App\Events\TicketCreated;
|
||||||
|
use App\Mail\NewTicket;
|
||||||
|
use App\Repositories\SiteRepository;
|
||||||
|
use App\Services\AutomaticTicketCreator;
|
||||||
|
use Domain\Models\ValueObjects\Email;
|
||||||
|
use Illuminate\Contracts\Events\Dispatcher;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Support\Facades\Config;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
// NOTE: this should be queued in order to be eventually retried or at least keep info data.
|
||||||
|
class CreateTicketAutomatically implements ShouldQueue
|
||||||
|
{
|
||||||
|
private const string SITE_NAME_WHERE_TO_CREATE_TICKET = 'Mailing en masse';
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
private readonly LoggerInterface $logger,
|
||||||
|
private readonly AutomaticTicketCreator $automaticTicketCreator,
|
||||||
|
private readonly SiteRepository $siteRepository,
|
||||||
|
private readonly Dispatcher $dispatcher
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function handle(BrevoWebhookCallReceived $event): void
|
||||||
|
{
|
||||||
|
$fromEmail = $event->from;
|
||||||
|
$toEmail = $event->to;
|
||||||
|
$htmlRawContent = $event->htmlRawContent;
|
||||||
|
|
||||||
|
$this->logger->info('Received a ticket creation event from brevo');
|
||||||
|
$this->logger->debug(
|
||||||
|
'Payload for ticket creation form brevo',
|
||||||
|
[
|
||||||
|
'from_email' => $fromEmail->value,
|
||||||
|
'to_email' => $toEmail->value,
|
||||||
|
'html_raw_content' => base64_encode($htmlRawContent)
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$siteReceivingTickets = $this->siteRepository->findByName(self::SITE_NAME_WHERE_TO_CREATE_TICKET);
|
||||||
|
|
||||||
|
if ($siteReceivingTickets === null) {
|
||||||
|
throw new \UnexpectedValueException(
|
||||||
|
'No site found with name \'' .
|
||||||
|
self::SITE_NAME_WHERE_TO_CREATE_TICKET . '\''
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$projectManager = $siteReceivingTickets->projectManager()->first();
|
||||||
|
|
||||||
|
if ($projectManager === null) {
|
||||||
|
throw new \UnexpectedValueException(
|
||||||
|
'No project manager found for site \'' .
|
||||||
|
self::SITE_NAME_WHERE_TO_CREATE_TICKET . '\''
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$ticket = $this->automaticTicketCreator->createTicket(
|
||||||
|
$siteReceivingTickets,
|
||||||
|
$projectManager,
|
||||||
|
$htmlRawContent,
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->dispatcher->dispatch(new TicketCreated(
|
||||||
|
siteReceivingTicket: $siteReceivingTickets,
|
||||||
|
ticket: $ticket,
|
||||||
|
byUserName: $fromEmail->value
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,21 +3,51 @@
|
||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
use App\Events\NotifyAdmin;
|
use App\Events\NotifyAdmin;
|
||||||
|
use App\Events\TicketCreated;
|
||||||
|
use App\Mail\NewTicket;
|
||||||
use App\Mail\TicketUpdate;
|
use App\Mail\TicketUpdate;
|
||||||
|
use Domain\Models\ValueObjects\Email;
|
||||||
|
use Illuminate\Support\Facades\Config;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
class SendNotificationMailToAdmin
|
class SendNotificationMailToAdmin
|
||||||
{
|
{
|
||||||
|
private readonly Email $mailAdmin;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->mailAdmin = new Email(
|
||||||
|
Config::string('mail.MAIL_ADMIN')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the event.
|
* Handle the event.
|
||||||
*
|
*
|
||||||
* @param \App\Events\NotifyAdmin $event
|
* @param \App\Events\NotifyAdmin $event
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function handle(NotifyAdmin $event)
|
public function handle(NotifyAdmin | TicketCreated $event)
|
||||||
{
|
{
|
||||||
|
if ($event instanceof NotifyAdmin) {
|
||||||
$ticket = $event->ticket;
|
$ticket = $event->ticket;
|
||||||
Mail::to(config('mail.MAIL_ADMIN'))
|
Mail::to($this->mailAdmin->value)
|
||||||
->send(new TicketUpdate($ticket, $event->corpsMaj));
|
->send(new TicketUpdate($ticket, $event->corpsMaj));
|
||||||
}
|
}
|
||||||
|
if ($event instanceof TicketCreated) {
|
||||||
|
$ticket = $event->ticket;
|
||||||
|
$siteReceivingTickets = $event->siteReceivingTicket;
|
||||||
|
$userName = $event->byUserName;
|
||||||
|
|
||||||
|
Mail::to($this->mailAdmin->value)
|
||||||
|
->send(new NewTicket(
|
||||||
|
ticketId: $ticket->id,
|
||||||
|
siteName: $siteReceivingTickets->name,
|
||||||
|
ticketTitle: $ticket->title,
|
||||||
|
ticketType: $ticket->type,
|
||||||
|
userName: $userName,
|
||||||
|
ticketDescription: $ticket->text,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,29 +2,23 @@
|
||||||
|
|
||||||
namespace App\Mail;
|
namespace App\Mail;
|
||||||
|
|
||||||
use App\Models\Ticket;
|
use App\Enums\Tickets\TicketTypeEnum;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Mail\Mailable;
|
use Illuminate\Mail\Mailable;
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
|
|
||||||
class NewTicket extends Mailable
|
class NewTicket extends Mailable implements ShouldQueue
|
||||||
{
|
{
|
||||||
use Queueable;
|
use Queueable;
|
||||||
use SerializesModels;
|
|
||||||
|
|
||||||
/** @var \App\Models\Ticket */
|
public function __construct(
|
||||||
private $ticket;
|
private readonly int $ticketId,
|
||||||
|
private readonly string $siteName,
|
||||||
/**
|
private readonly string $ticketTitle,
|
||||||
* Create a new message instance.
|
private readonly TicketTypeEnum $ticketType,
|
||||||
*
|
private readonly string $userName,
|
||||||
* @param \App\Models\Ticket $ticket
|
private readonly string $ticketDescription,
|
||||||
* @return void
|
) {}
|
||||||
*/
|
|
||||||
public function __construct(Ticket $ticket)
|
|
||||||
{
|
|
||||||
$this->ticket = $ticket;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the message.
|
* Build the message.
|
||||||
|
|
@ -33,8 +27,14 @@ class NewTicket extends Mailable
|
||||||
*/
|
*/
|
||||||
public function build()
|
public function build()
|
||||||
{
|
{
|
||||||
$ticket = $this->ticket;
|
return $this->subject("[Support] Nouveau ticket n° {$this->ticketId} - {$this->ticketTitle}")
|
||||||
return $this->subject("[Support] Nouveau ticket n°" . $ticket->id)
|
->view('emails.new-ticket', [
|
||||||
->view('emails.new-ticket', compact('ticket'));
|
'ticketId' => $this->ticketId,
|
||||||
|
'siteName' => $this->siteName,
|
||||||
|
'ticketTitle' => $this->ticketTitle,
|
||||||
|
'ticketType' => $this->ticketType,
|
||||||
|
'userName' => $this->userName,
|
||||||
|
'ticketDescription' => $this->ticketDescription,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class TicketMention extends Mailable
|
||||||
{
|
{
|
||||||
$ticket = $this->ticket;
|
$ticket = $this->ticket;
|
||||||
$corpsMaj = ToolboxHelper::plainToHtml($this->corpsMaj);
|
$corpsMaj = ToolboxHelper::plainToHtml($this->corpsMaj);
|
||||||
return $this->subject("[Support] Vous avez été mentionné sur le ticket n° $ticket->id")
|
return $this->subject("[Support] Vous avez été mentionné sur le ticket n°$ticket->id - $ticket->title")
|
||||||
->view('emails.ticket-mention', compact('ticket', 'corpsMaj'));
|
->view('emails.ticket-mention', compact('ticket', 'corpsMaj'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class TicketUpdate extends Mailable
|
||||||
{
|
{
|
||||||
$ticket = $this->ticket;
|
$ticket = $this->ticket;
|
||||||
$corpsMaj = \html_entity_decode(ToolboxHelper::plainToHtml($this->corpsMaj));
|
$corpsMaj = \html_entity_decode(ToolboxHelper::plainToHtml($this->corpsMaj));
|
||||||
return $this->subject("[Support][{$ticket->site->name}] Ticket n°$ticket->id")
|
return $this->subject("[Support][{$ticket->site->name}] Ticket n°$ticket->id - $ticket->title")
|
||||||
->view('emails.ticket-update', compact('ticket', 'corpsMaj'));
|
->view('emails.ticket-update', compact('ticket', 'corpsMaj'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,13 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property string $name
|
* @property int $id Doit correspondre aux ids marques de la CRM
|
||||||
|
* @property string $name Nom de la marque
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, Account> $accounts
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Site> $sites
|
||||||
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Brand extends Model
|
class Brand extends Model
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,14 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @property int $id
|
||||||
* @property string $name
|
* @property string $name
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Invoice> $invoices
|
||||||
|
* @property-read mixed $value
|
||||||
|
* @method static \Database\Factories\CompanyFactory factory($count = null, $state = [])
|
||||||
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Company extends Model
|
class Company extends Model
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,16 @@ use App\Models\Brand;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property string $label
|
* @property int $id
|
||||||
* @property AccountTypeEnum $type
|
* @property AccountTypeEnum $type Enum Credit\AccountTypeEnum
|
||||||
* @property integer $balance
|
* @property string $label Custom account label
|
||||||
* @property Brand $brand_id
|
* @property float $balance Account balance
|
||||||
|
* @property int $brand_id
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @property-read Brand $brand
|
||||||
|
* @property-read \App\Models\Credit\CreditLog|null $creditlogs
|
||||||
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Account extends Model
|
class Account extends Model
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,15 @@ use App\Enums\Credit\BalanceOperationEnum;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property BalanceOperationEnum $type
|
* @property int $id
|
||||||
* @property double $amount
|
* @property BalanceOperationEnum $type Enum Credit\BalanceOperationEnum
|
||||||
* @property Account $credit_account_id
|
* @property float $amount Montant de l'opération
|
||||||
* @property date $created_at
|
* @property int $credit_account_id
|
||||||
|
* @property string $created_at
|
||||||
|
* @property-read \App\Models\Credit\Account $account
|
||||||
|
* @property-read \App\Models\Credit\EstimationLog|null $pivot
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Credit\Estimation> $estimation
|
||||||
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class CreditLog extends Model
|
class CreditLog extends Model
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,22 @@ use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property EstimationStatusEnum $status Enum Credit\EstimationStatusEnum
|
||||||
|
* @property numeric $amount Estimation amount
|
||||||
|
* @property int $ticket_id
|
||||||
|
* @property int $credit_account_id The account to debit.
|
||||||
|
* @property int $estimator_id The person who has done the estimate.
|
||||||
|
* @property int|null $validator_id The person who has validate the estimate.
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @property-read \App\Models\Credit\Account $account
|
||||||
|
* @property-read User|null $estimator
|
||||||
|
* @property-read Ticket|null $ticket
|
||||||
|
* @property-read User|null $validator
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
class Estimation extends Model
|
class Estimation extends Model
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,14 @@ namespace App\Models\Credit;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property int $credit_log_id
|
||||||
|
* @property int $credit_estimation_id
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
class EstimationLog extends Pivot
|
class EstimationLog extends Pivot
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
60
app/Models/GitlabIssues.php
Normal file
60
app/Models/GitlabIssues.php
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property string $title Gitlab issue title
|
||||||
|
* @property string $url Gitlab URL
|
||||||
|
* @property int $estimate_time Gitlab issue estimate time in seconds
|
||||||
|
* @property int $spent_time Gitlab issue spent time in seconds
|
||||||
|
* @property int $is_closed Gitlab issue status
|
||||||
|
* @property int $gitlab_id Gitlab issue id
|
||||||
|
* @property int $gitlab_iid Gitlab issue iid in project
|
||||||
|
* @property int|null $milestone_iid Gitlab issue linked milestone iid in project
|
||||||
|
* @property int $gitlab_project_id Gitlab project id
|
||||||
|
* @property string $g_created_at Gitlab issue created at
|
||||||
|
* @property string $g_updated_at Gitlab issue updated at
|
||||||
|
* @property string|null $g_closed_at Gitlab issue closed at
|
||||||
|
* @property string|null $g_due_date Gitlab issue due date
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\GitlabLabels> $gitlabLabels
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
class GitlabIssues extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Fillable array model
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'title',
|
||||||
|
'url',
|
||||||
|
'estimate_time',
|
||||||
|
'spent_time',
|
||||||
|
'is_closed',
|
||||||
|
'gitlab_id',
|
||||||
|
'gitlab_iid',
|
||||||
|
'milestone_iid',
|
||||||
|
'gitlab_project_id',
|
||||||
|
'g_created_at',
|
||||||
|
'g_updated_at',
|
||||||
|
'g_closed_at',
|
||||||
|
'g_due_date'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gitlab Labels relationship
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||||
|
*/
|
||||||
|
public function gitlabLabels()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(GitlabLabels::class, 'gitlab_issues_labels', 'issue_id', 'label_id')
|
||||||
|
->withTimestamps();
|
||||||
|
}
|
||||||
|
}
|
||||||
38
app/Models/GitlabLabels.php
Normal file
38
app/Models/GitlabLabels.php
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property string $name Label name
|
||||||
|
* @property int $gitlab_id Label Gitlab id
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\GitlabIssues> $issues
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
class GitlabLabels extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Fillable array model
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'gitlab_id'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gitlab Issues relationship
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||||
|
*/
|
||||||
|
public function issues()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(GitlabIssues::class, 'gitlab_issues_labels', 'label_id', 'issue_id')
|
||||||
|
->withTimestamps();
|
||||||
|
}
|
||||||
|
}
|
||||||
42
app/Models/GitlabMilestones.php
Normal file
42
app/Models/GitlabMilestones.php
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property string $title Milestone title
|
||||||
|
* @property string $url Gitlab URL
|
||||||
|
* @property int $is_closed Gitlab milestone status
|
||||||
|
* @property int $gitlab_id Gitlab milestone id
|
||||||
|
* @property int $gitlab_iid Gitlab milestone iid in project
|
||||||
|
* @property int $gitlab_project_id Gitlab project id
|
||||||
|
* @property string $g_created_at Gitlab milestone created at
|
||||||
|
* @property string $g_updated_at Gitlab milestone updated at
|
||||||
|
* @property string|null $g_start_date Gitlab milestone start date
|
||||||
|
* @property string|null $g_due_date Gitlab milestone due date
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
class GitlabMilestones extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Fillable array model
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'title',
|
||||||
|
'url',
|
||||||
|
'is_closed',
|
||||||
|
'gitlab_id',
|
||||||
|
'gitlab_iid',
|
||||||
|
'gitlab_project_id',
|
||||||
|
'g_created_at',
|
||||||
|
'g_updated_at',
|
||||||
|
'g_start_date',
|
||||||
|
'g_due_date'
|
||||||
|
];
|
||||||
|
}
|
||||||
30
app/Models/GitlabProjects.php
Normal file
30
app/Models/GitlabProjects.php
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property string $name Gitlab project name
|
||||||
|
* @property string $url Gitlab URL
|
||||||
|
* @property int $is_archived Gitlab archive status
|
||||||
|
* @property int $gitlab_id Gitlab unique ID
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
|
class GitlabProjects extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Fillable array model
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'url',
|
||||||
|
'is_archived',
|
||||||
|
'gitlab_id'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -7,9 +7,13 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @property int $id
|
||||||
* @property string $title
|
* @property string $title
|
||||||
* @property string $message
|
* @property string $message
|
||||||
* @property InfoColorsEnum $type
|
* @property InfoColorsEnum $type Defined by the InfoColorsEnum enum.
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Information extends Model
|
class Information extends Model
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,28 +10,42 @@ use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Mccarlosen\LaravelMpdf\LaravelMpdf;
|
use Mccarlosen\LaravelMpdf\LaravelMpdf;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property string $ref
|
* @property int $id
|
||||||
* @property string $firstname
|
* @property string $ref The invoice reference built as YYYY_MM_INCREMENT_USER. INCREMENT is the N invoice of the month. USER is the first two letters of the user who last edited the invoice. This field has to generated only on create.
|
||||||
* @property string $lastname
|
* @property string $firstname The person to which the invoice is addressed.
|
||||||
* @property string $object
|
* @property string $lastname The person to which the invoice is addressed.
|
||||||
* @property string $tasks
|
* @property string $object The invoice object.
|
||||||
* @property double $total
|
* @property array<array-key, mixed> $tasks A JSON object, each line has to be contructed using these fields description, days, type Invoices\TaskTypeEnum, amount
|
||||||
* @property double $total_days
|
* @property float $total The total calculated using all tasks
|
||||||
* @property string $comment
|
* @property float $total_days The total days calculated using all tasks
|
||||||
* @property boolean $show_days
|
* @property string|null $comment Any comment joined to the invoice
|
||||||
* @property date $signed_date
|
* @property int $show_days Show days on the printed invoice
|
||||||
* @property date $sent_client_date
|
* @property Carbon|null $signed_date The date the invoice was signed
|
||||||
* @property date $sent_accounting_date
|
* @property Carbon|null $sent_client_date The date the invoice was send to the client
|
||||||
* @property Site $site_id
|
* @property Carbon|null $sent_accounting_date The date the invoice was send to the client
|
||||||
* @property Company $company_id
|
* @property int $site_id
|
||||||
* @property Company $invoiced_to_id
|
* @property int $company_id
|
||||||
* @property InvoiceStatusEnum $status
|
* @property int $invoiced_to_id
|
||||||
|
* @property InvoiceStatusEnum $status Status of the invoice.
|
||||||
|
* @property Carbon|null $created_at
|
||||||
|
* @property Carbon|null $updated_at
|
||||||
|
* @property Carbon|null $deleted_at
|
||||||
|
* @property-read \App\Models\Company $company
|
||||||
|
* @property-read \App\Models\Company $companyInvoiced
|
||||||
|
* @property-read \App\Models\Site|null $site
|
||||||
|
* @method static \Database\Factories\InvoiceFactory factory($count = null, $state = [])
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Invoice onlyTrashed()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Invoice withTrashed(bool $withTrashed = true)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Invoice withoutTrashed()
|
||||||
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Invoice extends Model
|
class Invoice extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are fillable.
|
* The attributes that are fillable.
|
||||||
|
|
@ -109,6 +123,10 @@ class Invoice extends Model
|
||||||
->reduce(function ($previous, array $task) {
|
->reduce(function ($previous, array $task) {
|
||||||
return \floatval($task['amount']) + \floatval($previous);
|
return \floatval($task['amount']) + \floatval($previous);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if($model->sent_accounting_date && $model->status !== InvoiceStatusEnum::archived->value) {
|
||||||
|
$model->status = InvoiceStatusEnum::archived;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
static::deleting(function () {
|
static::deleting(function () {
|
||||||
throw new \Error('Action impossible');
|
throw new \Error('Action impossible');
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,14 @@ use App\Lib\Helpers\ToolboxHelper;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property string $name Un ou deux mot désignant le label
|
||||||
|
* @property string $color Cast HTML color
|
||||||
|
* @property-read \App\Models\Site|null $site
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Ticket> $tickets
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
class Label extends Model
|
class Label extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,20 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @property string $message The message content.
|
|
||||||
* @property \App\Enums\MessageTypeEnum $type The message is not visible for clients.
|
|
||||||
* @property string $file The message joined file path.
|
|
||||||
*
|
|
||||||
* @package App\Models
|
* @package App\Models
|
||||||
|
* @property int $id
|
||||||
|
* @property int $ticket_id
|
||||||
|
* @property int|null $user_id
|
||||||
|
* @property string $message
|
||||||
|
* @property MessageTypeEnum $type Message Type defined by an enum.
|
||||||
|
* @property string|null $file
|
||||||
|
* @property string|null $file2 Pièce jointes n°2
|
||||||
|
* @property string|null $file3 Pièce jointes n°3
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @property-read \App\Models\Ticket|null $ticket
|
||||||
|
* @property-read \App\Models\User|null $user
|
||||||
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Message extends Model
|
class Message extends Model
|
||||||
{
|
{
|
||||||
|
|
@ -96,15 +104,10 @@ class Message extends Model
|
||||||
}
|
}
|
||||||
// ? Is message author is admin ?
|
// ? Is message author is admin ?
|
||||||
if ($messageUser->isAdmin()) {
|
if ($messageUser->isAdmin()) {
|
||||||
// Url: https://supportweb.ldc.fr/ticket/583/message/create.
|
|
||||||
// SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '583-8' for key 'PRIMARY'
|
|
||||||
// $ticket->subscriptions()->attach($messageUser);
|
|
||||||
// Add subscription.
|
// Add subscription.
|
||||||
if (!$messageUser->subscriptions()->find($ticket->id)) {
|
$messageUser->subscriptions()->syncWithoutDetaching([$ticket->id]);
|
||||||
$messageUser->subscriptions()->attach($ticket->id);
|
|
||||||
\session()->flash('info', trans('Vous avez été inscrit.'));
|
\session()->flash('info', trans('Vous avez été inscrit.'));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// * Send mail to other subscribed users
|
// * Send mail to other subscribed users
|
||||||
event(new NotifySubscriptions(
|
event(new NotifySubscriptions(
|
||||||
$message->ticket,
|
$message->ticket,
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,12 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @property int $id
|
||||||
* @property string $name
|
* @property string $name
|
||||||
* @property double $amount
|
* @property float $amount The cost per day
|
||||||
|
* @property bool $published
|
||||||
|
* @method static \Database\Factories\PackageFactory factory($count = null, $state = [])
|
||||||
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Package extends Model
|
class Package extends Model
|
||||||
{
|
{
|
||||||
|
|
@ -28,5 +32,16 @@ class Package extends Model
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
'amount',
|
'amount',
|
||||||
|
'published'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be cast.
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
protected $casts = [
|
||||||
|
'published' => 'boolean',
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Models;
|
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @property string $name
|
|
||||||
* @property Site $site_id
|
|
||||||
*/
|
|
||||||
class Project extends Model
|
|
||||||
{
|
|
||||||
use HasFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The attributes that are mass assignable.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected $fillable = [
|
|
||||||
'name',
|
|
||||||
'site_id'
|
|
||||||
];
|
|
||||||
|
|
||||||
// * RELATIONSHIPS.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BelongsTo Site
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
||||||
*/
|
|
||||||
public function site()
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Site::class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -10,11 +10,26 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @property int $id
|
||||||
* @property string $name
|
* @property string $name
|
||||||
* @property string $url_re7
|
* @property string|null $url_re7
|
||||||
* @property string $url_prod
|
* @property string|null $url_prod
|
||||||
* @property integer $gitlab_project_id
|
* @property int|null $gitlab_project_id
|
||||||
* @property Brand $brand_id
|
* @property int|null $brand_id Relation is nullable, since not all site would be affiliate with a brand.
|
||||||
|
* @property int|null $project_manager_id Project manager relationship
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||||
|
* @property-read \App\Models\Brand|null $brand
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Invoice> $invoices
|
||||||
|
* @property-read \App\Models\User|null $projectManager
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Ticket> $tickets
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $users
|
||||||
|
* @property-read mixed $value
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Site onlyTrashed()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Site withTrashed(bool $withTrashed = true)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Site withoutTrashed()
|
||||||
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class Site extends Model
|
class Site extends Model
|
||||||
{
|
{
|
||||||
|
|
@ -57,6 +72,10 @@ class Site extends Model
|
||||||
static::updating(function (self $model) {
|
static::updating(function (self $model) {
|
||||||
self::manageFields($model);
|
self::manageFields($model);
|
||||||
});
|
});
|
||||||
|
static::deleted(function ($site) {
|
||||||
|
$site->invoices()->delete();
|
||||||
|
$site->tickets()->delete();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// * METHODS
|
// * METHODS
|
||||||
|
|
@ -84,7 +103,7 @@ class Site extends Model
|
||||||
* HasMany Message relation
|
* HasMany Message relation
|
||||||
* The users of type client that would have access to this site tickets
|
* The users of type client that would have access to this site tickets
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
* @return \Illuminate\Database\Eloquent\Relations\belongsToMany
|
||||||
*/
|
*/
|
||||||
public function users()
|
public function users()
|
||||||
{
|
{
|
||||||
|
|
@ -101,6 +120,16 @@ class Site extends Model
|
||||||
return $this->hasMany(Ticket::class, 'site_id');
|
return $this->hasMany(Ticket::class, 'site_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HasMany Invoices relation
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||||
|
*/
|
||||||
|
public function invoices()
|
||||||
|
{
|
||||||
|
return $this->hasMany(Invoice::class, 'site_id');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BelongsTo Brand relation
|
* BelongsTo Brand relation
|
||||||
*
|
*
|
||||||
|
|
@ -122,16 +151,6 @@ class Site extends Model
|
||||||
return $this->belongsTo(User::class, 'project_manager_id');
|
return $this->belongsTo(User::class, 'project_manager_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* BelongsTo Project relation
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
||||||
*/
|
|
||||||
public function project()
|
|
||||||
{
|
|
||||||
return $this->belongsTo(Project::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return value attribute for belongsto search component
|
* Return value attribute for belongsto search component
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,11 @@ namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Relations\Pivot;
|
use Illuminate\Database\Eloquent\Relations\Pivot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $site_id
|
||||||
|
* @property int $user_id
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
class SiteUser extends Pivot
|
class SiteUser extends Pivot
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,26 +2,68 @@
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Enums\Users\RoleEnum;
|
|
||||||
use App\Enums\Tickets\TicketStatusEnum;
|
|
||||||
use App\Enums\Tickets\TicketTypeEnum;
|
|
||||||
use App\Events\NotifyAdmin;
|
use App\Events\NotifyAdmin;
|
||||||
use App\Events\NotifySubscriptions;
|
|
||||||
use App\Events\TicketStatusChanged;
|
|
||||||
use App\Jobs\SendTicketMentionMail;
|
|
||||||
use App\Mail\TicketMention;
|
use App\Mail\TicketMention;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use App\Models\GitlabIssues;
|
||||||
|
use App\Enums\Users\RoleEnum;
|
||||||
use App\Models\Credit\Account;
|
use App\Models\Credit\Account;
|
||||||
use App\Models\Credit\Estimation;
|
use App\Models\Credit\Estimation;
|
||||||
use App\Models\Ticket\TicketType;
|
use App\Models\Ticket\TicketType;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Str;
|
use App\Events\NotifySubscriptions;
|
||||||
|
use App\Events\TicketStatusChanged;
|
||||||
|
use App\Jobs\SendTicketMentionMail;
|
||||||
|
use App\Enums\Tickets\TicketTypeEnum;
|
||||||
|
use App\Enums\Tickets\TicketStatusEnum;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use GrahamCampbell\GitLab\Facades\GitLab;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property int $created_by
|
||||||
|
* @property int|null $assigned_to La personne a qui est assigné le ticket.
|
||||||
|
* @property int $site_id
|
||||||
|
* @property TicketTypeEnum $type
|
||||||
|
* @property string $title Titre du ticket
|
||||||
|
* @property string $text
|
||||||
|
* @property string|null $file
|
||||||
|
* @property string|null $file2
|
||||||
|
* @property string|null $file3 Pièce jointes n°3
|
||||||
|
* @property string|null $file4 Pièce jointes n°4
|
||||||
|
* @property string|null $file5 Pièce jointes n°5
|
||||||
|
* @property TicketStatusEnum $status
|
||||||
|
* @property int $order Ticket order.
|
||||||
|
* @property bool $is_internal
|
||||||
|
* @property string|null $gitlab_issue URL de l'issue Gitlab
|
||||||
|
* @property \Illuminate\Support\Carbon|null $date_mep Date MEP souhaitée
|
||||||
|
* @property int $last_activity Last activity on the ticket.
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||||
|
* @property-read \App\Models\User|null $assignedUser
|
||||||
|
* @property-read Estimation|null $estimation
|
||||||
|
* @property-read string $full_name
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Label> $labels
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, Ticket> $linkedTickets
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Message> $messages
|
||||||
|
* @property-read \App\Models\User|null $projectManager
|
||||||
|
* @property-read \App\Models\Site|null $site
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $subscriptions
|
||||||
|
* @property-read TicketType|null $ticketType
|
||||||
|
* @property-read \App\Models\User|null $user
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Ticket onlyTrashed()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Ticket withTrashed(bool $withTrashed = true)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|Ticket withoutTrashed()
|
||||||
|
* @mixin \Eloquent
|
||||||
|
*/
|
||||||
class Ticket extends Model
|
class Ticket extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes that are fillable.
|
* The attributes that are fillable.
|
||||||
|
|
@ -61,8 +103,8 @@ class Ticket extends Model
|
||||||
protected static function booted()
|
protected static function booted()
|
||||||
{
|
{
|
||||||
static::creating(function (Ticket $ticket) {
|
static::creating(function (Ticket $ticket) {
|
||||||
// If bug force the ticket status on new. All the others are estimateTodo.
|
|
||||||
self::setOrder($ticket);
|
self::setOrder($ticket);
|
||||||
|
// If bug force the ticket status on new. All the others are estimateTodo.
|
||||||
if ($ticket->type->equals(TicketTypeEnum::bug)) {
|
if ($ticket->type->equals(TicketTypeEnum::bug)) {
|
||||||
$ticket->status = TicketStatusEnum::new;
|
$ticket->status = TicketStatusEnum::new;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -70,24 +112,23 @@ class Ticket extends Model
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
static::updating(function (Ticket $ticket) {
|
static::updating(function (Ticket $ticket) {
|
||||||
if (!$ticket->original['status'] !== $ticket->status->value && $ticket->original['order'] === $ticket->order) {
|
if (
|
||||||
|
!$ticket->original['status'] !== $ticket->status->value && $ticket->original['order'] === $ticket->order
|
||||||
|
) {
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
event(new TicketStatusChanged(
|
event(new TicketStatusChanged(
|
||||||
$ticket,
|
$ticket,
|
||||||
TicketStatusEnum::make($ticket->original['status']),
|
TicketStatusEnum::make($ticket->original['status']),
|
||||||
auth()->user(),
|
$user,
|
||||||
null,
|
null,
|
||||||
false
|
false
|
||||||
));
|
));
|
||||||
event(new NotifySubscriptions($ticket, sprintf(
|
|
||||||
'<b>%s</b> a modifié le statut en <b>%s</b>',
|
$message = $user ? sprintf('<b>%s</b> a modifié le statut en <b>%s</b>', $user->name, $ticket->status->label()) : sprintf('Le statut a été modifié en <b>%s</b>', $ticket->status->label());
|
||||||
auth()->user()->name,
|
|
||||||
$ticket->status->label()
|
event(new NotifySubscriptions($ticket, $message));
|
||||||
)));
|
event(new NotifyAdmin($ticket, $message));
|
||||||
event(new NotifyAdmin($ticket, sprintf(
|
|
||||||
'<b>%s</b> a modifié le statut en <b>%s</b>',
|
|
||||||
auth()->user()->name,
|
|
||||||
$ticket->status->label()
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
if ($ticket->status->equals(TicketStatusEnum::archived)) {
|
if ($ticket->status->equals(TicketStatusEnum::archived)) {
|
||||||
self::setOrder($ticket, true);
|
self::setOrder($ticket, true);
|
||||||
|
|
@ -104,7 +145,18 @@ class Ticket extends Model
|
||||||
*/
|
*/
|
||||||
private static function setOrder(self $model, bool $isArchived = false): void
|
private static function setOrder(self $model, bool $isArchived = false): void
|
||||||
{
|
{
|
||||||
$model->order = \intval(self::query()->where('status', $isArchived ? '=' : '!=', TicketStatusEnum::archived)->max('order')) + 1;
|
$maxOrder = \intval(self::query()->where('status', '!=', TicketStatusEnum::archived)->max('order'));
|
||||||
|
if ($isArchived) {
|
||||||
|
$request = Ticket::query()
|
||||||
|
->where('site_id', $model->site_id)
|
||||||
|
->whereNot('status', TicketStatusEnum::archived)
|
||||||
|
->whereNot('id', $model->id)
|
||||||
|
->whereBetween('order', [$model->order, $maxOrder]);
|
||||||
|
$request->decrement('order', 1);
|
||||||
|
$model->order = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$model->order = $maxOrder + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -152,6 +204,17 @@ class Ticket extends Model
|
||||||
return $this->belongsTo(User::class, 'assigned_to');
|
return $this->belongsTo(User::class, 'assigned_to');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BelongsTo User relation
|
||||||
|
* The user that is in charge of the site linked to this ticket
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
|
*/
|
||||||
|
public function projectManager()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'project_manager_id');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HasMany Message relation
|
* HasMany Message relation
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,13 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property TicketTypeEnum $type
|
* @property int $id
|
||||||
* @property string $template
|
* @property TicketTypeEnum $type TicketType Enum
|
||||||
|
* @property string $template Le template du type de ticket
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @property-read \Illuminate\Database\Eloquent\Collection<int, Ticket> $tickets
|
||||||
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class TicketType extends Model
|
class TicketType extends Model
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,27 @@ use Illuminate\Support\Facades\Hash;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @property int $id
|
||||||
* @property string $name
|
* @property string $name
|
||||||
* @property string $email
|
* @property string $email
|
||||||
* @property string $password
|
* @property string $password
|
||||||
* @property string $remember_token
|
|
||||||
* @property RoleEnum $role
|
* @property RoleEnum $role
|
||||||
* @property Collection $sites
|
* @property string|null $remember_token
|
||||||
|
* @property int|null $gitlab_id ID du user Gitlab
|
||||||
|
* @property int|null $favourite_site_id
|
||||||
|
* @property \Illuminate\Support\Carbon|null $created_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $updated_at
|
||||||
|
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||||
|
* @property-read Collection<int, \App\Models\Message> $messages
|
||||||
|
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection<int, \Illuminate\Notifications\DatabaseNotification> $notifications
|
||||||
|
* @property-read Collection<int, \App\Models\Site> $sites
|
||||||
|
* @property-read Collection<int, \App\Models\Ticket> $subscriptions
|
||||||
|
* @property-read Collection<int, \App\Models\Ticket> $tickets
|
||||||
|
* @method static \Database\Factories\UserFactory factory($count = null, $state = [])
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User onlyTrashed()
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User withTrashed(bool $withTrashed = true)
|
||||||
|
* @method static \Illuminate\Database\Eloquent\Builder<static>|User withoutTrashed()
|
||||||
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class User extends Authenticatable
|
class User extends Authenticatable
|
||||||
{
|
{
|
||||||
|
|
@ -46,7 +61,8 @@ class User extends Authenticatable
|
||||||
'password',
|
'password',
|
||||||
'role',
|
'role',
|
||||||
'sites',
|
'sites',
|
||||||
'gitlab_id'
|
'gitlab_id',
|
||||||
|
'favourite_site_id'
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
60
app/Notifications/ExportTicketsStateNotification.php
Normal file
60
app/Notifications/ExportTicketsStateNotification.php
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
class ExportTicketsStateNotification extends Notification implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The CSV content to be sent.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private string $csvContent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new notification instance.
|
||||||
|
*
|
||||||
|
* @param string $csvContent The content of the CSV file to be sent.
|
||||||
|
*/
|
||||||
|
public function __construct(string $csvContent)
|
||||||
|
{
|
||||||
|
$this->csvContent = $csvContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the notification's delivery channels.
|
||||||
|
*
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public function via(): array
|
||||||
|
{
|
||||||
|
return ['mail'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mail representation of the notification.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||||
|
*/
|
||||||
|
public function toMail(): \Illuminate\Notifications\Messages\MailMessage
|
||||||
|
{
|
||||||
|
return (new MailMessage())
|
||||||
|
->subject(trans("Export de l'état des lieux des tickets"))
|
||||||
|
->line(trans("Vous trouverez ci-joint le fichier CSV contenant l'état des tickets."))
|
||||||
|
->attachData(
|
||||||
|
$this->csvContent,
|
||||||
|
sprintf('tickets_state_%s.csv', Carbon::now()->format('Y-m-d_H-i-s')),
|
||||||
|
[
|
||||||
|
'mime' => 'text/csv',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,7 +7,6 @@ use App\Enums\Tickets\TicketTypeEnum;
|
||||||
use App\Enums\Users\RoleEnum;
|
use App\Enums\Users\RoleEnum;
|
||||||
use App\Models\Ticket;
|
use App\Models\Ticket;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Error;
|
|
||||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||||
|
|
||||||
class TicketPolicy
|
class TicketPolicy
|
||||||
|
|
@ -284,7 +283,12 @@ class TicketPolicy
|
||||||
public function createGitlabIssue(User $user, Ticket $ticket)
|
public function createGitlabIssue(User $user, Ticket $ticket)
|
||||||
{
|
{
|
||||||
return $user->role->equals(RoleEnum::developper)
|
return $user->role->equals(RoleEnum::developper)
|
||||||
&& ($ticket->type->equals(TicketTypeEnum::bug) || $ticket->type->equals(TicketTypeEnum::evolution) || $ticket->type->equals(TicketTypeEnum::newsletter))
|
&& (
|
||||||
|
$ticket->type->equals(TicketTypeEnum::bug)
|
||||||
|
|| $ticket->type->equals(TicketTypeEnum::evolution)
|
||||||
|
|| $ticket->type->equals(TicketTypeEnum::newsletter)
|
||||||
|
|| $ticket->type->equals(TicketTypeEnum::mailing)
|
||||||
|
)
|
||||||
&& !\is_null($ticket->site->gitlab_project_id)
|
&& !\is_null($ticket->site->gitlab_project_id)
|
||||||
&& \is_null($ticket->gitlab_issue);
|
&& \is_null($ticket->gitlab_issue);
|
||||||
}
|
}
|
||||||
|
|
@ -293,12 +297,11 @@ class TicketPolicy
|
||||||
* Determine if the user can changeOrder
|
* Determine if the user can changeOrder
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param User $user
|
||||||
* @return bool
|
* @return boolean
|
||||||
* @throws Error
|
* @throws Error The error.
|
||||||
*/
|
*/
|
||||||
public function changeOrder(User $user)
|
public function changeOrder(User $user)
|
||||||
{
|
{
|
||||||
return $user->role->equals(RoleEnum::developper);
|
return $user->role->equals(RoleEnum::developper);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,24 @@
|
||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use App\Repositories\EloquentSiteRepository;
|
||||||
|
use App\Repositories\SiteRepository;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\URL;
|
use Illuminate\Support\Facades\URL;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Override;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
|
#[Override]
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$this->app->singleton(
|
||||||
|
SiteRepository::class,
|
||||||
|
fn() => new EloquentSiteRepository()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap any application services.
|
* Bootstrap any application services.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,6 @@
|
||||||
|
|
||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\Events\NotifyAdmin;
|
|
||||||
use App\Events\NotifySubscriptions;
|
|
||||||
use App\Events\NotifyTicketCreator;
|
|
||||||
use App\Events\TicketStatusChanged;
|
|
||||||
use App\Listeners\AddStatusMessages;
|
|
||||||
use App\Listeners\SendNotificationMailToAdmin;
|
|
||||||
use App\Listeners\SendNotificationMailToTicketCreator;
|
|
||||||
use App\Listeners\SendSubscriptionsNotificationsMail;
|
|
||||||
use Illuminate\Auth\Events\Registered;
|
use Illuminate\Auth\Events\Registered;
|
||||||
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
|
||||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||||
|
|
@ -23,10 +15,6 @@ class EventServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
protected $listen = [
|
protected $listen = [
|
||||||
Registered::class => [SendEmailVerificationNotification::class],
|
Registered::class => [SendEmailVerificationNotification::class],
|
||||||
TicketStatusChanged::class => [AddStatusMessages::class],
|
|
||||||
NotifySubscriptions::class => [SendSubscriptionsNotificationsMail::class],
|
|
||||||
NotifyTicketCreator::class => [SendNotificationMailToTicketCreator::class],
|
|
||||||
NotifyAdmin::class => [SendNotificationMailToAdmin::class],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -36,6 +24,6 @@ class EventServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
public function shouldDiscoverEvents(): bool
|
public function shouldDiscoverEvents(): bool
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ use App\Models\Information;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Models\Label;
|
use App\Models\Label;
|
||||||
use App\Models\Package;
|
use App\Models\Package;
|
||||||
use App\Models\Project;
|
|
||||||
use App\Models\Site;
|
use App\Models\Site;
|
||||||
use App\Models\Ticket;
|
use App\Models\Ticket;
|
||||||
use App\Models\Ticket\TicketType;
|
use App\Models\Ticket\TicketType;
|
||||||
|
|
@ -88,14 +87,12 @@ class RouteServiceProvider extends ServiceProvider
|
||||||
});
|
});
|
||||||
Route::model('brand', Brand::class);
|
Route::model('brand', Brand::class);
|
||||||
Route::model('label', Label::class);
|
Route::model('label', Label::class);
|
||||||
Route::model('marker', Marker::class);
|
|
||||||
Route::model('package', Package::class);
|
Route::model('package', Package::class);
|
||||||
Route::model('information', Information::class);
|
Route::model('information', Information::class);
|
||||||
Route::model('company', Company::class);
|
Route::model('company', Company::class);
|
||||||
Route::model('invoice', Invoice::class);
|
Route::model('invoice', Invoice::class);
|
||||||
Route::model('user', User::class);
|
Route::model('user', User::class);
|
||||||
Route::model('site', Site::class);
|
Route::model('site', Site::class);
|
||||||
Route::model('project', Project::class);
|
|
||||||
Route::model('ticket_type', TicketType::class);
|
Route::model('ticket_type', TicketType::class);
|
||||||
Route::bind('ticket', function ($value) {
|
Route::bind('ticket', function ($value) {
|
||||||
return Ticket::where('id', $value)->has('site')->firstOrFail();
|
return Ticket::where('id', $value)->has('site')->firstOrFail();
|
||||||
|
|
|
||||||
19
app/Repositories/EloquentSiteRepository.php
Normal file
19
app/Repositories/EloquentSiteRepository.php
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Repositories;
|
||||||
|
|
||||||
|
use App\Models\Site;
|
||||||
|
use Override;
|
||||||
|
|
||||||
|
class EloquentSiteRepository implements SiteRepository
|
||||||
|
{
|
||||||
|
#[Override]
|
||||||
|
public function findByName(string $name): ?Site
|
||||||
|
{
|
||||||
|
return Site::query()
|
||||||
|
->where('name', $name)
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
}
|
||||||
12
app/Repositories/SiteRepository.php
Normal file
12
app/Repositories/SiteRepository.php
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Repositories;
|
||||||
|
|
||||||
|
use App\Models\Site;
|
||||||
|
|
||||||
|
interface SiteRepository
|
||||||
|
{
|
||||||
|
public function findByName(string $name): ?Site;
|
||||||
|
}
|
||||||
56
app/Services/AutomaticTicketCreator.php
Normal file
56
app/Services/AutomaticTicketCreator.php
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Enums\Tickets\TicketStatusEnum;
|
||||||
|
use App\Enums\Tickets\TicketTypeEnum;
|
||||||
|
use App\Models\Site;
|
||||||
|
use App\Models\Ticket;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class AutomaticTicketCreator
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly BrevoWebookParser $parser
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function createTicket(
|
||||||
|
Site $forSite,
|
||||||
|
User $withProjectManager,
|
||||||
|
string $withRawHtmlContent,
|
||||||
|
): Ticket {
|
||||||
|
|
||||||
|
$parsedContent = $this->parser->parseRawHtml($withRawHtmlContent);
|
||||||
|
|
||||||
|
$textContent = "Bonjour,\n";
|
||||||
|
$textContent .= " Contenu :\n\n";
|
||||||
|
$textContent .= " {$parsedContent->plainTextContent},\n\n";
|
||||||
|
$textContent .= " Cordialement.";
|
||||||
|
|
||||||
|
$title = "Demande de mail en masse";
|
||||||
|
|
||||||
|
if (!empty($parsedContent->brand)) {
|
||||||
|
$title .= " pour {$parsedContent->brand}";
|
||||||
|
}
|
||||||
|
|
||||||
|
$ticket = new Ticket([
|
||||||
|
'site_id' => $forSite->id,
|
||||||
|
'type' => TicketTypeEnum::mailing->value,
|
||||||
|
'status' => TicketStatusEnum::estimateTodo->value,
|
||||||
|
'date_mep' => null,
|
||||||
|
'text' => $textContent,
|
||||||
|
'title' => $title,
|
||||||
|
'is_internal' => false
|
||||||
|
]);
|
||||||
|
|
||||||
|
$ticket->site()->associate($forSite);
|
||||||
|
$ticket->user()->associate($withProjectManager);
|
||||||
|
$ticket->assignedUser()->associate($withProjectManager);
|
||||||
|
|
||||||
|
$ticket->saveOrFail();
|
||||||
|
|
||||||
|
return $ticket;
|
||||||
|
}
|
||||||
|
}
|
||||||
35
app/Services/BrevoWebookParser.php
Normal file
35
app/Services/BrevoWebookParser.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Dto\BrevoWebHookDto;
|
||||||
|
use App\Exceptions\BrevoParseFailure;
|
||||||
|
|
||||||
|
class BrevoWebookParser
|
||||||
|
{
|
||||||
|
/** @throws BrevoParseFailure */
|
||||||
|
public function parseRawHtml(string $rawHtml): BrevoWebHookDto
|
||||||
|
{
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
$plainText = strip_tags($rawHtml);
|
||||||
|
$tblRegexPatterns = [
|
||||||
|
'user' => '/^Matricule et Nom du demandeur\s*\r?\n(.*)$/im',
|
||||||
|
'email' => '/^Email du demandeur\s*\r?\n(.*)$/im',
|
||||||
|
'brand' => '/^Marque\s*\/\s*Filiale\s*\r?\n(.*)$/im',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($tblRegexPatterns as $field => $regex) {
|
||||||
|
if (preg_match($regex, $plainText, $matches)) {
|
||||||
|
$data[$field] = trim($matches[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BrevoWebHookDto(
|
||||||
|
plainTextContent: $plainText,
|
||||||
|
brand: $data['brand'] ?? null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
59
app/Traits/Controllers/HasGitlabIssue.php
Normal file
59
app/Traits/Controllers/HasGitlabIssue.php
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Traits\Controllers;
|
||||||
|
|
||||||
|
use App\Models\GitlabIssues;
|
||||||
|
use GrahamCampbell\GitLab\Facades\GitLab;
|
||||||
|
|
||||||
|
trait HasGitlabIssue
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Retrieves a GitLab issue id from its URL.
|
||||||
|
*
|
||||||
|
* @param int $projectId
|
||||||
|
* @param string $issueUrl
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getGitlabIssue(int $projectId, string $issueUrl): array
|
||||||
|
{
|
||||||
|
if (!preg_match('/\/(?:issues|work_items)\/(\d+)/', $issueUrl, $matches)) { return []; }
|
||||||
|
|
||||||
|
$gitlabIssue = GitLab::issues()->show($projectId, (int) $matches[1]);
|
||||||
|
|
||||||
|
return $gitlabIssue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update labels for a GitLab issue.
|
||||||
|
*
|
||||||
|
* @param int|string $projectId
|
||||||
|
* @param int $issueId
|
||||||
|
* @param array $labels
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function updateGitlabIssueLabels($projectId, int $issueId, array $labels): array
|
||||||
|
{
|
||||||
|
return GitLab::issues()->update($projectId, $issueId, [
|
||||||
|
'labels' => implode(',', $labels),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close a GitLab issue.
|
||||||
|
*
|
||||||
|
* @param int|string $projectId
|
||||||
|
* @param int $issueId
|
||||||
|
* @param array $labels
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function closeGitlabIssue($projectId, int $issueId, array $labels): array
|
||||||
|
{
|
||||||
|
return GitLab::issues()->update($projectId, $issueId, [
|
||||||
|
'state_event' => 'close',
|
||||||
|
'labels' => implode(',', $labels),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"description": "Support web",
|
"description": "Support web",
|
||||||
"support": {
|
"support": {
|
||||||
"email": "equipe.web@ldc.fr"
|
"email": "digital@ldc.fr"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"framework",
|
"framework",
|
||||||
|
|
@ -12,22 +12,23 @@
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.3",
|
"php": "^8.5",
|
||||||
"carlos-meneses/laravel-mpdf": "^2.1",
|
"carlos-meneses/laravel-mpdf": "^2.1",
|
||||||
"codegreencreative/laravel-samlidp": "^5.2",
|
"codegreencreative/laravel-samlidp": "^5.2",
|
||||||
"diglactic/laravel-breadcrumbs": "^9.0",
|
"diglactic/laravel-breadcrumbs": "^9.0",
|
||||||
"doctrine/dbal": "^3.1",
|
"doctrine/dbal": "^3.1",
|
||||||
"graham-campbell/gitlab": "^7.0",
|
"graham-campbell/gitlab": "^7.6",
|
||||||
"guzzlehttp/guzzle": "^7.2",
|
"guzzlehttp/guzzle": "^7.2",
|
||||||
"laravel/framework": "^11.0",
|
"laravel/framework": "^11.0",
|
||||||
"laravel/tinker": "^2.8",
|
"laravel/tinker": "^2.8",
|
||||||
"laravel/ui": "^4.2",
|
"laravel/ui": "^4.2",
|
||||||
"mews/purifier": "^3.4",
|
"mews/purifier": "^3.4",
|
||||||
"sentry/sentry-laravel": "*",
|
"sentry/sentry-laravel": "*",
|
||||||
"uwil/admin-secure-laravel": "^3.0",
|
"uwil/admin-secure-laravel": "^5.0",
|
||||||
"uwil/k8s-laravel": "^1.2"
|
"uwil/k8s-laravel": "^1.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"barryvdh/laravel-ide-helper": "^3.7",
|
||||||
"fakerphp/faker": "^1.9.1",
|
"fakerphp/faker": "^1.9.1",
|
||||||
"laravel-lang/common": "^4.0",
|
"laravel-lang/common": "^4.0",
|
||||||
"laravel/pint": "^1.0",
|
"laravel/pint": "^1.0",
|
||||||
|
|
@ -43,7 +44,8 @@
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"App\\": "app/",
|
"App\\": "app/",
|
||||||
"Database\\Factories\\": "database/factories/",
|
"Database\\Factories\\": "database/factories/",
|
||||||
"Database\\Seeders\\": "database/seeders/"
|
"Database\\Seeders\\": "database/seeders/",
|
||||||
|
"Domain\\": "domain/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"repositories": [
|
"repositories": [
|
||||||
|
|
@ -67,7 +69,11 @@
|
||||||
"@php artisan package:discover --ansi"
|
"@php artisan package:discover --ansi"
|
||||||
],
|
],
|
||||||
"post-update-cmd": [
|
"post-update-cmd": [
|
||||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
"@php artisan vendor:publish --tag=laravel-assets --ansi --force",
|
||||||
|
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
|
||||||
|
"@php artisan lang:update",
|
||||||
|
"@php artisan ide-helper:generate",
|
||||||
|
"@php artisan ide-helper:models -RW"
|
||||||
],
|
],
|
||||||
"post-root-package-install": [
|
"post-root-package-install": [
|
||||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||||
|
|
|
||||||
2958
composer.lock
generated
2958
composer.lock
generated
File diff suppressed because it is too large
Load diff
379
config/ide-helper.php
Normal file
379
config/ide-helper.php
Normal file
|
|
@ -0,0 +1,379 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Http\Client\Factory;
|
||||||
|
use Illuminate\Http\Client\PendingRequest;
|
||||||
|
use Illuminate\Session\Store;
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Filename
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The default filename.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'filename' => '_ide_helper.php',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Models filename
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The default filename for the models helper file.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'models_filename' => '_ide_helper_models.php',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| PhpStorm meta filename
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| PhpStorm also supports the directory `.phpstorm.meta.php/` with arbitrary
|
||||||
|
| files in it, should you need additional files for your project; e.g.
|
||||||
|
| `.phpstorm.meta.php/laravel_ide_Helper.php'.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'meta_filename' => '.phpstorm.meta.php',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Fluent helpers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Set to true to generate commonly used Fluent methods.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'include_fluent' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Write model query methods
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Set to false to disable generated docs for the 'query()', 'newQuery()' and 'newModelQuery()' methods.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'write_query_methods' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Write model magic methods
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Set to false to disable write magic methods of model.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'write_model_magic_where' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Write model external Eloquent builder methods
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Set to false to disable write external Eloquent builder methods.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'write_model_external_builder_methods' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Write model relation count and exists properties
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Set to false to disable writing of relation count and exists properties
|
||||||
|
| to model DocBlocks.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'write_model_relation_count_properties' => false,
|
||||||
|
'write_model_relation_exists_properties' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Write Eloquent model mixins
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This will add the necessary DocBlock mixins to the model class
|
||||||
|
| contained in the Laravel framework. This helps the IDE with
|
||||||
|
| auto-completion.
|
||||||
|
|
|
||||||
|
| Please be aware that this setting changes a file within the /vendor directory.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'write_eloquent_model_mixins' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Helper files to include
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Include helper files. By default not included, but can be toggled with the
|
||||||
|
| -- helpers (-H) option. Extra helper files can be included.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'include_helpers' => false,
|
||||||
|
|
||||||
|
'helper_files' => [
|
||||||
|
base_path() . '/vendor/laravel/framework/src/Illuminate/Support/helpers.php',
|
||||||
|
base_path() . '/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Model locations to include
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define in which directories the ide-helper:models command should look
|
||||||
|
| for models.
|
||||||
|
|
|
||||||
|
| glob patterns are supported to easier reach models in sub-directories,
|
||||||
|
| e.g. `app/Services/* /Models` (without the space).
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'model_locations' => [
|
||||||
|
'app',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Models to ignore
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define which models should be ignored.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'ignored_models' => [],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Models hooks
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define which hook classes you want to run for models to add custom information.
|
||||||
|
|
|
||||||
|
| Hooks should implement Barryvdh\LaravelIdeHelper\Contracts\ModelHookInterface.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'model_hooks' => [
|
||||||
|
// App\Support\IdeHelper\MyModelHook::class
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Extra classes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These implementations are not really extended, but called with magic functions.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'extra' => [
|
||||||
|
'Eloquent' => [Builder::class, \Illuminate\Database\Query\Builder::class],
|
||||||
|
'Session' => [Store::class],
|
||||||
|
],
|
||||||
|
|
||||||
|
'magic' => [],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Interface implementations
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| These interfaces will be replaced with the implementing class. Some interfaces
|
||||||
|
| are detected by the helpers, others can be listed below.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'interfaces' => [
|
||||||
|
// App\MyInterface::class => App\MyImplementation::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Support for camel cased models
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| There are some Laravel packages (such as Eloquence) that allow for accessing
|
||||||
|
| Eloquent model properties via camel case, instead of snake case.
|
||||||
|
|
|
||||||
|
| Enabling this option will support these packages by saving all model
|
||||||
|
| properties as camel case, instead of snake case.
|
||||||
|
|
|
||||||
|
| For example, normally you would see this:
|
||||||
|
|
|
||||||
|
| * @property \Illuminate\Support\Carbon $created_at
|
||||||
|
| * @property \Illuminate\Support\Carbon $updated_at
|
||||||
|
|
|
||||||
|
| With this enabled, the properties will be this:
|
||||||
|
|
|
||||||
|
| * @property \Illuminate\Support\Carbon $createdAt
|
||||||
|
| * @property \Illuminate\Support\Carbon $updatedAt
|
||||||
|
|
|
||||||
|
| Note, it is currently an all-or-nothing option.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'model_camel_case_properties' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Property casts
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Cast the given "real type" to the given "type".
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'type_overrides' => [
|
||||||
|
'integer' => 'int',
|
||||||
|
'boolean' => 'bool',
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Include DocBlocks from classes
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Include DocBlocks from classes to allow additional code inspection for
|
||||||
|
| magic methods and properties.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'include_class_docblocks' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Force FQN usage
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Use the fully qualified (class) name in DocBlocks,
|
||||||
|
| even if the class exists in the same namespace
|
||||||
|
| or there is an import (use className) of the class.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'force_fqn' => false,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Use generics syntax
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Use generics syntax within DocBlocks,
|
||||||
|
| e.g. `Collection<User>` instead of `Collection|User[]`.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'use_generics_annotations' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Default return types for macros
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Define default return types for macros without explicit return types.
|
||||||
|
| e.g. `\Illuminate\Database\Query\Builder::class => 'static'`,
|
||||||
|
| `\Illuminate\Support\Str::class => 'string'`
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'macro_default_return_types' => [
|
||||||
|
Factory::class => PendingRequest::class,
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Additional relation types
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Sometimes it's needed to create custom relation types. The key of the array
|
||||||
|
| is the relationship method name. The value of the array is the fully-qualified
|
||||||
|
| class name of the relationship, e.g. `'relationName' => RelationShipClass::class`.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'additional_relation_types' => [],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Additional relation return types
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When using custom relation types its possible for the class name to not contain
|
||||||
|
| the proper return type of the relation. The key of the array is the relationship
|
||||||
|
| method name. The value of the array is the return type of the relation ('many'
|
||||||
|
| or 'morphTo').
|
||||||
|
| e.g. `'relationName' => 'many'`.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'additional_relation_return_types' => [],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enforce nullable Eloquent relationships on not null columns
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When set to true (default), this option enforces nullable Eloquent relationships.
|
||||||
|
| However, in cases where the application logic ensures the presence of related
|
||||||
|
| records it may be desirable to set this option to false to avoid unwanted null warnings.
|
||||||
|
|
|
||||||
|
| Default: true
|
||||||
|
| A not null column with no foreign key constraint will have a "nullable" relationship.
|
||||||
|
| * @property int $not_null_column_with_no_foreign_key_constraint
|
||||||
|
| * @property-read BelongsToVariation|null $notNullColumnWithNoForeignKeyConstraint
|
||||||
|
|
|
||||||
|
| Option: false
|
||||||
|
| A not null column with no foreign key constraint will have a "not nullable" relationship.
|
||||||
|
| * @property int $not_null_column_with_no_foreign_key_constraint
|
||||||
|
| * @property-read BelongsToVariation $notNullColumnWithNoForeignKeyConstraint
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'enforce_nullable_relationships' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Make soft deletable relations nullable
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| When set to true (default), relationships to models using SoftDeletes trait
|
||||||
|
| will be marked as nullable. This is because soft-deleted records are excluded
|
||||||
|
| from queries by default, meaning even non-nullable foreign keys can return
|
||||||
|
| null when the related model is soft-deleted.
|
||||||
|
|
|
||||||
|
| Default: true
|
||||||
|
| A relationship to a soft-deletable model will include |null in the type:
|
||||||
|
| * @property-read Team|null $team
|
||||||
|
|
|
||||||
|
| Option: false
|
||||||
|
| A relationship to a soft-deletable model will NOT include |null (unless
|
||||||
|
| nullable for other reasons such as nullable foreign key column):
|
||||||
|
| * @property-read Team $team
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'soft_deletes_force_nullable' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Run artisan commands after migrations to generate model helpers
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The specified commands should run after migrations are finished running.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'post_migrate' => [
|
||||||
|
// 'ide-helper:models --nowrite',
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
||||||
|
|
@ -16,7 +16,11 @@ return [
|
||||||
'default' => env('MAIL_MAILER', 'smtp'),
|
'default' => env('MAIL_MAILER', 'smtp'),
|
||||||
|
|
||||||
// * Mail admin
|
// * Mail admin
|
||||||
'MAIL_ADMIN' => env('MAIL_ADMIN', 'equipe.web@ldc.fr'),
|
'MAIL_ADMIN' => env('MAIL_ADMIN', 'digital@ldc.fr'),
|
||||||
|
|
||||||
|
'brevo_webook' => [
|
||||||
|
'expected_from_address' => 'mailing@reply.uwil.fr'
|
||||||
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
@ -100,7 +104,7 @@ return [
|
||||||
],
|
],
|
||||||
|
|
||||||
'contactsList' => [
|
'contactsList' => [
|
||||||
'serviceweb' => env('MAIL_LIST_SERVICEWEB', 'equipe.web@ldc.fr')
|
'serviceweb' => env('MAIL_LIST_SERVICEWEB', 'digital@ldc.fr')
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
46
database/factories/SiteFactory.php
Normal file
46
database/factories/SiteFactory.php
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\Site;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
class SiteFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name of the factory's corresponding model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $model = Site::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => fake()->company(),
|
||||||
|
'url_re7' => fake()->url(),
|
||||||
|
'url_prod' => fake()->url(),
|
||||||
|
'gitlab_project_id' => fake()->optional()->randomNumber(4),
|
||||||
|
'brand_id' => null,
|
||||||
|
'project_manager_id' => null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indique que le site a un chef de projet assigné.
|
||||||
|
*/
|
||||||
|
public function withProjectManager(): static
|
||||||
|
{
|
||||||
|
return $this->state(fn(array $attributes) => [
|
||||||
|
'project_manager_id' => User::factory(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use App\Enums\Users\RoleEnum;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
class UserFactory extends Factory
|
class UserFactory extends Factory
|
||||||
{
|
{
|
||||||
|
|
@ -18,17 +20,23 @@ class UserFactory extends Factory
|
||||||
/**
|
/**
|
||||||
* Define the model's default state.
|
* Define the model's default state.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public function definition()
|
public function definition(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->faker->name,
|
'name' => fake()->name(),
|
||||||
'email' => $this->faker->unique()->safeEmail,
|
'email' => fake()->unique()->safeEmail(),
|
||||||
'email_verified_at' => now(),
|
'role' => RoleEnum::developper,
|
||||||
// * password
|
'gitlab_id' => fake()->optional()->randomNumber(5),
|
||||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi',
|
'favourite_site_id' => null,
|
||||||
'remember_token' => Str::random(10),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function admin(): static
|
||||||
|
{
|
||||||
|
return $this->state(fn(array $attributes) => [
|
||||||
|
'role' => RoleEnum::admin,
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@ class CreateCreditLogsTable extends Migration
|
||||||
Schema::create('credit_logs', function (Blueprint $table) {
|
Schema::create('credit_logs', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
|
|
||||||
$table->unsignedTinyInteger('type')->comment('Enum Credit\\BalanceOperationEnum');
|
$table->tinyInteger('type')->unsigned()->comment('Enum Credit\\BalanceOperationEnum');
|
||||||
$table->unsignedFloat('amount')->comment('Montant de l\'opération');
|
$table->float('amount')->unsigned()->comment('Montant de l\'opération');
|
||||||
|
|
||||||
$table->foreignId('credit_account_id')
|
$table->foreignId('credit_account_id')
|
||||||
->constrained('credit_accounts')
|
->constrained('credit_accounts')
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@ class CreateCreditEstimationsTable extends Migration
|
||||||
Schema::create('credit_estimations', function (Blueprint $table) {
|
Schema::create('credit_estimations', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
|
|
||||||
$table->unsignedTinyInteger('status')->default(EstimationStatusEnum::pending)
|
$table->tinyInteger('status')->unsigned()->default(EstimationStatusEnum::pending)
|
||||||
->comment('Enum Credit\\EstimationStatusEnum');
|
->comment('Enum Credit\\EstimationStatusEnum');
|
||||||
|
|
||||||
$table->unsignedFloat('amount')->comment('Estimation amount');
|
$table->float('amount')->unsigned()->comment('Estimation amount');
|
||||||
|
|
||||||
$table->foreignIdFor(Ticket::class)
|
$table->foreignIdFor(Ticket::class)
|
||||||
->constrained();
|
->constrained();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class ChangeAmoutFloatingPointOnCreditEstimations extends Migration
|
class ChangeAmoutFloatingPointOnCreditEstimations extends Migration
|
||||||
|
|
@ -12,8 +13,8 @@ class ChangeAmoutFloatingPointOnCreditEstimations extends Migration
|
||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Schema::table('credit_estimations', function ($table) {
|
Schema::table('credit_estimations', function (Blueprint $table) {
|
||||||
$table->unsignedFloat('amount', 8, 3)
|
$table->decimal('amount', 8, 3)->unsigned()
|
||||||
->comment('Estimation amount')->change();
|
->comment('Estimation amount')->change();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -25,8 +26,8 @@ class ChangeAmoutFloatingPointOnCreditEstimations extends Migration
|
||||||
*/
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Schema::table('credit_estimations', function ($table) {
|
Schema::table('credit_estimations', function (Blueprint $table) {
|
||||||
$table->unsignedFloat('amount')
|
$table->float('amount')->unsigned()
|
||||||
->comment('Estimation amount')->change();
|
->comment('Estimation amount')->change();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class CreatePackagesTable extends Migration
|
||||||
$table->id();
|
$table->id();
|
||||||
|
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->unsignedFloat('amount')->comment('The cost per day');
|
$table->float('amount')->unsigned()->comment('The cost per day');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ class CreateInvoicesTable extends Migration
|
||||||
'A JSON object, each line has to be contructed using these fields description, days, type Invoices\TaskTypeEnum, amount'
|
'A JSON object, each line has to be contructed using these fields description, days, type Invoices\TaskTypeEnum, amount'
|
||||||
);
|
);
|
||||||
|
|
||||||
$table->unsignedFloat('total')->comment('The total calculated using all tasks');
|
$table->float('total')->unsigned()->comment('The total calculated using all tasks');
|
||||||
$table->unsignedFloat('total_days')->comment('The total days calculated using all tasks');
|
$table->float('total_days')->unsigned()->comment('The total days calculated using all tasks');
|
||||||
|
|
||||||
$table->text('comment')->nullable()
|
$table->text('comment')->nullable()
|
||||||
->comment('Any comment joined to the invoice');
|
->comment('Any comment joined to the invoice');
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Models\Ticket;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
class ChangeTicketsStatus extends Migration
|
class ChangeTicketsStatus extends Migration
|
||||||
|
|
@ -12,17 +12,22 @@ class ChangeTicketsStatus extends Migration
|
||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
Ticket::whereIn('status', [4, 5, 7, 10])
|
DB::table('tickets')->whereIn('status', [4, 5, 7, 10])
|
||||||
->update(['status' => 3]);
|
->update(['status' => 3]);
|
||||||
Ticket::where('status', 9)
|
|
||||||
|
DB::table('tickets')->where('status', 9)
|
||||||
->update(['status' => 4]);
|
->update(['status' => 4]);
|
||||||
Ticket::where('status', 17)
|
|
||||||
|
DB::table('tickets')->where('status', 17)
|
||||||
->update(['status' => 5]);
|
->update(['status' => 5]);
|
||||||
Ticket::where('status', 12)
|
|
||||||
|
DB::table('tickets')->where('status', 12)
|
||||||
->update(['status' => 6]);
|
->update(['status' => 6]);
|
||||||
Ticket::where('status', 13)
|
|
||||||
|
DB::table('tickets')->where('status', 13)
|
||||||
->update(['status' => 7]);
|
->update(['status' => 7]);
|
||||||
Ticket::where('status', 15)
|
|
||||||
|
DB::table('tickets')->where('status', 15)
|
||||||
->update(['status' => 8]);
|
->update(['status' => 8]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,17 +38,22 @@ class ChangeTicketsStatus extends Migration
|
||||||
*/
|
*/
|
||||||
public function down()
|
public function down()
|
||||||
{
|
{
|
||||||
Ticket::where('status', 3)
|
DB::table('tickets')->where('status', 3)
|
||||||
->update(['status' => 10]);
|
->update(['status' => 10]);
|
||||||
Ticket::where('status', 4)
|
|
||||||
|
DB::table('tickets')->where('status', 4)
|
||||||
->update(['status' => 9]);
|
->update(['status' => 9]);
|
||||||
Ticket::where('status', 5)
|
|
||||||
|
DB::table('tickets')->where('status', 5)
|
||||||
->update(['status' => 17]);
|
->update(['status' => 17]);
|
||||||
Ticket::where('status', 6)
|
|
||||||
|
DB::table('tickets')->where('status', 6)
|
||||||
->update(['status' => 12]);
|
->update(['status' => 12]);
|
||||||
Ticket::where('status', 7)
|
|
||||||
|
DB::table('tickets')->where('status', 7)
|
||||||
->update(['status' => 13]);
|
->update(['status' => 13]);
|
||||||
Ticket::where('status', 8)
|
|
||||||
|
DB::table('tickets')->where('status', 8)
|
||||||
->update(['status' => 15]);
|
->update(['status' => 15]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Models\Ticket;
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class extends Migration
|
||||||
|
|
@ -17,15 +16,32 @@ return new class extends Migration
|
||||||
{
|
{
|
||||||
Schema::table('tickets', function (Blueprint $table) {
|
Schema::table('tickets', function (Blueprint $table) {
|
||||||
$table->timestamp('last_activity')
|
$table->timestamp('last_activity')
|
||||||
->default(Carbon::now())
|
->useCurrent()
|
||||||
->comment('Last activity on the ticket.')
|
->comment('Last activity on the ticket.')
|
||||||
->after('is_internal');
|
->after('is_internal');
|
||||||
});
|
});
|
||||||
Ticket::get()->map(function (object $ticket) {
|
|
||||||
$lastMessage = $ticket->messages->whereNotNull('user_id')->sortByDesc('updated_at')->first();
|
DB::table('tickets')->orderBy('id')->chunk(500, function ($tickets) {
|
||||||
$ticket->last_activity =
|
$ticketIds = $tickets->pluck('id')->toArray();
|
||||||
$lastMessage->updated_at ?? $ticket->updated_at;
|
|
||||||
$ticket->saveQuietly();
|
$messages = DB::table('messages')
|
||||||
|
->whereIn('ticket_id', $ticketIds)
|
||||||
|
->whereNotNull('user_id')
|
||||||
|
->orderBy('updated_at', 'desc')
|
||||||
|
->get()
|
||||||
|
->groupBy('ticket_id');
|
||||||
|
|
||||||
|
foreach ($tickets as $ticket) {
|
||||||
|
$lastMessageDate = $messages->has($ticket->id)
|
||||||
|
? $messages->get($ticket->id)->first()->updated_at
|
||||||
|
: null;
|
||||||
|
|
||||||
|
DB::table('tickets')
|
||||||
|
->where('id', $ticket->id)
|
||||||
|
->update([
|
||||||
|
'last_activity' => $lastMessageDate ?? $ticket->updated_at
|
||||||
|
]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Models\Ticket;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class extends Migration
|
||||||
{
|
{
|
||||||
|
|
@ -22,12 +21,16 @@ return new class extends Migration
|
||||||
});
|
});
|
||||||
|
|
||||||
DB::transaction(function () {
|
DB::transaction(function () {
|
||||||
$tickets = Ticket::all();
|
DB::table('tickets')->orderBy('id')->chunkById(1000, function ($tickets) {
|
||||||
foreach ($tickets as $ticket) {
|
foreach ($tickets as $ticket) {
|
||||||
$ticket->title = 'ts-' . $ticket->id;
|
DB::table('tickets')
|
||||||
$ticket->saveQuietly();
|
->where('id', $ticket->id)
|
||||||
|
->update([
|
||||||
|
'title' => 'ts-' . $ticket->id
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Models\Ticket;
|
|
||||||
use App\Models\Ticket\TicketType;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class extends Migration
|
||||||
{
|
{
|
||||||
|
|
@ -13,13 +12,19 @@ return new class extends Migration
|
||||||
*/
|
*/
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
Ticket::query()->get()->map(function (Ticket $model) {
|
DB::transaction(function () {
|
||||||
$model->type = $model->getRawOriginal('type') + 1;
|
DB::table('tickets')->orderBy('id')->chunkById(1000, function ($tickets) {
|
||||||
$model->saveQuietly();
|
$ids = $tickets->pluck('id')->toArray();
|
||||||
|
DB::table('tickets')->whereIn('id', $ids)->increment('type');
|
||||||
});
|
});
|
||||||
TicketType::query()->orderBy('type', 'DESC')->get()->map(function (TicketType $model) {
|
|
||||||
$model->type = $model->getRawOriginal('type') + 1;
|
$ticketTypes = DB::table('ticket_types')->orderBy('type', 'desc')->get();
|
||||||
$model->saveQuietly();
|
|
||||||
|
foreach ($ticketTypes as $type) {
|
||||||
|
DB::table('ticket_types')
|
||||||
|
->where('id', $type->id)
|
||||||
|
->update(['type' => $type->type + 1]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,13 +35,20 @@ return new class extends Migration
|
||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Ticket::query()->get()->map(function (Ticket $model) {
|
DB::transaction(function () {
|
||||||
$model->type = $model->getRawOriginal('type') - 1;
|
// 1. Restauration des tickets
|
||||||
$model->saveQuietly();
|
DB::table('tickets')->orderBy('id')->chunkById(1000, function ($tickets) {
|
||||||
|
$ids = $tickets->pluck('id')->toArray();
|
||||||
|
DB::table('tickets')->whereIn('id', $ids)->decrement('type');
|
||||||
});
|
});
|
||||||
TicketType::query()->orderBy('type', 'DESC')->get()->map(function (TicketType $model) {
|
|
||||||
$model->type = $model->getRawOriginal('type') - 1;
|
$ticketTypes = DB::table('ticket_types')->orderBy('type', 'asc')->get();
|
||||||
$model->saveQuietly();
|
|
||||||
|
foreach ($ticketTypes as $type) {
|
||||||
|
DB::table('ticket_types')
|
||||||
|
->where('id', $type->id)
|
||||||
|
->update(['type' => $type->type - 1]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use App\Models\Ticket;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class extends Migration
|
||||||
{
|
{
|
||||||
|
|
@ -12,10 +12,9 @@ return new class extends Migration
|
||||||
*/
|
*/
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
Ticket::query()->where('status', '>', 6)->get()->map(function (Ticket $model) {
|
DB::table('tickets')
|
||||||
$model->status = $model->getRawOriginal('status') + 1;
|
->where('status', '>', 6)
|
||||||
$model->saveQuietly();
|
->increment('status');
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -25,9 +24,8 @@ return new class extends Migration
|
||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Ticket::query()->where('status', '>', 6)->get()->map(function (Ticket $model) {
|
DB::table('tickets')
|
||||||
$model->status = $model->getRawOriginal('status') - 1;
|
->where('status', '>', 6)
|
||||||
$model->saveQuietly();
|
->decrement('status');
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use App\Models\Site;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
return new class extends Migration
|
return new class extends Migration
|
||||||
{
|
{
|
||||||
|
|
@ -15,13 +15,30 @@ return new class extends Migration
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
Schema::table('tickets', function (Blueprint $table) {
|
Schema::table('tickets', function (Blueprint $table) {
|
||||||
$table->integer('order')->after('status')->comment('Ticket order.');
|
$table->integer('order')->default(0)->after('status')->comment('Ticket order.');
|
||||||
});
|
});
|
||||||
|
|
||||||
Site::query()->get()->map(function ($site) {
|
DB::transaction(function () {
|
||||||
$site->tickets->map(function ($ticket, $ticketIndex) {
|
$currentSiteId = null;
|
||||||
$ticket->order = $ticketIndex + 1;
|
$orderCounter = 1;
|
||||||
$ticket->saveQuietly();
|
|
||||||
|
DB::table('tickets')
|
||||||
|
->orderBy('site_id')
|
||||||
|
->orderBy('id')
|
||||||
|
->chunk(1000, function ($tickets) use (&$currentSiteId, &$orderCounter) {
|
||||||
|
|
||||||
|
foreach ($tickets as $ticket) {
|
||||||
|
if ($ticket->site_id !== $currentSiteId) {
|
||||||
|
$currentSiteId = $ticket->site_id;
|
||||||
|
$orderCounter = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::table('tickets')
|
||||||
|
->where('id', $ticket->id)
|
||||||
|
->update(['order' => $orderCounter]);
|
||||||
|
|
||||||
|
$orderCounter++;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('invoices', function (Blueprint $table) {
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('invoices', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('deleted_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('tickets', function (Blueprint $table) {
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('tickets', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('deleted_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->foreignId('favourite_site_id')
|
||||||
|
->nullable()
|
||||||
|
->after('gitlab_id')
|
||||||
|
->constrained('sites')
|
||||||
|
->onDelete('set null');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropForeign(['favourite_site_id']);
|
||||||
|
$table->dropColumn('favourite_site_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue