You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.1 KiB
49 lines
1.1 KiB
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Laravel\Sanctum\HasApiTokens;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
use App\Models\Validation\ValidationByNameInterface;
|
|
|
|
class User extends Authenticatable implements ValidationByNameInterface
|
|
{
|
|
use HasApiTokens, HasFactory, Notifiable;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'username',
|
|
'matrix_username',
|
|
'phone',
|
|
];
|
|
|
|
|
|
|
|
|
|
public static function isExistByName(string $name): bool
|
|
{
|
|
$count = User::where('matrix_username', $name)->count();
|
|
|
|
return $count != 0;
|
|
}
|
|
|
|
public static function isNameValid(string $name): bool
|
|
{
|
|
return $name != '';
|
|
}
|
|
|
|
public function userAddresses(): HasMany
|
|
{
|
|
return $this->hasMany(UserAddress::class);
|
|
}
|
|
}
|