<?php

namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use App\Facades\File\FileFacade;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasFactory, Notifiable, HasRoles;

    protected $guarded = [];

    protected $hidden = ['password', 'pivot'];
    public string $guard_name = 'web';

    public function storeFile($file, $name)
    {
        if ($this->avatar) {
            FileFacade::delete($this->avatar, true);
        }

        return FileFacade::save($file, 'users/avatars/' . $name);
    }
}
