init
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
Flight::route('GET /v1/api/image/get/@id', function($id)
|
||||
{
|
||||
|
||||
$model = new ImagesModel();
|
||||
$result = $model->get($id);
|
||||
$output = [];
|
||||
if ($result)
|
||||
{
|
||||
$allow_fields = ['id', 'url', 'user_id', 'caption'];
|
||||
|
||||
foreach ($result as $key => &$value)
|
||||
{
|
||||
if (in_array($key, $allow_fields))
|
||||
{
|
||||
$output[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'code' => 200,
|
||||
'error' => false,
|
||||
'model' => $output
|
||||
]);
|
||||
http_response_code(200);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode([
|
||||
'code' => 404,
|
||||
'error' => true
|
||||
]);
|
||||
http_response_code(404);
|
||||
exit;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user