HI i am searching for relevant solution from 2 days, i did not get any and i am writing here finally. I have 2 database tables with the columns table :1 "item, stock, used, created_at and updated_at" table:2 "item, brand, price, quantity, updated_at, created_at".
In second table whenever we are inserting a record it should add to another row. But in first table if the record is already exist then it should update the stock, otherwise it should add one more new row. can anyone help me with that.
I tried your code but i am getting this error now
"QueryException in Connection.php line 761:
SQLSTATE[HY000]: General error: 1364 Field 'item' doesn't have a default value (SQL: insert into stationary (available, updated_at, created_at) values (12345, 2016-09-30 12:16:52, 2016-09-30 12:16:52))"
Here is my controller code
I changed the code now i am getting this error
"QueryException in Connection.php line 761: SQLSTATE[HY000]: General error: 1364 Field 'item' doesn't have a default value (SQL: insert into stationary (available, updated_at, created_at) values (12345, 2016-09-30 12:16:52, 2016-09-30 12:16:52))"
Now one more issue. If both the available and item matches only it is updating. but i want it to be like " if item matches then it should update the count" instead it is adding one more row.
@tomi you suggested to give count++ in my thing i have to give available ++. when i give available++ it is incrementing the value but i need it to be add the present entered value to previous value. can you help me in that?