Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/crud forms #51

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Feat/crud forms #51

wants to merge 5 commits into from

Conversation

Skiperpol
Copy link
Member

No description provided.

@Skiperpol
Copy link
Member Author

    if (form.name && form.id) {
      form.slug = slugify(`${form.name}${form.id}`, {
        lower: true,
        strict: true,
      }) as string;
    }

Takie tworzenie sluga napisałem za pomocą biblioteki. Nie jestem pewny czy powinna obejmować takie dane w sobie

@Skiperpol
Copy link
Member Author

import { BaseSchema } from '@adonisjs/lucid/schema'

export default class AddSlugToForms extends BaseSchema {
  protected tableName = 'forms';

  async up() {
    this.schema.alterTable(this.tableName, (table) => {
      table.string('slug').notNullable().unique().after('name');
    });
  }

  async down() {
    this.schema.alterTable(this.tableName, (table) => {
      table.dropColumn('slug');
    });
  }
}

Dodatkowo dodanie sluga do formsów zrobiłem jako oddzielną migrację, a nie w głównej migracji. Wydaje mi się że jest to prawidłowe w Adonis, ale nie jestem pewny.

@dawidlinek
Copy link
Member

@Skiperpol bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat/endpoint formularza feat/crud formsów
2 participants