I am doing this query
$ventas = VentasProductos::select('id_factura','=' ,$id);
to a database table from a Controller InvoiceController and when I check the number of elements it returns me that elements exist but when displaying them in a view it does not return values. How can i solve this?
The query to use an Eloquent would be:
That would be a query to the model you made. It is not
select
since that is used to specify fields of the model you created.Now you have to have the model imported into the Controller you created for it to work as well. But if that's not the case you can use
DB
deQuery Builder
which I don't recommend but it's used for queries that don't use models created in your project.Your query is fine but it is incomplete, that is, once you execute these operations you have to indicate it with another method to return the results, in this case, since you are making a query with a filter at the end, you must have access to the get() method. ;
then it should be: