<?php

namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Database\Factories\UserFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;


use Spatie\Onboard\Concerns\GetsOnboarded;
use Spatie\Onboard\Concerns\Onboardable;
use Spatie\Permission\Traits\HasRoles;

#[Fillable(['name', 'email', 'password', 'profile_picture', 'google2fa_secret', 'google2fa_enabled', 'is_super_admin', 'business_id'])]
#[Hidden(['password', 'remember_token'])]
class User extends Authenticatable implements Onboardable
{
    /** @use HasFactory<UserFactory> */
    use HasFactory, Notifiable, GetsOnboarded, HasRoles;

    /**
     * Get the attributes that should be cast.
     *
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'email_verified_at' => 'datetime',
            'password' => 'hashed',
            'google2fa_enabled' => 'boolean',
        ];
    }

    /**
     * Check if the user's profile is complete.
     */
    public function isComplete(): bool
    {
        return filled($this->name)
            && filled($this->email);
    }

    public function business()
    {
      return $this->belongsTo(Business::class);
    }
}
