- Introduced `HandlesOperations` trait for reusable error handling with toasts and logging. - Added `StoreConnectionProviderForm` Livewire component with validation and slug uniqueness check. - Implemented `StoreConnectionProviderRequestData` DTO for structured data handling. - Updated `ConnectionProviderService` to include `create()` method using database transactions. - Registered new routes for creating connection providers. - Enhanced `ConnectionProvider` model with `Fillable` attribute for `name` and `slug`.
32 lines
797 B
PHP
32 lines
797 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Data\ConnectedApp\StoreConnectionProviderRequestData;
|
|
use App\Models\ConnectionProvider;
|
|
use Illuminate\Support\Collection;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class ConnectionProviderService
|
|
{
|
|
public function create(StoreConnectionProviderRequestData $requestData): void
|
|
{
|
|
DB::transaction(function () use ($requestData): void {
|
|
ConnectionProvider::query()->create($requestData->toArray());
|
|
});
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, ConnectionProvider>
|
|
*/
|
|
public function search(string $value): Collection
|
|
{
|
|
return ConnectionProvider::query()
|
|
->whereLike('slug', "%{$value}%")
|
|
->orWhereLike('name', "%{$value}%")
|
|
->get();
|
|
}
|
|
}
|