init
This commit is contained in:
16
app/models/user.js
Normal file
16
app/models/user.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { UserSchema } from '#database/schema';
|
||||
import hash from '@adonisjs/core/services/hash';
|
||||
import { compose } from '@adonisjs/core/helpers';
|
||||
import { withAuthFinder } from '@adonisjs/auth/mixins/lucid';
|
||||
import { DbAccessTokensProvider } from '@adonisjs/auth/access_tokens';
|
||||
export default class User extends compose(UserSchema, withAuthFinder(hash)) {
|
||||
static accessTokens = DbAccessTokensProvider.forModel(User);
|
||||
get initials() {
|
||||
const [first, last] = this.fullName ? this.fullName.split(' ') : this.email.split('@');
|
||||
if (first && last) {
|
||||
return `${first.charAt(0)}${last.charAt(0)}`.toUpperCase();
|
||||
}
|
||||
return `${first.slice(0, 2)}`.toUpperCase();
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=user.js.map
|
||||
Reference in New Issue
Block a user