clearly you have modified the notifications table
Jul 13, 2024
13
Level 8
Why in Notificationtable inserted row has strange id ?
In laravel 11 / livewire 3 app I send email using parameter in via method :
class NewStaffUserCreatedNotification extends Notification
{
use Queueable;
protected User $staffUser;
protected bool $isActive;
protected string $generatedPassword;
public function __construct(User $staffUser, bool $isActive = false, string $generatedPassword = '')
{
$this->staffUser = $staffUser;
$this->isActive = $isActive;
$this->generatedPassword = $generatedPassword;
}
public function via(object $notifiable): array
{
return ['database'];
}
...
I got strange error :
[2024-07-12 10:56:21] local.INFO: SQLSTATE[01000]: Warning: 1265 Data truncated for column 'id' at row 1 (Connection: mysql, SQL: insert into `notifications` (`id`, `type`, `data`, `read_at`, `notifiable_id`, `notifiable_type`, `updated_at`, `created_at`) values (2fad7130-e97c-46d6-9791-cdff36ff548d, App\Notifications\NewStaffUserCreatedNotification, {"data":{"staffUser":{"name":"Laura Atkins","email":"[email protected]","slug":"laura-atkins","notes":"<p>f<\/p>","status":"N","membership_mark":"M","phone":"+1 (663) 838-9799","website":"https:\/\/www.rapesy.mobi","activated_at":null,"avatar":"public\/avatars\/avatar-50\/6wxK2Q4gL6OrsE9m8LIXepgCiVWbPBhNyXBHwhIO.jpg","id":50}}}, ?, 50, App\Models\User, 2024-07-12 10:56:21, 2024-07-12 10:56:21))
Value "2fad7130-e97c-46d6-9791-cdff36ff548d" really seems invalid for field defined :
CREATE TABLE `notifications` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
It seems I did not modify notifications anyway.
This notification is called from listener:
public function handle(NewStaffUserCreatedEvent $event): void
{
// I check that vaiid parameters are passed
\Log::info(varDump($event, ' -1 NewStaffUserCreatedListener $event::'));
$event->staffUser->notify(new NewStaffUserCreatedNotification(staffUser: $event->staffUser, isActive: $event->isActive,
generatedPassword: $event->generatedPassword));
Any ideas why I got such error ? What have I to check ?
Level 122
@mstdmstd there is an artisan command to install the table, but you should drop the table first, and delete your current migration file
https://laravel.com/docs/11.x/notifications#database-prerequisites
1 like
Please or to participate in this conversation.