148 lines
3.5 KiB
PHP
148 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Traits\User\Attributes\UserAttributes;
|
|
use App\Models\Traits\User\Methods\UserMethods;
|
|
use App\Models\Traits\User\Relationships\UserRelationships;
|
|
use App\Models\Traits\User\Scopes\UserScope;
|
|
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\Support\Str;
|
|
use App\Notifications\Auth\ResetPassword;
|
|
use App\Notifications\Auth\VerifyEmail;
|
|
use App\Traits\HasKarmaPoint;
|
|
use Spatie\Permission\Traits\HasRoles;
|
|
|
|
|
|
class User extends Authenticatable implements MustVerifyEmail
|
|
{
|
|
use HasApiTokens, HasFactory, Notifiable, HasRoles, UserRelationships, UserMethods, UserAttributes, UserScope, HasKarmaPoint;
|
|
|
|
protected $appends = ['is_working', 'is_friends', 'hide_mobile', 'is_user_friends', 'is_blocked'];
|
|
|
|
/**
|
|
* The "booting" method of the model.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected static function boot()
|
|
{
|
|
parent::boot();
|
|
|
|
static::creating(function ($model) {
|
|
$model->uuid = (string) Str::uuid();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'email',
|
|
'email_hash',
|
|
'username',
|
|
'country_code',
|
|
'mobile',
|
|
'dharma_id',
|
|
'gender',
|
|
'birth_date',
|
|
'confirmation_code',
|
|
'avatar',
|
|
'verification_confirmed',
|
|
'status',
|
|
'is_profile_verified',
|
|
'parent_id',
|
|
'is_passive',
|
|
'relationship',
|
|
'about',
|
|
'school_name',
|
|
'password',
|
|
'mobile_privacy',
|
|
'email_privacy',
|
|
'avatar_privacy',
|
|
'birth_date_privacy',
|
|
'gender_privacy',
|
|
'dharma_privacy',
|
|
'profile_statistics',
|
|
'is_profile_completed',
|
|
'email_verified_at',
|
|
'mobile_verified_at',
|
|
'karma_dhan',
|
|
'last_login_at',
|
|
'last_login_ip',
|
|
'unread_message_count',
|
|
'unread_notification_count',
|
|
'app_version',
|
|
];
|
|
|
|
protected $guarded = [
|
|
'id',
|
|
];
|
|
/**
|
|
* The attributes that should be hidden for serialization.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be cast to native types.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $casts = [
|
|
'id' => 'integer',
|
|
'dharma_id' => 'integer',
|
|
'email_verified_at' => 'datetime',
|
|
'mobile_verified_at' => 'datetime',
|
|
'extra_attributes' => 'array',
|
|
'mobile' => 'string',
|
|
'timezone' => 'string',
|
|
'last_login_at' => 'datetime',
|
|
'last_login_ip' => 'string',
|
|
'profile_statistics' => 'json',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be mutated to dates.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $dates = [
|
|
'email_verified_at',
|
|
'mobile_verified_at',
|
|
'last_login_at',
|
|
];
|
|
|
|
/**
|
|
* Send the email verification notification.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function sendEmailVerificationNotification()
|
|
{
|
|
$this->notify(new VerifyEmail);
|
|
}
|
|
|
|
/**
|
|
* Send the password reset notification.
|
|
*
|
|
* @param string $token
|
|
* @return void
|
|
*/
|
|
public function sendPasswordResetNotification($token)
|
|
{
|
|
$this->notify(new ResetPassword($token));
|
|
}
|
|
}
|