Answer the question
In order to leave comments, you need to log in
How is the logic under the hood arranged when sending messages and confirmations?
For the test, I am making a website where it will be possible to transfer a thing, one person from the list selects an item, passes it to the second, the second must accept.
There is nothing complicated with filling tables in the database through php laravel, there are a lot of lessons, but what to do next? Make the subject have a user id? Type at confirmation by the second user update in the table it will be admissible the column belongs and there id to whom exactly?
And how to make the notification mechanism itself? How to understand the second user that he received a message?
Answer the question
In order to leave comments, you need to log in
items table, users table, user_items table
create table user_items (
user_id int,
item_id int,
ownership enum('changed','confirmed')
);
-- Let user 1 have item 100
insert into user_items values (1, 100, 'confirmed');
select * from user_items;
-- user 1 offer his item 100 to user 2
update user_items set user_id = 2, ownership = 'changed' where item_id = 100 and user_id = 1 and ownership = 'confirmed';
select * from user_items;
-- user 2 confirm ownership
update user_items set ownership = 'confirmed' where item_id = 100 and user_id = 2 and ownership = 'changed';
select * from user_items;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question