Snippets

The ASCI Extend Model in Existing Class

You are viewing an old version of this snippet. View the current version.
Revised by Austin 09b7b88

I'm going to use PaymentTransaction as the example as I work through the conversion. This way I can note tips and tricks to save some future headache.

  1. Change class PaymentTransaction to class PaymentTransaction extends Model
  2. Remove any private class variables associated with db columns (e.g. $created).
  3. For PaymentTransaction many of the class variables were named with underscores in the way they are in the databases.
    • If this is not the case, the getters and setters need to be updated to reference the appropirate column variables. (e.g. $this->poNumber would need to become $this->po_number when the db column is named po_number.
      • My suggestion would be to keep all of the getters and setters, at least at this point. This will maintain compatability with existing code. I also personally like the getters and setters.
    • The next thing I did was run the tests. This caught variables in the FactoryMuffin object that were mis-named. (e.g. PaymentTransaction factory used invoiceId and needed to be changed to invoice_id. This is more than just in the FactoryMuffin definition, because there was some custom construction of these factories in various test suites.) 4.
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.