mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
API blueprint test
This commit is contained in:
1 parent
daf4850506
commit
c4e3282be8
5 files changed
+102
-6
No files matched your search
@@ -66,7 +66,7 @@ const options: Options = {
|
|||||||
'GET v1/teams/(id)': true,
|
'GET v1/teams/(id)': true,
|
||||||
'POST v1/teams/(id)': true,
|
'POST v1/teams/(id)': true,
|
||||||
'DELETE v1/teams/(id)': true,
|
'DELETE v1/teams/(id)': true,
|
||||||
'GET v1/teams': true,
|
'GET v1/teams': false,
|
||||||
'POST v1/teams': true,
|
'POST v1/teams': true,
|
||||||
|
|
||||||
'GET v1/employees': true,
|
'GET v1/employees': true,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export default {
|
|||||||
|
|
||||||
async created() {
|
async created() {
|
||||||
try {
|
try {
|
||||||
this.teams = await this.$axios.get_auth_data('v1/teams')
|
this.teams = await this.$axios.get_auth_data('http://127.0.0.1:8000/api/v1/teams')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.teams = {error: error.data.error}
|
this.teams = {error: error.data.error}
|
||||||
this.$toast.error(error.data.error)
|
this.$toast.error(error.data.error)
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class TeamController extends Controller
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new controller instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('api');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get()
|
||||||
|
{
|
||||||
|
return json_decode('{
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "Team 111",
|
||||||
|
"employees": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "Rastislav",
|
||||||
|
"surname": "Kuttner"
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"name": "Lenka",
|
||||||
|
"surname": "Nemeckova"
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"name": "Peter",
|
||||||
|
"surname": "Bucan"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"name": "Team 2",
|
||||||
|
"employees": [
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"name": "Peter",
|
||||||
|
"surname": "Bucan"
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": 5,
|
||||||
|
"name": "Pavel",
|
||||||
|
"surname": "Gajdos"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"name": "Team 3",
|
||||||
|
"employees": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "Rastislav",
|
||||||
|
"surname": "Kuttner"
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"name": "Lenka",
|
||||||
|
"surname": "Nemeckova"
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"name": "Peter",
|
||||||
|
"surname": "Bucan"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"status": 200
|
||||||
|
}');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,7 +39,7 @@ class Kernel extends HttpKernel
|
|||||||
],
|
],
|
||||||
|
|
||||||
'api' => [
|
'api' => [
|
||||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
\Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||||
'throttle:api',
|
'throttle:api',
|
||||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||||
],
|
],
|
||||||
|
|||||||
+6
-3
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use App\Http\Controllers\TeamController;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@@ -14,6 +15,8 @@ use Illuminate\Support\Facades\Route;
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
|
//Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
|
||||||
return $request->user();
|
// return $request->user();
|
||||||
});
|
//});
|
||||||
|
|
||||||
|
Route::get('/v1/teams', [TeamController::class, 'get']);
|
||||||
Reference in new issue
Block a user