Laravel Action Route not Define

I have unique problem. I already create Route on web.php, on Controller, and Blade. and working on my localhost. but after publish to real server, I jus got error Action url\controller@function not define. this is my code.

Route::get('/timetableschedule', 'ManagementController@EmployeeTimeTable');

this is my web.php

public function EmployeeTimeTable(Request $request){
    $session = $request->session()->get('user.id');
    $companysession = $request->session()->get('user.location');
    $locationdata = DB::table('company')
    ->join('companyrole','companyrole.company_id','=','company.Company_id')
    ->join('users','users.id','=','companyrole.user_id')
    ->where('users.id',$session)
    ->get();

    $userlist = db::table('users')
    ->join('companyrole','users.id','companyrole.user_id')
    ->where('companyrole.company_id',$companysession)
    ->whereNotNull('users.NPK')
    ->select('users.id','users.name','users.NPK')
    ->orderby('users.name')
    ->get();

    $timesetting = db::table('time_leaving')
    ->where('company_id',$companysession)
    ->get();

    $leaveschedule = db::table('employee_leaving')
    ->join('users','employee_leaving.user_id','users.id')
    ->where('employee_leaving.company_id',$companysession)
    ->select('employee_leaving.leaving_date','users.name')
    ->get();

    return view('Management.employeetimetable',['location'=>$locationdata,'UserList'=>$userlist,'ListTimeSet'=>$timesetting,'LeavingSchedule'=>$leaveschedule]);
}

this is my controller

<li>
          <a href="{{action('ManagementController@EmployeeTimeTable')}}" class="dropdown-item">
            <p>Employee Timetable</p>
          </a>
        </li>

and this is code on blade to call controller@function

this step same as another controller, web, and blade.php. but, just for this rout get me a trouble. thank you

>Solution :

If your controller is on a subfolder, and not in app\Http\Controllers you will need to provide the fully qualified class name of the controller to the action helper :

action('App\Http\Controllers\Admin\ManagementController@EmployeeTimeTable')

by default action helper will look for : App\Http\Controllers\ManagementController

note that this syntax will not work as you might expect :

action('Admin\ManagementController@EmployeeTimeTable')

because laravel will not add App\Http\Controllers if there is a \ in the action name parameter

Leave a Reply