Pular para o conteúdo
← Voltar para projetos

Laravel User

Base authenticatable User model, migration, factory and observer shared by the jeffersongoncalves Laravel starter kits.

Laravel User

#Laravel User

Base authenticatable User model, migration, factory and observer shared by the jeffersongoncalves Laravel starter kits.

Your app keeps its own App\Models\User and simply extends the package model, so columns, casts, factory and observer live in one place and every kit gets fixes through composer update.

#Installation

composer require jeffersongoncalves/laravel-user

Publish and run the migration (skip it if your app already has a users table with the same columns):

php artisan vendor:publish --tag="laravel-user-migrations"
php artisan migrate

#Usage

namespace App\Models;

use JeffersonGoncalves\User\Models\User as BaseUser;

class User extends BaseUser
{
    // add traits, relations or overrides here
}

config/auth.php keeps pointing the users provider to App\Models\User.

What the base model gives you:

Feature Details
Columns status, name, email, email_verified_at, password, remember_token, avatar_url, custom_fields, locale, theme_color
Casts password hashed, status boolean, custom_fields array, email_verified_at datetime
Contracts Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail, Notifiable
Factory User::factory() with unverified() and inactive() states. It creates the model set in auth.providers.users.model, so App\Models\User::factory() works without a factory in your app
Observer Clears the users_count cache key on create/delete (inherited by subclasses)

#Testing

composer test

#Changelog

Please see CHANGELOG for more information on what has changed recently.

#Credits

#License

The MIT License (MIT). Please see License File for more information.

Nova versão disponível.