Correction on ticket filter
This commit is contained in:
parent
b60913525b
commit
55ff49fd42
1 changed files with 8 additions and 4 deletions
|
|
@ -36,10 +36,14 @@ class TicketController extends Controller
|
|||
|
||||
public function index(SortTickets $request)
|
||||
{
|
||||
$tickets = Ticket::query();
|
||||
if (auth()->user()->project_id) {
|
||||
$tickets = $tickets->where('project_id', auth()->user()->project_id);
|
||||
}
|
||||
/** @var \App\Models\User */
|
||||
$user = auth()->user();
|
||||
$tickets = Ticket::with('project')
|
||||
->whereHas('project', function ($q) use ($user) {
|
||||
$q->whereHas('users', function ($q) use ($user) {
|
||||
$q->whereId($user->id);
|
||||
});
|
||||
});
|
||||
$tickets = $tickets->where('status', $request->status ? '=' : '<>', TicketStatus::archived());
|
||||
if ($request->search) {
|
||||
$tickets = $this->searchTicket($tickets, $request);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue