laravel-promocodes
laravel-promocodes copied to clipboard
Column not found: 1054 Unknown column 'user_id' in 'field list'
Hi,
if you customize users foreign key in the config, create method throws an exception user_id column can not be found.
something like this do the trick:
return $this->generate()->map(fn(string $code) => app(PromocodeContract::class)->create([
config('promocodes.models.users.foreign_id') => optional($this->user)->id,
'code' => $code,
'usages_left' => $this->unlimited ? -1 : $this->usagesLeft,
'bound_to_user' => $this->user || $this->boundToUser,
'multi_use' => $this->multiUse,
'details' => $this->details,
'expired_at' => $this->expiredAt,
]));
Have same problem