[英]Laravel Lumen cannot recognize table in shared hosting
我在Laravel服務器上發出請求時遇到問題
SQLSTATE [42S02]:找不到基表或視圖:1146表'dbdespensa.imagenesProducto'不存在(SQL:從
imagenesProducto
中選擇*,其中productoId
= 5)
我有imagenesProducto表,但是laravel無法識別它
謝謝和幫助:)
namespace App\Http\Controllers;
use App\ImagenesProducto;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Database\Eloquent\ModelNotFoundException;
class ImagenesProductoController extends Controller
{
function getImagesByProduct(Request $request,$id){
if($request-> isJson()){
try{
$images = ImagenesProducto::where('productoId','=',$id)->get();
return response()->json($images,200);
}catch(ModelNotFoundException $e){
return response()->json("error"=>"error",500);
}
}else{
return response()->json(['error'=>'Unhatorized'], 401, []);
}
}
}
其他數據庫查詢是否成功? (如果不是,則應檢查.env文件的數據庫配置)
也許您在模型中遇到問題。 您應該在模型中指定表名稱。
class ImagenesProducto extends Model{
public $table = "imagenesProducto";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.