Skip to content

Manual Generation #5

Closed
Closed

Description

@mohamedzumry

Hi,

First of all thank you for your great package. I have 1 doubt, how can I stop auto generation during creation, because I want to generate later

Let us say I am creating a Voucher, when creating I don't want a voucher_no, its null. Later when the user confirms the voucher creation teh voucher status becomes conformed while the voucher_no is also created at that time.

Thank you.

Activity

  1. EG-Mohamed commented on Jun 12, 2026

    @EG-Mohamed
    Owner

    Hi, thanks for the kind words!

    You can defer generation with the current version — just create the voucher quietly so auto-generation doesn't fire, then generate on confirm:

    // On create — voucher_no stays null
    $voucher = new Voucher($data);
    $voucher->saveQuietly();
    
    // On confirm
    $voucher->voucher_no = $voucher->generateReference();
    $voucher->save();

    Just make the column nullable: $table->string('voucher_no')->nullable()->unique()->index();

    This is a bit of an edge case, so I don't think it needs a dedicated feature in the package — saveQuietly() covers it well. Only thing to keep in mind is that it skips other model events on that insert too.

    Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions