PHP code example of sgcomptech / filament-ticketing
1. Go to this page and download the library: Download sgcomptech/filament-ticketing library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sgcomptech / filament-ticketing example snippets
return [
// Defines your user model. At the moment, can extend the package's TicketResource to customize to your needs.
'ticket-resource' => Sgcomptech\FilamentTicketing\Filament\Resources\TicketResource::class,
// whether a ticket must be strictly interacted with another model
'is_strictly_interacted' => false,
// filament navigation
'navigation' => [
'group' => 'Tickets',
'sort' => 1,
],
// ticket statuses
'statuses' => [
1 => 'Open',
2 => 'Pending',
3 => 'Resolved',
4 => 'Closed',
],
// ticket priorities
'priorities' => [
1 => 'Low',
2 => 'Normal',
3 => 'High',
4 => 'Critical',
],
// use authorization
'use_authorization' => false,
// event broadcast channel
'event_broadcast_channel' => 'ticket-channel',
];
use Illuminate\Database\Eloquent\Model;
use Sgcomptech\FilamentTicketing\Interfaces\HasTickets;
use Sgcomptech\FilamentTicketing\Traits\InteractsWithTickets;
class Item extends Model implements HasTickets
{
use InteractsWithTickets;
}
use Sgcomptech\FilamentTicketing\Tables\Actions\TicketAction;
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name'),
])
->actions([
EditAction::make(),
TicketAction::make('ticket'),
]);
}
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use Sgcomptech\FilamentTicketing\Interfaces\TicketPolicies;
use Sgcomptech\FilamentTicketing\Models\Ticket;
class TicketPolicy implements TicketPolicies
{
use HandlesAuthorization;
public function viewAny(User $user)
{
return true;
}
public function view(User $user, Ticket $ticket)
{
return true;
}
public function create(User $user)
{
return true;
}
public function update(User $user, Ticket $ticket)
{
return $user->can('manage all tickets')
|| $user->can('assign tickets')
|| ($user->can('manage assigned tickets') && $ticket->assigned_to_id == $user->id)
|| $ticket->user_id == $user->id;
}
public function delete(User $user, Ticket $ticket)
{
return $user->can('Delete Tickets');
}
public function manageAllTickets($user): bool
{
return $user->can('Manage All Tickets');
}
public function manageAssignedTickets($user): bool
{
return $user->can('Manage Assigned Tickets');
}
public function assignTickets($user): bool
{
return $user->can('Assign Tickets');
}
}