繁体   English   中英

Laravel Lumen无法识别共享主机中的表

[英]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.

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