2020-11-18 10:23:51 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
|
|
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
|
|
|
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
|
|
|
|
use Illuminate\Routing\Controller as BaseController;
|
2022-02-23 15:15:47 +00:00
|
|
|
use App\Enums\TicketStatus;
|
|
|
|
|
use App\Models\Ticket;
|
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
|
use Illuminate\Support\Facades\View;
|
|
|
|
|
|
2020-11-18 10:23:51 +01:00
|
|
|
class Controller extends BaseController
|
|
|
|
|
{
|
2021-07-23 12:06:08 +02:00
|
|
|
use AuthorizesRequests;
|
|
|
|
|
use DispatchesJobs;
|
|
|
|
|
use ValidatesRequests;
|
2022-02-23 15:15:47 +00:00
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
2022-04-05 11:08:38 +02:00
|
|
|
$this->middleware(function($request, $next) {
|
|
|
|
|
$ignore = [
|
|
|
|
|
// Support Web
|
|
|
|
|
9,
|
|
|
|
|
// Gen-Game- Web
|
|
|
|
|
15,
|
|
|
|
|
// Store LDC
|
|
|
|
|
19,
|
|
|
|
|
// CRM
|
|
|
|
|
27,
|
|
|
|
|
// LDC - WEB
|
|
|
|
|
55,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$ticketsNew = Ticket::where('status', TicketStatus::new());
|
|
|
|
|
$ticketsWaiting = Ticket::where('status', TicketStatus::waiting());
|
|
|
|
|
$ticketsInProgress = Ticket::whereNotIn(
|
|
|
|
|
'status',
|
|
|
|
|
[
|
|
|
|
|
TicketStatus::new(),
|
|
|
|
|
TicketStatus::estimateTodo(),
|
|
|
|
|
TicketStatus::estimateValidated(),
|
|
|
|
|
TicketStatus::toPlan(),
|
|
|
|
|
TicketStatus::planned(),
|
|
|
|
|
TicketStatus::waiting(),
|
|
|
|
|
TicketStatus::production(),
|
|
|
|
|
TicketStatus::archived()
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/** @var \App\Models\User|null $user */
|
|
|
|
|
$user = Auth::user();
|
|
|
|
|
if (!is_null($user) and !$user->isAdmin()) {
|
|
|
|
|
$ticketsNew = $ticketsNew->where('is_internal', 0)->whereNotIn('site_id', $ignore);
|
|
|
|
|
$ticketsWaiting = $ticketsWaiting->where('is_internal', 0)->whereNotIn('site_id', $ignore);
|
|
|
|
|
$ticketsInProgress = $ticketsInProgress->where('is_internal', 0)->whereNotIn('site_id', $ignore);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
View::share('ticketsNew', $ticketsNew->count());
|
|
|
|
|
View::share('ticketsWaiting', $ticketsWaiting->count());
|
|
|
|
|
View::share('ticketsInProgress', $ticketsInProgress->count());
|
|
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
|
});
|
2022-02-23 15:15:47 +00:00
|
|
|
}
|
2020-11-18 10:23:51 +01:00
|
|
|
}
|