Skip to content

Commit 982405a

Browse files
committed
test api
1 parent 5cd376f commit 982405a

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

Diff for: app/Http/Controllers/TestController.php

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
7+
class TestController extends Controller
8+
{
9+
public function index() {
10+
$data = [
11+
[
12+
'first_name' => 'Sajeeva',
13+
'last_name' => 'Hasith',
14+
'location' => 'Colombo'
15+
],
16+
[
17+
'first_name' => 'Anjana',
18+
'last_name' => 'Porawagama',
19+
'location' => 'Colombo'
20+
]
21+
];
22+
23+
return response()->json($data, 200);;
24+
}
25+
}

Diff for: routes/api.php

+2
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@
1616
Route::middleware('auth:api')->get('/user', function (Request $request) {
1717
return $request->user();
1818
});
19+
20+
Route::get('users', 'TestController@index');

Diff for: routes/web.php

+4
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@
1414
Route::get('/', function () {
1515
return view('welcome');
1616
});
17+
18+
Route::get('/test', function () {
19+
return ["message" => "test api"];
20+
});

0 commit comments

Comments
 (0)