use BookStack\Activity\Models\Watch;
use BookStack\Api\ApiToken;
use BookStack\App\Model;
-use BookStack\App\Sluggable;
+use BookStack\App\SluggableInterface;
use BookStack\Entities\Tools\SlugGenerator;
use BookStack\Translation\LocaleDefinition;
use BookStack\Translation\LocaleManager;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
+use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Collection;
* @property string $system_name
* @property Collection $roles
* @property Collection $mfaValues
+ * @property ?Image $avatar
*/
-class User extends Model implements AuthenticatableContract, CanResetPasswordContract, Loggable, Sluggable
+class User extends Model implements AuthenticatableContract, CanResetPasswordContract, Loggable, SluggableInterface
{
use HasFactory;
use Authenticatable;
/**
* The attributes that are mass assignable.
*
- * @var array
+ * @var list<string>
*/
protected $fillable = ['name', 'email'];
/**
* The attributes excluded from the model's JSON form.
*
- * @var array
+ * @var list<string>
*/
protected $hidden = [
'password', 'remember_token', 'system_name', 'email_confirmed', 'external_auth_id', 'email',
/**
* The roles that belong to the user.
*
- * @return BelongsToMany
+ * @return BelongsToMany<Role, $this>
*/
- public function roles()
+ public function roles(): BelongsToMany
{
- if ($this->id === 0) {
- return;
- }
-
return $this->belongsToMany(Role::class);
}
*/
public function refreshSlug(): string
{
- $this->slug = app()->make(SlugGenerator::class)->generate($this);
+ $this->slug = app()->make(SlugGenerator::class)->generate($this, $this->name);
return $this->slug;
}