Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

How I can generate the unique transaction ID in laravel 8

class Transaction extends Model {
 ...
 public static function boot()
 {
        parent::boot();
        self::created(function ($model) { 
            $model->transaction_id = 'NMB-BOO-' . str_pad($model->id, 7, "0", STR_PAD_LEFT);
            $model->save();
        });
 }
}
 
PREVIOUS NEXT
Tagged: #How #I #generate #unique #transaction #ID #laravel
ADD COMMENT
Topic
Name
8+5 =