feat: Update Ticket linking
This commit is contained in:
parent
d9aa989984
commit
f1ddf3b101
4 changed files with 13 additions and 8 deletions
|
|
@ -150,13 +150,10 @@ class TicketController extends Controller
|
|||
abort(403);
|
||||
}
|
||||
|
||||
$linkedTicket = $ticket->linkedTicket()->get();
|
||||
|
||||
$messages = $ticket->messages()->orderBy('created_at', 'DESC')->get();
|
||||
$isSubscribed = (bool)$ticket->subscriptions()->where('user_id', $user->id)->count();
|
||||
return view('bo.pages.tickets.show', [
|
||||
'ticket' => $ticket,
|
||||
'linkedTicket' => $linkedTicket,
|
||||
'messages' => $messages,
|
||||
'isSubscribed' => $isSubscribed
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Requests\Bo;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class LinkTicket extends FormRequest
|
||||
{
|
||||
|
|
@ -13,7 +14,9 @@ class LinkTicket extends FormRequest
|
|||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return auth()->check();
|
||||
/** @var \App\Models\User|null $user */
|
||||
$user = Auth::user();
|
||||
return Auth::check() && $user->isAdmin();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ class Ticket extends Model
|
|||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function linkedTicket()
|
||||
public function linkedTickets()
|
||||
{
|
||||
return $this->belongsToMany(Ticket::class, 'linked_tickets', 'ticket_id', 'linked_ticket_id');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -279,6 +279,10 @@
|
|||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
@php
|
||||
$linkedTickets = $ticket->linkedTickets;
|
||||
@endphp
|
||||
@if (!$linkedTickets->isEmpty() or auth()->user()->can('linkTicket', $ticket))
|
||||
<hr>
|
||||
<div class="flex-col">
|
||||
<div>
|
||||
|
|
@ -299,7 +303,7 @@
|
|||
</div>
|
||||
@endcan
|
||||
<div class="row row-cols-auto gap-2">
|
||||
@foreach ($linkedTicket as $linked)
|
||||
@foreach ($linkedTickets as $linked)
|
||||
<div class="col">
|
||||
@can('linkTicket', $ticket)
|
||||
<form id="form_unlink_ticket" action="{{ route('bo.ticket.unlink', ['ticket' => $ticket, 'linkedTicket' => $linked]) }}" method="POST">
|
||||
|
|
@ -307,8 +311,8 @@
|
|||
@method('DELETE')
|
||||
<div class="input-group mt-2">
|
||||
@endcan
|
||||
<a class="btn btn-xl btn-outline-primary" href="{{ route('bo.ticket.show', $linked->id) }}" title="{{ Str::ucfirst(__('crud.other.view_linked_ticket', ['model' => $linked->id])) }}">
|
||||
TICKET - {{ $linked->id }}
|
||||
<a class="btn btn-xl btn-outline-primary" target="_blank" href="{{ route('bo.ticket.show', $linked->id) }}" title="{{ Str::ucfirst(__('crud.other.view_linked_ticket', ['model' => $linked->id])) }}">
|
||||
TICKET - #{{ $linked->id }}
|
||||
</a>
|
||||
@can('linkTicket', $ticket)
|
||||
<button class="btn btn-xl btn-outline-danger" type="submit" title="{{ Str::ucfirst(__('crud.other.unlink_ticket', ['model' => $linked->id])) }}"><i class="fa-solid fa-link-slash"></i></button>
|
||||
|
|
@ -318,6 +322,7 @@
|
|||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<hr>
|
||||
@can('createGitlabIssue', $ticket)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue