使用路由时找不到基本表或视图

时间:2019-07-04 14:20:15

标签: php sql laravel laravel-5.8

我正在做的网站的管理员方面有问题。我在管理端包含了4个链接,但是当我单击其中任何一个链接时,都会出现此错误:

  

SQLSTATE [42S02]:找不到基本表或视图:1146表'sonic.admins'不存在(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', ]]); =外设限制1)

我不知道该SQL查询来自何处,因为据我所知没有运行任何

我使用以下控制器作为一个断开链接的示例:

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

工作正常。

这是我在上面的示例路由中使用的控制器:

push "redirect-gateway def1"

这是链接

push "route 172.168.1.0 255.255.255.0 vpn_gateway 1"
push "route 172.168.2.0 255.255.255.0 vpn_gateway 2"

1 个答案:

答案 0 :(得分:0)

问题:路由相互冲突/重叠

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');
});

enter image description here

在刀片文件中,可以通过以下刀片语法访问游戏路线:

    // 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'])}}