Skip to content

Commit

Permalink
feat(info): add info route
Browse files Browse the repository at this point in the history
  • Loading branch information
tikrack committed Jan 29, 2025
1 parent 54002b6 commit 8bfc959
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions app/Http/Controllers/InfoController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Http\Controllers;

use App\Http\Trait\ApiResponseTrait;
use Illuminate\Http\Request;

class InfoController extends Controller
{
use ApiResponseTrait;

public function info(Request $request)
{
$user = $request->user();
$code_count = $user?->codes()?->count();

return $this->success([
"user" => [
"name" => $user->name,
"family" => $user->family,
],
"code" => [
"count" => $code_count,
]
]);
}
}
2 changes: 2 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use App\Http\Controllers\Auth\AuthController;
use App\Http\Controllers\CodeController;
use App\Http\Controllers\InfoController;
use Illuminate\Support\Facades\Route;

Route::name('api.')->group(function () {
Expand All @@ -15,6 +16,7 @@
Route::post('codes', [CodeController::class, 'codes'])->name('codes');
Route::post('code', [CodeController::class, 'store'])->name('code');
Route::delete('code', [CodeController::class, 'destroy'])->name('code');
Route::post('info', [InfoController::class, 'info'])->name('info');
});
});
});

0 comments on commit 8bfc959

Please sign in to comment.