0

I have a project in Laravel 5.5 and I am using Laravel notification.

I want to send a notification to users when a product is added but when I use the notification, it gives me a mass assignment exception error id.

I think I don't have an error on the User model because my user model worked correctly before using the notification, and I don't find any model for notification until I add fillable id.

What is the solution for this problem?

these are the errors:

matiaslauriti
  • 7,065
  • 4
  • 31
  • 43
Akhlaqi
  • 1
  • 2
  • 2
    you have mass assignment error when a product is added, so check product model for $guarded and $fillable – Anurat Chapanond Mar 15 '21 at 06:00
  • you should provide more details and code snippets for others to understand better. see this answer for mass assignment error: https://stackoverflow.com/a/26724253/8607640 – Farhan Ibn Wahid Mar 15 '21 at 06:45
  • @AnuratChapanond FIrst Thanks for your response but why should I check the product model? I did not use any of the products field in the notifications – Akhlaqi Mar 15 '21 at 09:29
  • like @Psycho said, it's the best I can imply from your short description of your problem. – Anurat Chapanond Mar 15 '21 at 09:31
  • are you doing any manipulation to the product or user model object inside your notification class? – MAY Mar 15 '21 at 10:57
  • @MAY yes I change my user model but it desnt have any error in crud operation before using laravel notification – Akhlaqi Mar 15 '21 at 11:11
  • Can you please provide a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example)? Thanks – MAY Mar 15 '21 at 11:15
  • @MAY please see the error images – Akhlaqi Mar 15 '21 at 15:21
  • Sorry, but these errors don't explain much, please show code for your user model and notification class from where this error is originating. that would help, thanks – MAY Mar 15 '21 at 17:18
  • @MAY thanks dear I solved it – Akhlaqi Mar 16 '21 at 09:31
  • @Akhlaqi can you please share the solution, it might help someone else facing the same issue. Thanks – MAY Mar 16 '21 at 15:32
  • @MAY because i have another notifications function in my user model for relationship and I think laravel also use notifications function, I rename my notification function and it solved – Akhlaqi Mar 24 '21 at 10:41

0 Answers0