There are three tables, users, project_user, projects. In the pivot table, project_user, there are only 2 columns user_id and project_id as foreign keys associated with users and projects.
What I want to do is simply change all the project_id=1 to project_id=2 in the pivot table. Here is my code:
DB::table('project_user')->where('project_id',1)->update(['project_id'=>2]);
I want to know is there any better way to do that? Any demo code is appreciated.