I've got the following code in my api.php file:
Route::group(['prefix' => 'v1', 'middleware' => 'auth:api'], function() {
// Return user information
Route::get('/user', function(Request $request) {
return $request->user();
});
// Return user runs
Route::get('/runs', function(Request $request) {
$user = $request->user('api');
return $user->runs();
});
Route::get('/runs/{id}', function(Request $request, $id) {
$user = $request->user('api');
return $user->run($id);
});
// Return user profiles
Route::get('/profiles', function(Request $request) {
$user = $request->user('api');
return $user->profiles();
});
});
API Call
I'm testing the API using PostMan:
GET - http://srp.local/api/v1/runs/1
Authentication is done using a bearer token and this is working fine, I'm however having problems with the /runs/{id} call, all I want is for the call to return the run associated with that ID (basically a filtered version of the /runs call), but I'm struggling to get the parameter of the ID accross.
Currently, the code above works, but when trying to perform the aforementioned call, all it does is return the output for /user and doesn't return the run with the given ID.
I'm also not sure if I'm doing my routing optimally using the method above so any help would be appreciated - thank you.