mirror of
https://github.com/arthur-pbty/portfolio2023.git
synced 2026-06-16 15:57:04 +02:00
add profile picture
This commit is contained in:
+13
-1
@@ -1,6 +1,7 @@
|
||||
import { DateTime } from 'luxon'
|
||||
import Hash from '@ioc:Adonis/Core/Hash'
|
||||
import { column, beforeSave, BaseModel } from '@ioc:Adonis/Lucid/Orm'
|
||||
import { column, beforeSave, BaseModel, computed } from '@ioc:Adonis/Lucid/Orm'
|
||||
import { responsiveAttachment, ResponsiveAttachmentContract } from '@ioc:Adonis/Addons/ResponsiveAttachment'
|
||||
|
||||
export default class User extends BaseModel {
|
||||
@column({ isPrimary: true })
|
||||
@@ -24,6 +25,17 @@ export default class User extends BaseModel {
|
||||
@column.dateTime({ autoCreate: true, autoUpdate: true })
|
||||
public updatedAt: DateTime
|
||||
|
||||
@responsiveAttachment({ preComputeUrls: true })
|
||||
public avatar: ResponsiveAttachmentContract
|
||||
|
||||
@computed()
|
||||
public get avatarUrl() {
|
||||
if (this.avatar) {
|
||||
return '/uploads/'+this.avatar.breakpoints!.small.name
|
||||
}
|
||||
return 'https://source.boringavatars.com/beam/40/${this.email}?colors=001449,012677,005BC5,00B4FC,17F9FF'
|
||||
}
|
||||
|
||||
@beforeSave()
|
||||
public static async hashPassword (user: User) {
|
||||
if (user.$dirty.password) {
|
||||
|
||||
Reference in New Issue
Block a user