protected function getHeaderActions(): array
{
$user = auth()->user();
if ($this->tenant->id != $user->team_id) {
return [
Actions\Action::make('Delete location')
->name('delete')
->icon('heroicon-m-x-mark')
->color('danger')
->requiresConfirmation()
->action(function () {
DeleteAction::make()
->record($this->tenant)
->successRedirectUrl(route('filament.dashboard.pages.dashboard', [
'tenant' => auth()->user()->team_id
]
));
Notification::make()
->success()
->title('Location deleted')
->body('The location has been deleted.')
->send();
}),
];
} else {
return [];
}
} public function teams(): BelongsToMany
{
return $this->belongsToMany(Team::class, 'team_user');
}$table->foreignId('team_id')->constrained()->on('teams')->onDelete('cascade'); protected function getHeaderActions(): array
{
$user = auth()->user();
if ($this->tenant->id != $user->team_id) {
return [
Actions\Action::make('Delete location')
->name('delete')
->icon('heroicon-m-x-mark')
->color('danger')
->requiresConfirmation()
->action(function (Team $team) {
$this->tenant->delete();
redirect(route('filament.dashboard.pages.dashboard', [
'tenant' => auth()->user()->team_id
]));
Notification::make()
->success()
->title('Location deleted')
->body('The location has been deleted.')
->send();
}),
];
} else {
return [];
}
}