Skip to content

Commit

Permalink
Added rank in press articles
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkBrines committed Mar 30, 2024
1 parent 88bed44 commit a642352
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Controllers/Http/PressController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PressArticle from "App/Models/PressArticle"

export default class PressController {
public async index({ view }: HttpContextContract) {
const pressArticles = await PressArticle.query().exec()
const pressArticles = await PressArticle.query().orderBy("rank", "desc").exec()

return view.render('press/index', {
pressArticles: pressArticles
Expand Down
3 changes: 3 additions & 0 deletions app/Models/PressArticle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export default class PressArticle extends BaseModel {
@column({ isPrimary: true })
public id: number

@column()
public rank: number

@column()
public title: string

Expand Down
15 changes: 15 additions & 0 deletions database/migrations/1711809658053_add_rank_to_press_articles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import BaseSchema from '@ioc:Adonis/Lucid/Schema'

export default class extends BaseSchema {
protected tableName = 'press_articles'

public async up() {
this.schema.alterTable(this.tableName, (table) => {
table.integer('rank')
})
}

public async down() {
this.schema.dropTable(this.tableName)
}
}

0 comments on commit a642352

Please sign in to comment.