71 lines
1.5 KiB
PHP
71 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
|
|
/**
|
|
* @property int $asset_id
|
|
*/
|
|
class User extends Authenticatable
|
|
{
|
|
/** @use HasFactory<\Database\Factories\UserFactory> */
|
|
use HasFactory, Notifiable;
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $fillable = [
|
|
'name',
|
|
'email',
|
|
'password',
|
|
'asset_id',
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be hidden for serialization.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'email_verified_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
];
|
|
}
|
|
|
|
public function asset(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Asset::class);
|
|
}
|
|
|
|
public function hasCompletedOnboarding(): bool
|
|
{
|
|
// Check if user has asset, purchases, and milestones
|
|
return $this->asset_id !== null
|
|
&& $this->hasPurchases()
|
|
&& $this->hasMilestones();
|
|
}
|
|
|
|
public function hasPurchases(): bool
|
|
{
|
|
return \App\Models\Transactions\Purchase::totalShares() > 0;
|
|
}
|
|
|
|
public function hasMilestones(): bool
|
|
{
|
|
return \App\Models\Milestone::count() > 0;
|
|
}
|
|
}
|