TyForHelpDude
TyForHelpDude

Reputation: 5002

laravel 5 routing controller to different directory

Route:

Route::resource('call-plan', 'CustomerCallPlanController');

Class

<?php 
namespace App\Http\Controllers\Customer;

use App\Http\Controllers\Controller;
use App\Http\Requests;
use Html;
use Illuminate\Http\Request;

class CustomerCallPlanController extends CustomerBaseController
{
    public function index()
    {
        dd('SUCCESS!');
    }

And I expect to see 'SUCCESS' message in blank page but I see this instead:

 ReflectionException in Container.php line 741:
    Class App\Http\Controllers\CustomerCallPlanController does not exist
    in Container.php line 741
    at ReflectionClass->__construct('App\Http\Controllers\CustomerCallPlanController') in Container.php line 741
    at Container->build('App\Http\Controllers\CustomerCallPlanController', array()) in Container.php line 631
    at Container->make('App\Http\Controllers\CustomerCallPlanController', array()) in Application.php line 674
    at Application->make('App\Http\Controllers\CustomerCallPlanController') in ControllerDispatcher.php line 85
    at ControllerDispatcher->makeController('App\Http\Controllers\CustomerCallPlanController') in ControllerDispatcher.php line 57
    at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\CustomerCallPlanController', 'index') in Route.php line 203

I see the message in exception tell App\Http\Controllers\CustomerCallPlanController it makes sense because my controller in Customer folder which means it should be App\Http\Controllers\Customer\CustomerCallPlanController How can I fix this

Upvotes: 0

Views: 445

Answers (1)

zeratulmdq
zeratulmdq

Reputation: 1494

You can use a relative path:

Route::resource('call-plan', 'Customer\CustomerCallPlanController');

Check the docs under Controllers & Namespaces

Upvotes: 1

Related Questions