mercredi 4 novembre 2015

Is it a good practice to extend Laravel models more than one layer?

I'm reworking a project on Laravel 5.1

What I realize is that the old classes have become much complicated and do not really follow the 'single responsibility' principle anymore.

So I'm planning to do such:

<?php

class User extends Model
{

}

class SocialUser extends User
{

}

So I have a few questions,

  1. Is it possible to achieve that?
  2. If yes, then does the SocialUser class link back to the same database table which is Users and would it conflict with the User model itself?
  3. Is this all a good design practice at the first place? Or I better make use of traits?

Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire