Базовая таблица или представление не найдено при использовании маршрутов

У меня проблема с административной частью сайта, который я делаю. Я включил на стороне администратора 4 ссылки, но когда я нажимаю на любую из них, я получаю эту ошибку:

SQLSTATE[42S02]: базовая таблица или представление не найдены: 1146 Таблица sonic.admins не существует (SQL: выберите * из admins, где id = ограничение периферийных устройств 1)

Я понятия не имею, откуда берется этот SQL-запрос, поскольку, насколько мне известно, я его не запускаю.

Я использую следующий контроллер в качестве примера одной неработающей ссылки:

Route::resource('/admin/games', 'AdminGamesController', ['names'=>[
  'index'=>'games.index',
  'create'=>'games.create',
  'store'=>'games.store',
  'edit'=>'games.edit',
  'show'=>'games.show',
  'destroy'=>'games.destroy',
  ]]);

но

Route::resource('/admin', 'AdminController', ['names'=>[
  'index'=>'admin.index',
  'create'=>'admin.create',
  'store'=>'admin.store',
  'edit'=>'admin.edit',
  'show'=>'admin.show',
  'destroy'=>'admin.destroy',
  ]]);

работает отлично.

Вот контроллер, который я использую для приведенного выше примера маршрутизации:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class AdminGamesController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return 'test';
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}

вот ссылки

<div class="list-group list-group-flush">
  <a href="{{route('home.index')}}" class="list-group-item list-group-item-action"><i class="fas fa-home"></i>&nbsp;&nbsp;Home</a>
  <a href="{{route('games.index')}}" class="list-group-item list-group-item-action"><i class="fas fa-home"></i>&nbsp;&nbsp;Games</a>
  <a href="{{route('figures.index')}}" class="list-group-item list-group-item-action"><i class="fas fa-user-friends"></i>&nbsp;&nbsp;Figures</a>
  <a href="{{route('guides.index')}}" class="list-group-item list-group-item-action"><i class="fas fa-user-friends"></i>&nbsp;&nbsp;Guides</a>
  <a href="{{route('peripherals.index')}}" class="list-group-item list-group-item-action"><i class="fas fa-user-tie"></i>&nbsp;&nbsp;Peripherals</a>
</div>

person Matt B    schedule 04.07.2019    source источник
comment
Я думаю, что проблема связана с одним из ваших промежуточных программ аутентификации/гостевой проверки.   -  person Latheesan    schedule 04.07.2019
comment
Я удалил промежуточное программное обеспечение, но оно все еще работает.   -  person Matt B    schedule 04.07.2019
comment
поищите трассировку стека в хранилище/журналах/, чтобы узнать, откуда это происходит.   -  person Latheesan    schedule 04.07.2019
comment
Я не вижу там ничего очевидного   -  person Matt B    schedule 04.07.2019
comment
Может быть, какой-нибудь помощник внутри представления/макета?   -  person Robbin Benard    schedule 04.07.2019


Ответы (1)


ПРОБЛЕМА: маршруты конфликтуют/накладываются друг на друга

admin/{admin}  // This is admin route URL
admin/games    // and this is from admin games route URL

Route::group([
    'prefix' => 'admins',  // Here we need to do something different
    'as'     => 'admin.'
],function () {
    Route::resource('admin','AdminController');
});
// http://localhost/project_name/public/admins/admin
Route::group([
    'prefix' => 'admin',
    'as'     => 'admin.'
],function () {
    Route::resource('games','AdminGamesController');
});

// http://localhost/awsupload/public/admin/games

Вот что я пробовал на своем маршруте ТОЛЬКО для игр администратора, и это работает нормально

Route::group([
    'prefix' => 'admin',
    'as'     => 'admin.'
],function () {
    Route::resource('games','AdminGamesController');
});

введите здесь описание изображения

В файле блейда маршруты игр доступны с помощью следующего синтаксиса блейда:

    // Games Listing
    {{route('admin.games.index')}}

    // Save game to the database
    {{route('admin.games.store')}}

    // Create Game form/page
    {{route('admin.games.create')}}

    // Show single game details
    {{route('admin.games.show',['game_id'])}}

    // Show edit form for single game
    {{route('admin.games.edit',['game_id'])}}

    // Update single game details
    {{route('admin.games.update',['game_id'])}}

    // Remove/Delete single game
    {{route('admin.games.destroy',['game_id'])}}
person Vipertecpro    schedule 06.07.2019