- Added client_id field to StoreTenantRequest and UpdateTenantRequest for tenant management. - Updated TenantResource to include client_id in the response. - Created migration to establish clients table and link tenants to clients. - Migrated existing tenant integrations to client_integrations table. - Grouped specific tenants under a shared client (OnTicket) in a new migration. - Updated seeders to reflect new client structure and relationships. - Adjusted integration configurations to require client instead of tenant. - Added tests for client integration functionality and ensured existing tests reflect the new client structure.
48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Client\Controllers;
|
|
|
|
use App\Domains\Client\Models\Client;
|
|
use App\Domains\Client\Requests\StoreClientRequest;
|
|
use App\Domains\Client\Requests\UpdateClientRequest;
|
|
use App\Domains\Client\Resources\ClientResource;
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Response;
|
|
|
|
class ClientController extends Controller
|
|
{
|
|
public function index(): JsonResponse
|
|
{
|
|
return ClientResource::collection(
|
|
Client::query()->with('tenants')->latest()->paginateFromRequest()
|
|
)->response();
|
|
}
|
|
|
|
public function store(StoreClientRequest $request): JsonResponse
|
|
{
|
|
return ClientResource::make(
|
|
Client::query()->create($request->validated())->load('tenants')
|
|
)->response()->setStatusCode(201);
|
|
}
|
|
|
|
public function show(Client $client): ClientResource
|
|
{
|
|
return ClientResource::make($client->load('tenants'));
|
|
}
|
|
|
|
public function update(UpdateClientRequest $request, Client $client): ClientResource
|
|
{
|
|
$client->update($request->validated());
|
|
|
|
return ClientResource::make($client->fresh()->load('tenants'));
|
|
}
|
|
|
|
public function destroy(Client $client): Response
|
|
{
|
|
$client->delete();
|
|
|
|
return response()->noContent();
|
|
}
|
|
}
|