This commit is contained in:
Bozhidar Slaveykov 2024-04-03 12:56:10 +03:00
parent f8728818f8
commit 36cf4a816f
7 changed files with 89 additions and 11 deletions

View file

@ -2,7 +2,6 @@
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Api\Request\CustomerCreateRequest;
use App\Http\Controllers\ApiController;
use App\Models\Customer;

View file

@ -20,6 +20,8 @@ class HealthController extends ApiController
*/
public function index()
{
file_put_contents('test.txt', 'test');
return response()->json(['status' => 'ok']);
}
}

View file

@ -0,0 +1,20 @@
<?php
namespace App\Http\Controllers\Api\Request;
class AuthLoginRequest extends ApiRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'email' => 'required|string|email',
'password' => 'required|string',
// 'browserAgent' => 'required|string',
];
}
}

View file

@ -2,6 +2,8 @@ PHYRE_PHP=/usr/local/phyre/php/bin/php
#rm -rf composer.lock
#$PHYRE_PHP composer.phar i
#$PHYRE_PHP composer.phar dump-autoload
$PHYRE_PHP artisan migrate
$PHYRE_PHP artisan l5-swagger:generate

View file

@ -16,13 +16,18 @@ use Illuminate\Support\Facades\Route;
Route::get('health', [\App\Http\Controllers\Api\HealthController::class, 'index']);
Route::middleware('auth:sanctum')->group(function () {
Route::get('/user', function (Request $request) {
return $request->user();
});
Route::get('customers', [\App\Http\Controllers\Api\CustomersController::class, 'index']);
Route::post('customers', [\App\Http\Controllers\Api\CustomersController::class, 'store']);
Route::get('customers/{id}', [\App\Http\Controllers\Api\CustomersController::class, 'show']);
Route::put('customers/{id}', [\App\Http\Controllers\Api\CustomersController::class, 'update']);
Route::delete('customers/{id}', [\App\Http\Controllers\Api\CustomersController::class, 'destroy']);
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user();
});

View file

@ -8,9 +8,59 @@
"version": "0.1"
},
"paths": {
"/health": {
"/api/customers": {
"get": {
"operationId": "14039960f5c35aafcd0adcc381fc5f34",
"operationId": "6f01ddd63e2a72fee24eb31157a1c799",
"responses": {
"200": {
"description": "Successful operation"
}
}
},
"post": {
"operationId": "cef1c1e98a7505ddd8d797aba6787da4",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"required": [
"name",
"email",
"phone"
],
"properties": {
"name": {
"description": "Name of the customer",
"type": "string",
"example": "John Doe"
},
"email": {
"description": "Email of the customer",
"type": "string",
"example": "jhon@gmail.com"
},
"phone": {
"description": "Phone of the customer",
"type": "string",
"example": "1234567890"
}
},
"type": "object"
}
}
}
},
"responses": {
"200": {
"description": "Successful operation"
}
}
}
},
"/api/health": {
"get": {
"operationId": "c873d7f3d9f52c19cd7a1b4bebfe02df",
"responses": {
"200": {
"description": "Successful operation"