So, I have a Product model which belongsTo('App\Tax'). A Product may or may not be associated with a Tax (the tax_id fk in Product could be null).
The query below works fine as long as I have at least one Product associated with a Tax:
\App\Product::with("tax")->get()
It starts throwing the following exception, when none of the Product's have associated Taxes:
Illuminate\Database\QueryException with message 'SQLSTATE[22P02]: Invalid text
representation: 7 ERROR: invalid input syntax for uuid: "0" (SQL: select *
from "taxes" where "taxes"."id" in (0))'
While this exception is quite understandable, my question is how do I avoid this situation?
Note: The tax.id column is of postgres uuid type.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire