*/ use HasFactory; use HasProfilePhoto; use Notifiable; use TwoFactorAuthenticatable; use HasRoles; protected $fillable = [ 'name', 'email', 'telefono', 'direccion', 'plantel', 'password', 'code', 'status', 'unsubscribe_token' ]; protected $hidden = [ 'password', 'remember_token', 'two_factor_recovery_codes', 'two_factor_secret', 'status', ]; protected $appends = [ 'profile_photo_url', ]; protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; } // public function note() : HasOne // { // //esta funcion es para retornar la relacion de un usario que contenga notas // return $this->hasOne(Note::class); // } public function notes() : HasMany { return $this->hasMany(Note::class); } public function codes() : HasMany { return $this->hasMany(Code::class); } public function pagos() : HasMany { return $this->hasMany(Pago::class); } public function plantelUsuarios() : BelongsToMany { return $this->belongsToMany(Plantel::class)->withPivot('plantel_id'); } public function existe($request = null) { if (!$request) { return false; } return $this->plantelUsuarios() ->wherePivot('plantel_id', $request) ->exists(); } public function prospectos() : BelongsToMany { return $this->belongsToMany(Prospecto::class); } protected static function booted() { static::creating(function ($user) { $user->unsubscribe_token ??= \Illuminate\Support\Str::uuid(); }); } }