- 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.
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Livewire\Forms;
|
|
|
|
use App\Data\ConnectedApp\ConnectionProviderData;
|
|
use App\Models\ConnectionProvider;
|
|
use Closure;
|
|
use Illuminate\Support\Str;
|
|
use Livewire\Form;
|
|
|
|
class StoreConnectionProviderForm extends Form
|
|
{
|
|
public string $name = '';
|
|
|
|
public function set(ConnectionProviderData $data): void
|
|
{
|
|
$this->name = $data->name;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'name' => [
|
|
'required',
|
|
'string',
|
|
'min:3',
|
|
'max:255',
|
|
// Custom Closure to check the generated slug
|
|
function (string $attribute, mixed $value, Closure $fail): void {
|
|
$slug = Str::slug($value);
|
|
|
|
// Check if the slug already exists in your database table
|
|
$exists = ConnectionProvider::query()
|
|
->where('slug', $slug)
|
|
->exists();
|
|
|
|
if ($exists) {
|
|
$fail("The name '{$value}' is already taken. Please choose a different name.");
|
|
}
|
|
},
|
|
],
|
|
];
|
|
}
|
|
}
|