1
votes

I am new to laravel. I have created a notification in laravel 5.6, I typed php artisan notifications:table, which created a notifications table. I then created a notification file by typing php artisan make:notification NewMessage, this created my notification file "NewMessage.php" inside the Notifications folder. This notification works fine for me.

Now I created another notification file "NewData.php" inside the Notifications folder. But now I want to make a separate notification table for it and connect this table with the new file NewData.php, so that the data meant for this file gets saved in the new database table. Any help is appreciated.

This sounds like an X-Y Problem. Why do you want separate tables for separate notifications? You don't have a table for each user too, right?Loek
the same user id in my case has multiple types of notification. One for message, one for new data added for that user etc. That is why I am making separate tables.Shantanu
Normalization of databases concerning this suggests you put all data that are similar in one table. You can differ the kind of notification by a type field, no?Rafael
And even then, what does type matter? It's just the contents that are different. It's still a notification and should still be handled the same way as every other.Loek
Isn't the whole idea of notifications that you send them directly instead of gathering a lot of them and bulk-send them? Anyway, take a look at "Accessing the Notifications" chapter of these docs and it should be pretty clear how to use the type to filter your notifications. (probably something like $user->unreadNotifications->filter(function($e) { $e->type == 'registered'}))Loek