What kind of database are you using? You cant actually store arrays in mysql.
There are probably lots of ways to do this, but I think I would have a simple 'watched' table with 'user_id' and 'video_id' columns. Set up relationships on the table so that you can easily go between videos, users, and watched tables. When a user watches a video, a new row is added with their user_id and the watched video_id. To find the videos a certain user simply search by user name.
Insert array of in database
I have a table named videos->watched , i am trying to insert the auth user id as an array in this column.
the ides is simple the videos will be watched the controller will add to the array a new id, when the video gets updated the entire column gets dumped and it starts over.
Any ideas how i could insert the array? Sadly eloquent seems to think that $array is part of the query and I get an error.
Error: Call to a member function update() on integer
Array: [{"0":"","user":1}]
Code: $array = array(array_add([$watched],'user' ,Auth::user()->id)); DB::table('videos')->whereId($id)->increment('views')- >update(['watched' => $array]);
Please or to participate in this conversation.