We want to change the model so that it looks like this:
Notice that we use the modified Firebird\Eloquent\Model
model from the sim1984/laravel-firebird
package as the basis. It allows us to use the sequence specified in the $sequence
attribute to generate values for the primary key ID.
Now, a model for the invoice header:
You’ll observe some additional functions in this model. The function returns the customer that relates to the invoice header via the CUSTOMER_ID
field. The belongsTo
method is used for establishing this relation. The name of the model class and the name of the relation field are passed to this method.
You can find more details about specifying relations between entities in the .
The pay
function performs payment of an invoice by calling the stored procedure SP_PAY_FOR_INVOICE
, passing the identifier of the invoice header. The value of any field (model attribute) can be obtained from the attribute attribute
. The method calls the stored procedure.