mobile app api
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require __DIR__ . '/_bootstrap.php';
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/homes.php",
|
||||
* tags={"Homes"},
|
||||
* summary="My properties",
|
||||
* security={{"bearerAuth":{}}},
|
||||
* @OA\Response(response=200, description="OK", @OA\JsonContent(
|
||||
* @OA\Property(property="data", type="array", @OA\Items(ref="#/components/schemas/Home"))
|
||||
* )),
|
||||
* @OA\Response(response=401, ref="#/components/responses/Unauthorized")
|
||||
* )
|
||||
*/
|
||||
require_method('GET');
|
||||
$user = require_auth($pdo);
|
||||
|
||||
$stmt = $pdo->prepare('SELECT * FROM home WHERE iduser = ? ORDER BY idhome DESC');
|
||||
$stmt->execute([$user['id']]);
|
||||
$rows = $stmt->fetchAll();
|
||||
|
||||
$counts = home_counts($pdo, array_column($rows, 'idhome'));
|
||||
$homes = array_map(fn ($h) => present_home($h, true, $counts[(int) $h['idhome']] ?? null), $rows);
|
||||
|
||||
json_data($homes);
|
||||
Reference in New Issue
Block a user