zabarah
2 months ago
424
4
Laravel

Switching 2 values in Database same column.

Posted 2 months ago by zabarah

Hey All,

I am trying to setup a dropdown where a user can select a preferred page in his account.

My database has a user table and pages table with relation to the user table.

In the pages table I have a primary column with 0 or 1 - 1 being the primary.

How can I make it so when a user chooses a new page it switches the primary column for that new page to be 1 and changing the old page to 0.

Note: only 1 page connected to the can have 1 in the primary column.

Please sign in or create an account to participate in this conversation.