Adding some additional information ...
- the url path shows "http://localhost/api/students?search=lee&page=1" when it fails
- nothing shows up in laravel.log
My routes/api.php does not have anything related as it is in routes/backback/custom.php as my above post
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
My api code is found in /App/Http/Controllers/Api/StudentController.php
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Student;
class StudentController extends Controller
{
public function index(Request $request) {
...
If I run artisan route:list I get target class [App\Http\Controlllers\Admin\Http\Controllers\Api\StudentControllre] does not exist
If I edit my routes/backpack/custom.php to
<?php
use App\Http\Controllers\Admin\CenterSwitchController;
use App\Http\Controllers\Admin\DashboardController;
use App\Http\Controllers\Admin\ReconciliationTransactionController;
Route::group([
'prefix' => config('backpack.base.route_prefix', 'admin'),
'middleware' => array_merge(
(array) config('backpack.base.web_middleware', 'web'),
(array) config('backpack.base.middleware_key', 'admin'),
// (array) config('backpack.base.middleware_class')
),
'namespace' => 'App\Http\Controllers\Admin',
], function () { // custom admin routes
Route::crud('centre', 'CentreCrudController');
...
});
Route::group([
'prefix' => 'api',
'middleware' => array_merge(
(array) config('backpack.base.web_middleware', 'web'),
(array) config('backpack.base.middleware_key', 'admin')
),
'namespace' => 'App\Http\Controllers\Api',
], function () {
Route::get('students', 'StudentController@index');
});
There will be no more errors displayed when I run artisan route:list but the 404 still exists and the url is still http://localhost/api/students?search=eee&page=1