launcher-host / mercurius

Real-time Messenger for Laravel
http://mercurius.launcher.host/
MIT License
326 stars 51 forks source link

Feature: Extend Users Model #29

Closed akazorg closed 5 years ago

akazorg commented 5 years ago

We need to be able to extend Users Model. e.g. dealing with User first_name and last_name see issue #28.

idea

I'm not sure what is the best approach on this, please send your feedback.

mikemand commented 5 years ago

I would suggest an interface that requires the developer to implement a specific method (or methods, if you need more) for you to get the user's name.

I don't think it would be possible to create a command or something to automatically apply this, so you'd have to have documentation. For example, in https://github.com/launcher-host/mercurius/blob/master/docs/customization.md add a section:

Custom User Model

1. Change the config file to point to your User model.
    'models' => [
        'user'          => App\Models\User::class,
        ...
    ],
2. Implement the interface(s)
class User extends Model implements MercuriusUser
3. Implement the function(s) from the interface(s).
akazorg commented 5 years ago

@mikemand great idea for the interface!

I can automate the customization for the User model, since is already defined in the config, we just need to open this file and change it.

I'll create a branch for this and send some news soon. Thanks for the feedback!

akazorg commented 5 years ago

Closing with PR #31. Currently, we can define a different User model and apply custom fields. The User's name support multiple fields, e.g. first_name and last_name.

In the future we might use the User Interface, but for now the system is quite extendable.