Search code examples
phpsqllaravellaragon

Laravel 5.8. Target class [Controller] does not exist


I am trying to create a view with four inputs which all enter that data into an sql database (using Laragon).

When I try click on the submit button I get an error saying "Target class [BikeController] does not exist."

Here is my controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class BikeController extends Controller
{
    function add(Request $req)
    {
print_r($req->input());
    }
}

Here is my routes

<?php

use Illuminate\Support\Facades\Route;
use \app\Http\Controllers\BikeController;


Route::view('/add', 'addView');


Route::post('/add', 'BikeController@add');


Route::get('/', function (){

    return view('bikesView');

});

Route::get('/delete', function (){

    return view('deleteView');

});

Route::get('/edit', function (){

    return view('editView');

});

Link to a pic of my file structure

Currently I'm just trying to print out the data input on the screen but will eventually link it to mysql.


Solution

  • => Open App\Providers\RouteServiceProvider.php and uncomment this line
    
    protected $namespace = 'App\\Http\\Controllers';