feat: wip, validation tickets and messages request
This commit is contained in:
parent
c23e2289e5
commit
a4d0b131a4
5 changed files with 80 additions and 68 deletions
|
|
@ -182,6 +182,12 @@ class TicketController extends Controller
|
|||
$fileTicket = $request->file_ticket;
|
||||
/** @var \Illuminate\Http\UploadedFile|null */
|
||||
$fileTicket2 = $request->file_ticket2;
|
||||
/** @var \Illuminate\Http\UploadedFile|null */
|
||||
$fileTicket3 = $request->file_ticket3;
|
||||
/** @var \Illuminate\Http\UploadedFile|null */
|
||||
$fileTicket4 = $request->file_ticket4;
|
||||
/** @var \Illuminate\Http\UploadedFile|null */
|
||||
$fileTicket5 = $request->file_ticket5;
|
||||
|
||||
if ($fileTicket) {
|
||||
$ticket->file = FileStorageHelper::storeFile($ticket, $fileTicket);
|
||||
|
|
@ -189,6 +195,15 @@ class TicketController extends Controller
|
|||
if ($fileTicket2) {
|
||||
$ticket->file2 = FileStorageHelper::storeFile($ticket, $fileTicket2);
|
||||
}
|
||||
if ($fileTicket3) {
|
||||
$ticket->file3 = FileStorageHelper::storeFile($ticket, $fileTicket3);
|
||||
}
|
||||
if ($fileTicket4) {
|
||||
$ticket->file4 = FileStorageHelper::storeFile($ticket, $fileTicket4);
|
||||
}
|
||||
if ($fileTicket5) {
|
||||
$ticket->file5 = FileStorageHelper::storeFile($ticket, $fileTicket5);
|
||||
}
|
||||
|
||||
$ticket->user()->associate(auth()->user());
|
||||
$ticket->site()->associate($site);
|
||||
|
|
@ -256,6 +271,12 @@ class TicketController extends Controller
|
|||
$fileTicket = $request->file_ticket;
|
||||
/** @var \Illuminate\Http\UploadedFile|null */
|
||||
$fileTicket2 = $request->file_ticket2;
|
||||
/** @var \Illuminate\Http\UploadedFile|null */
|
||||
$fileTicket3 = $request->file_ticket3;
|
||||
/** @var \Illuminate\Http\UploadedFile|null */
|
||||
$fileTicket4 = $request->file_ticket4;
|
||||
/** @var \Illuminate\Http\UploadedFile|null */
|
||||
$fileTicket5 = $request->file_ticket5;
|
||||
|
||||
if ($fileTicket) {
|
||||
$ticket->file = FileStorageHelper::storeFile($ticket, $fileTicket);
|
||||
|
|
@ -263,6 +284,15 @@ class TicketController extends Controller
|
|||
if ($fileTicket2) {
|
||||
$ticket->file2 = FileStorageHelper::storeFile($ticket, $fileTicket2);
|
||||
}
|
||||
if ($fileTicket3) {
|
||||
$ticket->file3 = FileStorageHelper::storeFile($ticket, $fileTicket3);
|
||||
}
|
||||
if ($fileTicket4) {
|
||||
$ticket->file4 = FileStorageHelper::storeFile($ticket, $fileTicket4);
|
||||
}
|
||||
if ($fileTicket5) {
|
||||
$ticket->file5 = FileStorageHelper::storeFile($ticket, $fileTicket5);
|
||||
}
|
||||
|
||||
|
||||
$ticket->labels()->sync($request->labels);
|
||||
|
|
@ -595,7 +625,7 @@ class TicketController extends Controller
|
|||
});
|
||||
} //end foreach
|
||||
} //end if
|
||||
}, 'text', 'title', 'file', 'file2');
|
||||
}, 'text', 'title', 'file', 'file2', 'file3', 'file4', 'file5');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -654,6 +684,21 @@ class TicketController extends Controller
|
|||
$description .= $this->formatGitlabFiles($ticket, $uploadedFile2, 2);
|
||||
}
|
||||
|
||||
if (!\is_null($ticket->file3)) {
|
||||
$uploadedFile3 = GitLab::projects()->uploadFile($gitlabRepoId, $ticket->file3);
|
||||
$description .= $this->formatGitlabFiles($ticket, $uploadedFile3, 3);
|
||||
}
|
||||
|
||||
if (!\is_null($ticket->file4)) {
|
||||
$uploadedFile4 = GitLab::projects()->uploadFile($gitlabRepoId, $ticket->file4);
|
||||
$description .= $this->formatGitlabFiles($ticket, $uploadedFile4, 4);
|
||||
}
|
||||
|
||||
if (!\is_null($ticket->file5)) {
|
||||
$uploadedFile5 = GitLab::projects()->uploadFile($gitlabRepoId, $ticket->file5);
|
||||
$description .= $this->formatGitlabFiles($ticket, $uploadedFile5, 5);
|
||||
}
|
||||
|
||||
$issue = GitLab::issues()->create($gitlabRepoId, [
|
||||
'title' => 'ts-' . $ticket->id,
|
||||
'description' => $description,
|
||||
|
|
@ -690,7 +735,7 @@ class TicketController extends Controller
|
|||
*/
|
||||
private function formatGitlabFiles(Ticket $ticket, array $uploadedFile, int $fileNb)
|
||||
{
|
||||
if (Str::endsWith($ticket->file, ['jpg', 'png', 'jpeg'])) {
|
||||
if (Str::endsWith($ticket->file, ['jpg', 'png', 'jpeg', 'pptx', 'docx', 'xslx', 'csv'])) {
|
||||
$file = \sprintf(
|
||||
"",
|
||||
$fileNb,
|
||||
|
|
|
|||
|
|
@ -96,16 +96,13 @@ class StoreTicket extends FormRequest
|
|||
}
|
||||
}
|
||||
],
|
||||
'text' => 'required|string|min:40',
|
||||
'title' => 'required|string|between:3,255',
|
||||
'file_ticket' => 'mimes:pptx,docx,xlsx,csv,jpeg,jpg,png,pdf|max:2048',
|
||||
'file_ticket2' => 'mimes:pptx,docx,xlsx,csv,jpeg,jpg,png,pdf|max:2048',
|
||||
'file_ticket3' => 'mimes:pptx,docx,xlsx,csv,jpeg,jpg,png,pdf|max:2048',
|
||||
'file_ticket4' => 'mimes:pptx,docx,xlsx,csv,jpeg,jpg,png,pdf|max:2048',
|
||||
'file_ticket5' => 'mimes:pptx,docx,xlsx,csv,jpeg,jpg,png,pdf|max:2048',
|
||||
'is_internal' => 'required|boolean',
|
||||
'labels' => 'sometimes|array',
|
||||
'labels.*' => [
|
||||
'text' => 'required|string|min:40',
|
||||
'title' => 'required|string|between:3,255',
|
||||
'file_tickets' => 'sometimes|array',
|
||||
'file_tickets.*' => 'mimes:pptx,docx,xlsx,csv,jpeg,jpg,png,pdf|max:2048',
|
||||
'is_internal' => 'required|boolean',
|
||||
'labels' => 'sometimes|array',
|
||||
'labels.*' => [
|
||||
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
|
||||
'required', 'exists:labels,id', function ($attribute, $value, $fail) use ($user) {
|
||||
if (!$user->can('assignLabels', Ticket::class)) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Ticket;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\MessageTypeEnum;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddMessageType extends Migration
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
|
|
@ -33,4 +31,4 @@ class AddMessageType extends Migration
|
|||
$table->dropColumn('file4');
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -105,56 +105,30 @@
|
|||
<label class="col-form-label text-md-right" for="text">{{ __('Description') }}</label>
|
||||
<textarea class="form-control" id="text" name="text" rows="15" placeholder="{{ __('Description du ticket') }} *">{{ old('text') ?? ($ticket->text ?? '') }}</textarea>
|
||||
</div>
|
||||
<h4>Fichier joint 1</h4>
|
||||
<div class="form-group mb-3">
|
||||
<input name="file_ticket" type="file" accept="image/png, image/jpeg, image/jpg, .pdf, .pptx, .docx, .xlsx, .csv">
|
||||
@if (isset($ticket) and $ticket->file !== null)
|
||||
<hr>
|
||||
<div class="text-center">
|
||||
<img class="img-fluid" src="{{ asset($ticket->file) }}">
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<h4>Fichier joint 2</h4>
|
||||
<div class="form-group">
|
||||
<input name="file_ticket2" type="file" accept="image/png, image/jpeg, image/jpg, .pdf, .pptx, .docx, .xlsx, .csv">
|
||||
@if (isset($ticket) and $ticket->file2 !== null)
|
||||
<hr>
|
||||
<div class="text-center">
|
||||
<img class="img-fluid" src="{{ asset($ticket->file2) }}">
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<h4>Fichier joint 3</h4>
|
||||
<div class="form-group">
|
||||
<input name="file_ticket3" type="file" accept="image/png, image/jpeg, image/jpg, .pdf, .pptx, .docx, .xlsx, .csv">
|
||||
@if (isset($ticket) and $ticket->file3 !== null)
|
||||
<hr>
|
||||
<div class="text-center">
|
||||
<img class="img-fluid" src="{{ asset($ticket->file3) }}">
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<h4>Fichier joint 4</h4>
|
||||
<div class="form-group">
|
||||
<input name="file_ticket4" type="file" accept="image/png, image/jpeg, image/jpg, .pdf, .pptx, .docx, .xlsx, .csv">
|
||||
@if (isset($ticket) and $ticket->file4 !== null)
|
||||
<hr>
|
||||
<div class="text-center">
|
||||
<img class="img-fluid" src="{{ asset($ticket->file4) }}">
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<h4>Fichier joint 5</h4>
|
||||
<div class="form-group">
|
||||
<input name="file_ticket5" type="file" accept="image/png, image/jpeg, image/jpg, .pdf, .pptx, .docx, .xlsx, .csv">
|
||||
@if (isset($ticket) and $ticket->file5 !== null)
|
||||
<hr>
|
||||
<div class="text-center">
|
||||
<img class="img-fluid" src="{{ asset($ticket->file5) }}">
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@for ($i = 1; $i < 6; $i++)
|
||||
<h4>Fichier joint {{ $i }}</h4>
|
||||
<div class="form-group mb-3">
|
||||
<input name="file_tickets[]" type="file" accept="image/png, image/jpeg, image/jpg, .pdf, .pptx, .docx, .xlsx, .csv">
|
||||
@if (isset($ticket) and $ticket->file !== null)
|
||||
@if ($i === 1)
|
||||
<hr>
|
||||
<div class="text-center">
|
||||
<img class="img-fluid" src="{{ asset($ticket->file) }}">
|
||||
</div>
|
||||
@else
|
||||
@php
|
||||
$fileNumber = 'file'. $i;
|
||||
@endphp
|
||||
<hr>
|
||||
<div class="text-center">
|
||||
<img class="img-fluid" src="{{ asset($ticket->$fileNumber) }}">
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
</div>
|
||||
@endfor
|
||||
|
||||
@can('changeInternalStatus', App\Model\Ticket::class)
|
||||
<div class="form-group text-center">
|
||||
<input id="is_internal" name="is_internal" type="checkbox" @if (old('is_internal', isset($ticket) and $ticket->is_internal)) checked @endif>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue