- Created ExampleTest and RoutesTest for basic application response and route testing. - Implemented IsolatedDatabaseTestCase for isolated database testing. - Added unit tests for various models and services including Contract, CPE, and LeadDetail. - Developed request validation tests for CreateClientRequest, UpdateClientRequest, and ContractRequest. - Introduced Vite configuration for asset management in the Laravel application.
93 lines
2.4 KiB
PHP
93 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\ContractRequest;
|
|
use App\Http\Requests\RenewContractRequest;
|
|
use App\Services\ContractService;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ContractController extends Controller
|
|
{
|
|
public function __construct(private ContractService $contracts)
|
|
{
|
|
}
|
|
|
|
public function index(Request $request)
|
|
{
|
|
return response()->json($this->contracts->index($request));
|
|
}
|
|
|
|
public function options(Request $request)
|
|
{
|
|
return response()->json($this->contracts->create($request));
|
|
}
|
|
|
|
public function show(string $id)
|
|
{
|
|
return response()->json($this->contracts->show($id));
|
|
}
|
|
|
|
public function edit(string $id)
|
|
{
|
|
return response()->json($this->contracts->edit($id));
|
|
}
|
|
|
|
public function store(ContractRequest $request)
|
|
{
|
|
return response()->json(['contract' => $this->contracts->store($request)], 201);
|
|
}
|
|
|
|
public function update(ContractRequest $request, string $id)
|
|
{
|
|
return response()->json(['contract' => $this->contracts->update($request, $id)]);
|
|
}
|
|
|
|
public function renewalOptions(string $id)
|
|
{
|
|
return response()->json($this->contracts->renewForm($id));
|
|
}
|
|
|
|
public function renew(RenewContractRequest $request, $id)
|
|
{
|
|
return response()->json(['contract' => $this->contracts->renew($request, $id)]);
|
|
}
|
|
|
|
public function history($id)
|
|
{
|
|
return response()->json($this->contracts->history($id));
|
|
}
|
|
|
|
public function showHistory($id, $historyId)
|
|
{
|
|
return response()->json($this->contracts->editHistory($id, $historyId));
|
|
}
|
|
|
|
public function updateHistory(Request $request, $id, $historyId)
|
|
{
|
|
return response()->json(['history' => $this->contracts->updateHistory($request, $id, $historyId)]);
|
|
}
|
|
|
|
public function destroyHistory($id, $historyId)
|
|
{
|
|
$this->contracts->destroyHistory($id, $historyId);
|
|
return response()->json(['message' => 'Registo eliminado com sucesso.']);
|
|
}
|
|
|
|
public function destroy(string $id)
|
|
{
|
|
return response()->json($this->contracts->destroy($id));
|
|
}
|
|
|
|
public function bulkDestroy(Request $request)
|
|
{
|
|
return response()->json($this->contracts->bulkDestroy($request));
|
|
}
|
|
|
|
public function export(Request $request)
|
|
{
|
|
return $this->contracts->export($request);
|
|
}
|
|
}
|