0
votes

I have a problem when I make a request on my Laravel server

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dbdespensa.imagenesProducto' doesn't exist (SQL: select * from imagenesProducto where productoId = 5)

I have the imagenesProducto table but laravel didnt recognize it

Thanks and help :)

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, []);
    }
}

}

1
Show us the request you're making. - Ohgodwhy
localhost:8080/server/getcarousel/5 this is the request adn the server send me the error in the detail - Rockos95

1 Answers

0
votes

Are other database queries successful? (if not you should check .env file for db config)

Or maybe you have problem in model. You should specify table name in model.

class ImagenesProducto extends Model{
public $table = "imagenesProducto";