0

This is not a question but a way i applied to solve the array to string conversion error while saving. Laravel 5.7

When you have a datatype of 'text' in your database schema and you wish to save array values into it. Then you need to add the following to the model

protected $casts = [
    'tribes' => 'array'
];

then you can continue saving and it wont give any problem.

Sterlingking
  • 190
  • 1
  • 6
  • Note: the tribes from above is the field whose datatype is text and would be accepting array values – Sterlingking Nov 05 '18 at 10:58
  • 5
    It's great you want to share your knowledge and solutions! [You can answer your own questions on StackOverflow](https://stackoverflow.com/help/self-answer) but I requires you to ask a properly formed question first, and then answering it as if it would be answering someone else. Just edit your question and add an answer to your own question and you'll be fine. – Johan Nov 05 '18 at 10:59

0 Answers0