Ticket status overhaul with colors

This commit is contained in:
Jérémy Munsch 2021-04-21 13:34:23 +02:00
parent 00f9f24036
commit f5c2ed0e18
3 changed files with 49 additions and 5 deletions

View file

@ -8,8 +8,9 @@ use Kwaadpepper\Enum\BaseEnum;
* @method static self new()
* @method static self inprogress()
* @method static self processed()
* @method static self archived()
* @method static self recette()
* @method static self production()
* @method static self archived()
*/
class TicketStatus extends BaseEnum
{
@ -19,8 +20,9 @@ class TicketStatus extends BaseEnum
'new' => 1,
'inprogress' => 2,
'processed' => 3,
'archived' => 4,
'production' => 5
'recette' => 4,
'production' => 5,
'archived' => 9,
];
}
@ -30,8 +32,9 @@ class TicketStatus extends BaseEnum
'new' => trans('Nouveau'),
'inprogress' => trans('En cours'),
'processed' => trans('Traité'),
'archived' => trans('Archivé'),
'recette' => trans('En recettage'),
'production' => trans('En production'),
'archived' => trans('Archivé'),
];
}
}

View file

@ -0,0 +1,33 @@
<?php
use App\Enums\TicketStatus;
use App\Models\Ticket;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateTicketsStatusWithEnumStatus extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
foreach (Ticket::where('status', 4)->get() as $ticket) {
$ticket->status = TicketStatus::archived();
$ticket->save();
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View file

@ -69,7 +69,15 @@
</td>
<td>{{ Carbon\Carbon::parse($ticket->created_at)->format('d/m/Y à H:i') }}</td>
<td>{{ $ticket->user->name }}</td>
<td>{{ $ticket->status->label }}</td>
@php
$cls = $ticket->status == TicketStatus::archived() ? 'text-secondary' : null;
$cls = (!$cls && $ticket->status == TicketStatus::new()) ? 'text-danger' : $cls;
$cls = (!$cls && $ticket->status == TicketStatus::processed()) ? 'text-info' : $cls;
$cls = (!$cls && $ticket->status == TicketStatus::recette()) ? 'text-primary' : $cls;
$cls = (!$cls && $ticket->status == TicketStatus::production()) ? 'text-success' : $cls;
$cls = (!$cls && $ticket->status == TicketStatus::inprogress()) ? 'text-dark' : $cls;
@endphp
<td><span class="{{ $cls }}">{{ $ticket->status->label }}</span></td>
<td>
{{-- Modal du ticket --}}
<!-- Button trigger modal -->