0

I have some problem with the controller. In my local repo as I serve the project it works! route: at web.php Route::get('/jobs', 'one\jobs\JobsController@index'); But as I tried at my company's server it didn't work! It says controller does not exist. I've compared the controller and web route but it is the same with my local one.

And here is my controller:

App\Http\Controllers\one\Jobs\JobsController;

    <?php
    
    namespace App\Http\Controllers\one\Jobs;
    
    use App\Http\Controllers\Controller;
    use Illuminate\Http\Request;
    use App\Library\One\ApiLibrary;
    use Alert;
    
    class JobsController extends Controller
    {
        public function __construct()
        {
            $this->apiLib = new ApiLibrary;
        }
        /**
         * Display a listing of the resource.
         *
         * @return \Illuminate\Http\Response
         */
        public function index(Request $request)
        {
            $token = $request->session()->get('token');
            $put['data'] = ['token' => $token];
            
            $this->apiLib->setParams($put['data']);
            $result = $this->apiLib->generate('GET','/api/jobs');
            
            if(!empty($result->status))
            {
                $data = $result->data;
                $action = $result->action->original;
    
                return view('one.jobs.jobsList',compact('data', 'action'));
            }else{
                $err_messages = "Server Error"; 
                return view('one.errors.errors', compact('err_messages'));
            }
        }
    }

got any idea how to fix this? Thanks in advance!

1 Answers1

0

The way you have referenced your controller is wrong:

Route::get('/jobs', 'one\jobs\JobsController@index');

Should be:

Route::get('/jobs', 'one\Jobs\JobsController@index');

You used a capital J in your controller namespace but a lowercase j when referencing it in your web.php. These things are case sensitive and should match the naming of files and folders for psr-4 autoloading.

Peppermintology
  • 9,343
  • 3
  • 27
  • 51