# Identifying users



When a user logs in to your Laravel application and an error or trace occurs, helpful information about the user is sent to Flare.

By default, the following attributes are sent:

- `id`
- `email`
- `name` (or `full_name`, `fullName`, `username`, in that order)

The defaults try a handful of common property names on the user object so most apps work out of the box. If your model uses different property names, see [Customising user data](#customising-user-data) below.

## Sending extra attributes

When you want to send additional attributes alongside the defaults, implement a `toFlare` method on your user model. The returned array is merged into the user attributes:

```php
class User extends Authenticatable
{
    public function toFlare(): array
    {
        return [
            'team_id' => $this->team_id,
            'plan' => $this->subscription?->plan_name,
        ];
    }
}
```

For most applications, this is all you need.

## Customising user data

When the defaults don't fit (different property names, computed fields, an entirely different user object), extend `LaravelUserAttributesProvider` and override the methods you need. The user is available as `$this->user` inside each method:

```php
namespace App\Flare;

use Spatie\LaravelFlare\AttributesProviders\LaravelUserAttributesProvider;

class CustomUserAttributesProvider extends LaravelUserAttributesProvider
{
    public function id(): string|int|null
    {
        return $this->user->uuid;
    }

    public function fullName(): ?string
    {
        return "{$this->user->first_name} {$this->user->last_name}";
    }

    public function email(): ?string
    {
        return $this->user->work_email;
    }

    public function attributes(): array
    {
        return [
            'team_id' => $this->user->team_id,
        ];
    }
}
```

Bind it in the container so the package picks up your subclass anywhere it constructs a user attributes provider:

```php
// AppServiceProvider::register()
$this->app->bind(
    \Spatie\LaravelFlare\AttributesProviders\LaravelUserAttributesProvider::class,
    \App\Flare\CustomUserAttributesProvider::class,
);
```

## Sending no user data

To send no user data at all, bind the `LaravelUserAttributesProvider` to the framework-agnostic `EmptyUserAttributesProvider` that ships with `flare-client-php`. It returns `null` (or an empty array) for every field:

```php
$this->app->bind(
    \Spatie\LaravelFlare\AttributesProviders\LaravelUserAttributesProvider::class,
    \Spatie\FlareClient\AttributesProviders\EmptyUserAttributesProvider::class,
);
```

For more on the underlying contract, see the [PHP attribute providers docs](/docs/php/general/attribute-providers).
