Php 使用路由时找不到基表或视图
我有一个网站的管理方面的问题,我正在做。我在管理员端包含了4个链接,但当我单击其中任何一个链接时,我会出现以下错误: SQLSTATE[42S02]:未找到基表或视图:1146表“sonic.admins”不存在(SQL:select*fromPhp 使用路由时找不到基表或视图,php,sql,laravel,laravel-5.8,Php,Sql,Laravel,Laravel 5.8,我有一个网站的管理方面的问题,我正在做。我在管理员端包含了4个链接,但当我单击其中任何一个链接时,我会出现以下错误: SQLSTATE[42S02]:未找到基表或视图:1146表“sonic.admins”不存在(SQL:select*fromadmins其中id=外围设备限制1) 我不知道SQL查询来自哪里,因为据我所知,我没有运行任何SQL查询 我使用以下控制器作为一个断开链接的示例: Route::resource('/admin/games', 'AdminGamesController
admins
其中id
=外围设备限制1)
我不知道SQL查询来自哪里,因为据我所知,我没有运行任何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',
]]);
但是
很好
下面是我在上面的路由示例中使用的控制器:
<?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)
{
//
}
}
问题:路由相互冲突/重叠
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');
});
在blade文件中,可以通过以下blade语法访问游戏路线:
// 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'])}}
我认为问题来自您的一个auth/guest检查中间件。我删除了该中间件,但它仍在执行它在storage/logs/中查找堆栈跟踪,以查看其发生的位置。我没有在视图/布局中看到任何明显的内容,可能是视图/布局中的某个助手?
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'])}}