Skip to content
Advertisement

Getting Controller does not exist after moving my controller to sub folder in laravel 5

I have created a resource full route which was pointing to a CRUD controller in App/Http/Controller/SeatController.php my Route in api.php

Route::resource(‘websites’, ‘SeatController’);

I wanted to put all controllers related to Seat inside a directory. I created a directory named Seat and I moved all of my controllers related to Seat to it. it’s path is : AppHttpControllersSeatSeatController

before change it’s path was : AppHttpControllersSeatController

After above changes I added Seat directory name to my resource full route like :

Route::resource('websites', 'SeatSeatController');

But when I’m reaching this controller I get below error message :

Class AppHttpControllersSeatSeatController does not exist

UPDATE : my SeatController.php file is like :

<?php
namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppHttpRequests;
use AppSeat;
use Auth;
use Validator;

class SeatController extends Controller
{

When I change it to :

namespace AppHttpControllersSeat;

use IlluminateHttpRequest;
use AppHttpRequests;
use AppSeat;
use Auth;
use Validator;

class SeatController extends Controller
{

I Get this error message :

SeatController.php line 12:
Class 'AppHttpControllersSeatController' not found

any one knows how to fix this ?

Advertisement

Answer

Class AppHttpControllersSeatSeatController does not exist

This means controller can not find out the SeatController class. You should check following steps. Hope this will be worked for you.

First you have to check model call in your SeatController file is ok or not. And then check your namespace in SeatController is ok or not. Try with Something like below:

namespace AppHttpControllersSeat;

use AppSeat; \type your Model name instead of Seat
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement