In the Transaction model class use the event created to get de ID and concatenate to transaction_id :
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();
});
}
}
* Be the first to Make Comment