Moving project online broke laravel controller

有些话、适合烂在心里 提交于 2019-12-11 23:50:31

问题


That's my route:

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

  Route::get('/co2index', 'UserController@adminCo2Index');
}

This is the controller method that fails:

<?php

namespace App\Http\Controllers;

use App\Http\Impl\ReferentManager;
use App\Http\Impl\RoleManager;
use App\Http\Impl\UserManager;
use App\Http\Impl\ValidationRulesManager;
use App\Models\User;
use App\Notifications\UserActivatedNotification;
use App\Models\Vendita;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Models\Referent;
use App\Models\Ddt;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\DB;
use Maatwebsite\Excel\Facades\Excel;
use Illuminate\Support\Facades\Session;

class UserController extends Controller
{
    public function adminCo2Index()
    {
        $search = \Request::get('search'); //<-- we use global request to get the param of URI
        $companies = User::where('name', 'like', '%' . $search . '%')->orderBy('name')
            ->paginate(10);
        $ddts_count = DB::table('ddts')
            ->select('company_id', DB::raw('count(*) as total'))
            ->groupBy('company_id')
            ->get();

        if ($companies && $ddts_count) {
            return view('administration.co2Index')->with('companies', $companies)->with('ddts_count', $ddts_count);

        } else {
            return view('administration.co2Index')->with('companies', null)->with('ddts_count', null);

        }
    }
}

on my online server if I try to visit:

mysite.com/admin/co2index it returns: BadMethodCallException Method [adminCo2Index] does not exist. in Controller.php line 82:

On localhost it works! Also, I have other methods on UserController class that work even online without any problem!
If I put 'null' on $companies or $ddts_count the correct empty view is loaded on localhost. If I do the same thing online I have still the same error! If I put a dd('ciao') on the top of the method the error is still showed and no message on front end...

This looks very strange to me! I can't see any typos... thanks for the help!


回答1:


hit this command

composer dump-autoload


来源:https://stackoverflow.com/questions/55375916/moving-project-online-broke-laravel-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!