Skip to main content

Overview

The User model extends Laravel’s Authenticatable class and serves as the primary authentication model for the Dashboard Laravel application. It includes support for user factories and notifications out of the box.
This model uses Laravel 11’s standard authentication implementation with the HasFactory and Notifiable traits.

Model Details

Namespace

App\Models\User

Extends

Illuminate\Foundation\Auth\User as Authenticatable

Traits

  • HasFactory - Enables model factory support for testing and seeding
  • Notifiable - Enables notification sending capabilities

Fillable Attributes

The following attributes are mass assignable:
name
string
required
The user’s full name
email
string
required
The user’s email address (used for authentication)
password
string
required
The user’s hashed password

Hidden Attributes

The following attributes are hidden from JSON serialization for security:
password
string
Hidden from array/JSON serialization
remember_token
string
Hidden from array/JSON serialization

Attribute Casting

The model automatically casts the following attributes:
email_verified_at
datetime
Cast to Carbon datetime instance for email verification timestamp
password
hashed
Automatically hashed when set, ensuring secure password storage

Database Configuration

Table Name

'users' // Default Laravel users table

Timestamps

true // Uses created_at and updated_at timestamps

Full Model Code

Usage Examples

Creating a New User

use App\Models\User;

$user = User::create([
    'name' => 'John Doe',
    'email' => '[email protected]',
    'password' => 'secret123', // Automatically hashed
]);

Authenticating a User

use Illuminate\Support\Facades\Auth;

if (Auth::attempt(['email' => $email, 'password' => $password])) {
    // Authentication successful
    $user = Auth::user();
}

Sending Notifications

use App\Notifications\WelcomeNotification;

$user->notify(new WelcomeNotification());

Build docs developers (and LLMs) love