Nov 12, 2016
0
Level 3
Upgrade notifications table
Hi, I already had an notification table and now want to upgrade to Laravel notifications.
So I created an migration like this:
Schema::table('notifications', function (Blueprint $table) {
$table->string('notifiable_type')->after('notification_type_id');
$table->unsignedInteger('notifiable_id')->after('notification_type_id');
$table->timestamp('read_at')->nullable()->after('data');
$table->index(['notifiable_id', 'notifiable_type']);
});
So now the tables look like: notifications: https://abload.de/img/bildschirmfoto2016-1131slm.png notification_types: https://abload.de/img/bildschirmfoto2016-11yksvl.png
Getting the following error:
FatalThrowableError in Grammar.php line 118:
Type error: Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, string given, called in /Applications/MAMP/htdocs/battlerap.club/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php on line 660
in Grammar.php line 118
at Grammar->parameterize('2016-11-12 13:51:01') in Grammar.php line 660
at Grammar->compileInsert(object(Builder), array('data' => array('notification_type_id' => '2', 'url' => 'http://localhost/battlerap.club/public/invite/479'), 'updated_at' => '2016-11-12 13:51:01', 'created_at' => '2016-11-12 13:51:01')) in Grammar.php line 678
at Grammar->compileInsertGetId(object(Builder), array('data' => array('notification_type_id' => '2', 'url' => 'http://localhost/battlerap.club/public/invite/479'), 'updated_at' => '2016-11-12 13:51:01', 'created_at' => '2016-11-12 13:51:01'), 'id') in Builder.php line 2148
at Builder->insertGetId(array('data' => array('notification_type_id' => '2', 'url' => 'http://localhost/battlerap.club/public/invite/479'), 'updated_at' => '2016-11-12 13:51:01', 'created_at' => '2016-11-12 13:51:01'), 'id')
at call_user_func_array(array(object(Builder), 'insertGetId'), array(array('data' => array('notification_type_id' => '2', 'url' => 'http://localhost/battlerap.club/public/invite/479'), 'updated_at' => '2016-11-12 13:51:01', 'created_at' => '2016-11-12 13:51:01'), 'id')) in Builder.php line 1451
at Builder->__call('insertGetId', array(array('data' => array('notification_type_id' => '2', 'url' => 'http://localhost/battlerap.club/public/invite/479'), 'updated_at' => '2016-11-12 13:51:01', 'created_at' => '2016-11-12 13:51:01'), 'id')) in Model.php line 1607
at Model->insertAndSetId(object(Builder), array('data' => array('notification_type_id' => '2', 'url' => 'http://localhost/battlerap.club/public/invite/479'), 'updated_at' => '2016-11-12 13:51:01', 'created_at' => '2016-11-12 13:51:01')) in Model.php line 1576
at Model->performInsert(object(Builder)) in Model.php line 1472
at Model->save(array('touch' => false)) in BelongsToMany.php line 772
at BelongsToMany->create(array('id' => 'cdcf6096-ea72-4882-9f89-452bd730b89e', 'type' => 'BattleRapClub\Notifications\InviteReceived', 'data' => array('notification_type_id' => '2', 'url' => 'http://localhost/battlerap.club/public/invite/479'), 'read_at' => null)) in DatabaseChannel.php line 20
at DatabaseChannel->send(object(User), object(InviteReceived)) in ChannelManager.php line 79
at ChannelManager->sendNow(object(Collection), object(InviteReceived)) in ChannelManager.php line 43
at ChannelManager->send(object(Collection), object(InviteReceived)) in RoutesNotifications.php line 18
at User->notify(object(InviteReceived)) in InviteController.php line 131
The other question is: Possible not just to modify the data-column in the "toArray()"-method in the notification class? Because I want to set the foreign key to the notification type and also set the url in a separate column. Any ideas here?
Thanks, Vincent
Please or to participate in this conversation.