在线移动项目打破了Laravel控制器

时间:2019-03-27 11:17:54

标签: laravel class controller http-method

那是我的路线:

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

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

这是失败的控制器方法:

<?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);

        }
    }
}

在我的在线服务器上,如果我尝试访问:

  

mysite.com/admin/co2index   它返回:    BadMethodCallException方法[adminCo2Index]不存在。在   Controller.php第82行:

在localhost上有效!另外,我在UserController类上还有其他方法,即使在网上也可以正常使用!
如果我在$companies$ddts_count上放置'null',则正确的空视图将加载到localhost上。如果我在网上做同样的事情,我仍然会有同样的错误! 如果我在方法的顶部放置一个dd('ciao'),错误仍然显示,并且前端没有消息...

这对我来说看起来很奇怪!我看不到任何错字...感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

点击此命令

composer dump-autoload