add location
This commit is contained in:
parent
e2cb4499bb
commit
78700a3c5a
@ -63,6 +63,28 @@ class ClientLocationController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified client id.
|
||||
*/
|
||||
public function getLocationsByClient(string $id)
|
||||
{
|
||||
try {
|
||||
$clientLocations = $this->clientLocationRepository->getByClientId((int)$id);
|
||||
return ClientLocationResource::collection($clientLocations);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Error fetching client location: ' . $e->getMessage(), [
|
||||
'exception' => $e,
|
||||
'trace' => $e->getTraceAsString(),
|
||||
'client_location_id' => $id,
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'message' => 'Une erreur est survenue lors de la récupération du lieu client.',
|
||||
'error' => config('app.debug') ? $e->getMessage() : null,
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified client location.
|
||||
*/
|
||||
|
||||
@ -12,4 +12,11 @@ class ClientLocationRepository extends BaseRepository implements ClientLocationR
|
||||
{
|
||||
parent::__construct($model);
|
||||
}
|
||||
|
||||
public function getByClientId(int $client_id)
|
||||
{
|
||||
$query = $this->model->newQuery();
|
||||
$query->where('client_id', $client_id);
|
||||
return $query->get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,5 +6,5 @@ namespace App\Repositories;
|
||||
|
||||
interface ClientLocationRepositoryInterface extends BaseRepositoryInterface
|
||||
{
|
||||
// Add ClientLocation-specific methods here later if needed
|
||||
function getByClientId(int $client_id);
|
||||
}
|
||||
|
||||
@ -39,8 +39,9 @@ Route::middleware('auth:sanctum')->group(function () {
|
||||
|
||||
Route::apiResource('clients', ClientController::class);
|
||||
Route::apiResource('client-groups', ClientGroupController::class);
|
||||
Route::apiResource('client-locations', ClientLocationController::class);
|
||||
|
||||
Route::apiResource('client-locations', ClientLocationController::class);
|
||||
Route::get('clients/{clientId}/locations', [ClientLocationController::class, 'getLocationsByClient']);
|
||||
|
||||
// Contact management
|
||||
Route::apiResource('contacts', ContactController::class);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user