在线移动项目打破了Laravel控制器 [英] Moving project online broke laravel controller
问题描述
那是我的路线:
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 它返回: BadMethodCallException方法[adminCo2Index]不存在.在 Controller.php第82行:
mysite.com/admin/co2index it returns: BadMethodCallException Method [adminCo2Index] does not exist. in Controller.php line 82:
在localhost上有效!另外,我在UserController
类上还有其他方法,即使在网上也可以正常使用!
如果我在$companies
或$ddts_count
上放置'null',则正确的空视图将加载到localhost上.如果我在网上做同样的事情,我仍然会有同样的错误!
如果在方法的顶部放置dd('ciao')
,则错误仍然显示,并且前端无消息...
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!
推荐答案
点击此命令
composer dump-autoload
这篇关于在线移动项目打破了Laravel控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!