mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-10 07:25:35 +00:00
feat: add basic admin dashboard
This commit is contained in:
@@ -7,21 +7,19 @@ import { DateTime } from 'luxon';
|
||||
|
||||
export default class AppBaseModel extends BaseModel {
|
||||
static namingStrategy = new CamelCaseNamingStrategy();
|
||||
static selfAssignPrimaryKey = true;
|
||||
serializeExtras = true;
|
||||
|
||||
@column({ isPrimary: true })
|
||||
declare id: number;
|
||||
|
||||
@column.dateTime({
|
||||
autoCreate: true,
|
||||
serializeAs: 'created_at',
|
||||
})
|
||||
declare created_at: DateTime;
|
||||
declare createdAt: DateTime;
|
||||
|
||||
@column.dateTime({
|
||||
autoCreate: true,
|
||||
autoUpdate: true,
|
||||
serializeAs: 'updated_at',
|
||||
})
|
||||
declare updated_at: DateTime;
|
||||
declare updatedAt: DateTime;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export default class Collection extends AppBaseModel {
|
||||
@column()
|
||||
declare authorId: number;
|
||||
|
||||
@belongsTo(() => User, { foreignKey: 'authorId' })
|
||||
@belongsTo(() => User, { foreignKey: 'author_id' })
|
||||
declare author: BelongsTo<typeof User>;
|
||||
|
||||
@hasMany(() => Link)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import Collection from '#models/collection';
|
||||
import Link from '#models/link';
|
||||
import type { GoogleToken } from '@adonisjs/ally/types';
|
||||
import { column, computed, manyToMany } from '@adonisjs/lucid/orm';
|
||||
import type { ManyToMany } from '@adonisjs/lucid/types/relations';
|
||||
import { column, computed, hasMany } from '@adonisjs/lucid/orm';
|
||||
import type { HasMany } from '@adonisjs/lucid/types/relations';
|
||||
import AppBaseModel from './app_base_model.js';
|
||||
|
||||
export default class User extends AppBaseModel {
|
||||
@@ -30,15 +30,15 @@ export default class User extends AppBaseModel {
|
||||
@column({ serializeAs: null })
|
||||
declare providerType: 'google';
|
||||
|
||||
@manyToMany(() => Collection, {
|
||||
relatedKey: 'authorId',
|
||||
@hasMany(() => Collection, {
|
||||
foreignKey: 'authorId',
|
||||
})
|
||||
declare collections: ManyToMany<typeof Collection>;
|
||||
declare collections: HasMany<typeof Collection>;
|
||||
|
||||
@manyToMany(() => Link, {
|
||||
relatedKey: 'authorId',
|
||||
@hasMany(() => Link, {
|
||||
foreignKey: 'authorId',
|
||||
})
|
||||
declare links: ManyToMany<typeof Link>;
|
||||
declare links: HasMany<typeof Link>;
|
||||
|
||||
@computed()
|
||||
get fullname() {
|
||||
|
||||
Reference in New Issue
Block a user