- Added `ConnectionProviderData`, `NavItemData`, and `NavSubItemData` DTOs for structured data handling. - Implemented CRUD operations for `ConnectionProviderService`, including transaction-safe create, update, and delete methods. - Introduced Livewire components for ConnectionProvider list, edit, and create pages with dynamic and reusable UI elements. - Refactored routes to consolidate paths under the `apps` prefix and updated navigation to dynamically include new sections for providers. - Enhanced sidebar with structured submenu for ConnectionProviders and Settings using dynamic collections. - Updated existing Create and Edit templates to use consistent route naming and validation handling. - Replaced hardcoded navigation items with dynamically generated structures leveraging the `NavItemData` collection.
80 lines
2.4 KiB
PHP
80 lines
2.4 KiB
PHP
<?php
|
|
|
|
use App\Concerns\HandlesOperations;
|
|
use App\Data\Ui\TableHeader;
|
|
use App\Services\ConnectionProviderService;
|
|
use Livewire\Attributes\Computed;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
use Spatie\LaravelData\Attributes\DataCollectionOf;
|
|
use Spatie\LaravelData\DataCollection;
|
|
|
|
new class extends Component {
|
|
use WithPagination, HandlesOperations;
|
|
|
|
protected ConnectionProviderService $service;
|
|
|
|
#[DataCollectionOf(TableHeader::class)]
|
|
public DataCollection $headers;
|
|
|
|
public function boot(ConnectionProviderService $service): void
|
|
{
|
|
$this->service = $service;
|
|
}
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->initTableHeaders();
|
|
}
|
|
|
|
private function initTableHeaders(): void
|
|
{
|
|
$this->headers = TableHeader::collect([
|
|
new TableHeader(key: 'name', label: 'Name',),
|
|
], DataCollection::class);
|
|
}
|
|
|
|
#[Computed]
|
|
public function getAllProviders()
|
|
{
|
|
return $this->service->getAll();
|
|
}
|
|
|
|
public function edit(string $providerSlug): void
|
|
{
|
|
$this->redirectRoute('apps.connectionProviders.edit', ['slug' => $providerSlug]);
|
|
}
|
|
|
|
public function delete(string $providerSlug): void
|
|
{
|
|
$this->attempt(
|
|
action: fn() => $this->service->delete($providerSlug),
|
|
successMessage: "Connection Provider deleted!"
|
|
);
|
|
|
|
}
|
|
};
|
|
?>
|
|
|
|
<div>
|
|
<x-shared.card title="Connection Providers" class="pb-2">
|
|
<x-slot:actions>
|
|
<x-mary-button :link="route('apps.connectionProviders.create')" wire:navigate icon="lucide.plus">Add
|
|
Provider
|
|
</x-mary-button>
|
|
</x-slot:actions>
|
|
<x-mary-table :headers="$headers->toArray()" :rows="$this->getAllProviders->items()" with-pagination>
|
|
@scope('actions', $row)
|
|
<div class="flex">
|
|
<x-mary-button icon="lucide.edit" wire:click="edit('{{$row->slug}}')" spinner="edit('{{$row->slug}}')"
|
|
class="mr-2 btn-sm text-gray-500"/>
|
|
<x-mary-button icon="lucide.trash" wire:click="delete('{{$row->slug}}')"
|
|
spinner="delete('{{$row->slug}}')"
|
|
variant="danger"
|
|
class="btn-sm btn-error btn-soft"/>
|
|
</div>
|
|
@endscope
|
|
</x-mary-table>
|
|
</x-shared.card>
|
|
</div>
|