简体   繁体   English

没有有关模型[App \\ Models \\ Setting] 1的查询结果

[英]No query results for model [App\Models\Setting] 1

I have been getting this error in my application when i try to sign in as an admin onto my application. 当我尝试以管理员身份登录到我的应用程序时,我的应用程序中出现此错误。 But when i sign in as normal user, it works fine. 但是当我以普通用户身份登录时,它可以正常工作。 Reading other solutions, i have made sure my routes are also in order to solve this issue but nothing has changed. 在阅读其他解决方案时,我已确保我的路线也可以解决此问题,但没有任何更改。

What could be causing this to prevent my admin from logging into the admin page please? 是什么原因导致阻止我的管理员登录到管理员页面?

PS: i can't really tell where the error is coming from now. PS:我真的不能说出错误从哪里来。

Routes 路线

    Route::auth();
    Route::get('/logout', 'Auth\LoginController@logout');
    Route::get('/', 'PagesController@show');


    Route::group(array('prefix' => 'client', 'namespace' => 'User', 'middleware' => ['auth']), function () {


        Route::get('/dashboard', 'DashboardController@create');


    });

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

    /**
     * Main
     */
        Route::get('dashboard', 'PagesController@dashboard')->name('dashboard');

    /**
     * Users
     */
    // Route::group(['prefix' => 'users'], function () {
        Route::get('/data', 'UsersController@anyData')->name('users.data');
        Route::get('/taskdata/{id}', 'UsersController@taskData')->name('users.taskdata');
        Route::get('/leaddata/{id}', 'UsersController@leadData')->name('users.leaddata');
        Route::get('/clientdata/{id}', 'UsersController@clientData')->name('users.clientdata');
        Route::get('/users', 'UsersController@users')->name('users.users');
        Route::post('/upload/{id}', 'FileController@upload');

        Route::resource('users', 'UsersController');

     /**
     * Roles
     */
        Route::resource('roles', 'RolesController');
    /**
     * Clients
     */
    Route::group(['prefix' => 'clients'], function () {
        Route::get('/data', 'ClientsController@anyData')->name('clients.data');
        Route::post('/create/cvrapi', 'ClientsController@cvrapiStart');
        Route::post('/upload/{id}', 'DocumentsController@upload');
        Route::patch('/updateassign/{id}', 'ClientsController@updateAssign');
    });
        Route::resource('clients', 'ClientsController');
        Route::resource('documents', 'DocumentsController');


    /**
     * Tasks
     */
    Route::group(['prefix' => 'tasks'], function () {
        Route::get('/data', 'TasksController@anyData')->name('tasks.data');
        Route::patch('/updatestatus/{id}', 'TasksController@updateStatus');
        Route::patch('/updateassign/{id}', 'TasksController@updateAssign');
        Route::post('/updatetime/{id}', 'TasksController@updateTime');
    });
        Route::resource('tasks', 'TasksController');

    /**
     * Leads
     */
    Route::group(['prefix' => 'leads'], function () {
        Route::get('/data', 'LeadsController@anyData')->name('leads.data');
        Route::patch('/updateassign/{id}', 'LeadsController@updateAssign');
        Route::patch('/updatestatus/{id}', 'LeadsController@updateStatus');
        Route::patch('/updatefollowup/{id}', 'LeadsController@updateFollowup')->name('leads.followup');
    });
        Route::resource('leads', 'LeadsController');
        Route::post('/comments/{type}/{id}', 'CommentController@store');
    /**
     * Settings
     */
    Route::group(['prefix' => 'settings'], function () {
        Route::get('/', 'SettingsController@index')->name('settings.index');
        Route::patch('/permissionsUpdate', 'SettingsController@permissionsUpdate');
        Route::patch('/overall', 'SettingsController@updateOverall');
    });

    /**
     * Departments
     */
        Route::resource('departments', 'DepartmentsController'); 

    /**
     * Integrations
     */
    Route::group(['prefix' => 'integrations'], function () {
        Route::get('Integration/slack', 'IntegrationsController@slack');
    });
        Route::resource('integrations', 'IntegrationsController');

    /**
     * Notifications
     */
    Route::group(['prefix' => 'notifications'], function () {
        Route::post('/markread', 'NotificationsController@markRead')->name('notification.read');
        Route::get('/markall', 'NotificationsController@markAll');
        Route::get('/{id}', 'NotificationsController@markRead');
    });

    /**
     * Invoices
     */
    Route::group(['prefix' => 'invoices'], function () {
        Route::post('/updatepayment/{id}', 'InvoicesController@updatePayment')->name('invoice.payment.date');
        Route::post('/reopenpayment/{id}', 'InvoicesController@reopenPayment')->name('invoice.payment.reopen');
        Route::post('/sentinvoice/{id}', 'InvoicesController@updateSentStatus')->name('invoice.sent');
        Route::post('/newitem/{id}', 'InvoicesController@newItem')->name('invoice.new.item');
    });
        Route::resource('invoices', 'InvoicesController');
});

Error is 错误是

ModelNotFoundException No query results for model [App\\Models\\Setting] 1 in Builder.php (line 312) and Handler.php (line 69) ModelNotFoundException在Builder.php(第312行)和Handler.php(第69行)中没有对模型[App \\ Models \\ Setting] 1的查询结果

Rewrite your route as follow 如下重写路线

Route::group(['middleware' => ['auth:admin']], function () {
    Route::get('dashboard', 'PagesController@dashboard')->name('dashboard');
});

Please note that ['middleware' => ['auth:admin'] . 请注意, ['middleware' => ['auth:admin']
Here admin is the gaurd name. 此处admin是gaurd名称。

This is happening due to your Setting model. 这是由于您的Setting模型而发生的。 you are accessing record of setting model which is not available. 您正在访问的设置模型记录不可用。

ex. 例如 Setting::findOrFail(1);

So if model is not found then it will throw an exception ModelNotFoundException 因此,如果未找到模型,则它将引发异常ModelNotFoundException

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM