Initial commit of testapi
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models\SmartdokProfile;
|
||||
|
||||
class SmartdokProfileController extends Controller
|
||||
{
|
||||
/**
|
||||
* List all users
|
||||
*
|
||||
* Returns a JSON array of all the smartdok users registered on the system
|
||||
*
|
||||
* @response \App\Models\SmartdokProfile
|
||||
*/
|
||||
public function index() {
|
||||
$profiles = SmartdokProfile::all()->map(function ($p) {
|
||||
return [
|
||||
'Id' => $p->id,
|
||||
'UserName' => $p->username,
|
||||
'Name' => $p->name,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json($profiles);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a user
|
||||
*
|
||||
* Returns a JSON array of all the smartdok users registered on the system
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* Example response:
|
||||
* {
|
||||
* "Id": "00000000-0000-0000-0000-000000000000",
|
||||
* "UserName": "string",
|
||||
* "Name": "string"
|
||||
* }
|
||||
*/
|
||||
public function show(string $id) {
|
||||
$p = SmartdokProfile::findOrFail($id);
|
||||
|
||||
return response()->json([
|
||||
'Id' => $p->id,
|
||||
'UserName' => $p->username,
|
||||
'Name' => $p->name,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user