surgiie
surgiie

Reputation: 4275

Laravel 5 Namespace issue fatal error exception

Im having this fatal error exception that i cant seem to figure out:

Class 'App\Http\Controllers\Admin\Controller' not found

For some reason im not sure why it is tacking controller at the end of that error. My namespace for the controller:

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Announcement;
use App\Http\Requests;

class AnnouncementController extends Controller
{
   ...
}

and my routes:

Route::group(['prefix' => 'admin','namespace'=>'Admin', 'middleware'=>'auth'], function () {


    Route::resource('announcements','AnnouncementController');



});

But when i navigate to the /admin/announcements route i get that fatal exception with the Controller tacked on at the end..

This controller is in the App\Http\Controllers\Admin directory so i m not sure why i m getting this error. Am i name spacing wrong?

Upvotes: 0

Views: 1009

Answers (1)

Achraf Khouadja
Achraf Khouadja

Reputation: 6279

Try this

Route

Route::group(['prefix' => 'admin', 'middleware'=>'auth'], function () {

    Route::resource('announcements','Admin\\AnnouncementController');

});

Controller

namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Announcement;
use App\Http\Requests;

class AnnouncementController extends Controller
{
   ...
}

if this dosent work, check if you have a Controller called Controller in app/Http/Controllers/

Upvotes: 1

Related Questions