Did you see my current problem?

|
natghi2010 2020-12-29 23:35:58
wanted to do a delete before the save but I have never seen save like this
segungreat 2020-12-30 00:06:58
natghi2010 2020-12-29 23:35:31

Am confused too, which version of laravel and is the working

natghi2010 2020-12-30 00:07:48
segungreat 2020-12-30 00:06:58
Am confused too, which version of laravel and is the working

if i use update, instead of save

natghi2010 2020-12-30 00:08:00
will it work?
nanribet 2020-12-30 00:50:00
Kibeish 2020-12-29 14:11:44
Hi someone assist below code snippet

Hi are u building a shopping cart

nazmulpcc 2020-12-30 00:55:28
natghi2010 2020-12-29 23:35:31

This will just create a new PlaningCalc instance/row
the “new PlaningCalc” section is redundant/not needed

natghi2010 2020-12-30 00:56:22
nazmulpcc 2020-12-30 00:55:28
This will just create a new PlaningCalc instance/row
the “new PlaningCalc” section is redundant/not needed

So how to convert to update?

nazmulpcc 2020-12-30 00:57:18
If you want to update a row/rows you can do so by using the update method
nazmulpcc 2020-12-30 00:58:59
PlanningCalc::find(10)->update([‘current_stock’ => 10])
nazmulpcc 2020-12-30 00:59:10
something like this
natghi2010 2020-12-30 01:12:07
nazmulpcc 2020-12-30 00:58:59
PlanningCalc::find(10)->update([‘current_stock’ => 10])

Oh I cant find the id

nazmulpcc 2020-12-30 01:14:06
It was just an example
nazmulpcc 2020-12-30 01:14:22
you need some kind of condition to limit the update
nazmulpcc 2020-12-30 01:14:47
surely you Don’t want to update all records of the table
Kibeish 2020-12-30 04:47:21
hypernxf 2020-12-29 16:42:22
The last time I saw such issue is when the Price include the currency. You might want to check if yours is just digits

Mine is just digits

Kibeish 2020-12-30 04:48:43
hypernxf 2020-12-29 16:43:26
usually if the string is just numbers, it doesn’t have to be cast to intval. so that means the data might contain something else PHP dont understand.

It is numbers

Kibeish 2020-12-30 04:50:23
djx10d 2020-12-29 17:04:54
But did you check it with var_dump or dd? It must have integer or float type, not string.

dd same problem

Kibeish 2020-12-30 04:53:59
nanribet 2020-12-30 00:50:00
Hi are u building a shopping cart

Yes!! A sample cart, already adding item in session so am trying to view added items in the session shopping cart then save in database. But some problems here and there

Kibeish 2020-12-30 04:55:47
2020-12-29 23:07:32
Not you bro..

Did you see my current problem?

Dkhicher 2020-12-30 04:58:00
Kibeish 2020-12-30 04:55:47
Did you see my current problem?

https://youtube.com/playlist?list=PLGsHwf2MeBOhLEzjinz4K6BaM-E9NIpsb it can help

Laravel Shopping Cart Tutorial Hindi – YouTubeYouTube
Kibeish 2020-12-30 05:01:25
I will definitely use this, and learn hindi while at it,
Kibeish 2020-12-30 05:02:08
Dkhicher 2020-12-30 04:58:00
https://youtube.com/playlist?list=PLGsHwf2MeBOhLEzjinz4K6BaM-E9NIpsb it can help

My problem is a an error in code just that everything is setup

Dkhicher 2020-12-30 05:07:42
Kibeish 2020-12-30 05:02:08
My problem is a an error in code just that everything is setup

Let me review your code. Do you have anydesk

Kibeish 2020-12-30 05:09:28
Kibeish 2020-12-29 15:30:32
You tell me sir. Am kind of worked up

@Dkhicher part with the problem

Kibeish 2020-12-30 05:10:12
Kibeish 2020-12-29 14:12:33
session to add

@Dkhicher the * part

Kibeish 2020-12-30 05:11:09
Where the code must do some multiplication, it says I have incorrectly formed numeric values
Dkhicher 2020-12-30 05:11:23
Kibeish 2020-12-30 05:10:12
@Dkhicher the * part

On your error screen you also can see line number where the error occurred

Kibeish 2020-12-30 05:12:06
Kibeish 2020-12-29 14:14:33
line of code $storedItem[‘price’] = $item->price * $storedItem[‘qty’];

Above line

Dkhicher 2020-12-30 05:17:08
Kibeish 2020-12-30 05:12:06
Above line

$storedItem[‘price’] = (int)$item->price * (int)$storedItem[‘qty’];

Dkhicher 2020-12-30 05:17:38
Try this one
Dkhicher 2020-12-30 05:18:06
Reason is you multiple string with number thats why you getting error
Dkhicher 2020-12-30 05:25:16
Or you can use intval method
Kibeish 2020-12-30 05:25:49
Dkhicher 2020-12-30 05:17:08
$storedItem[‘price’] = (int)$item->price * (int)$storedItem[‘qty’];

Let me try this

Dkhicher 2020-12-30 05:27:03
Kibeish 2020-12-30 05:25:49
Let me try this

Okay

Kibeish 2020-12-30 05:29:54
Dkhicher 2020-12-30 05:25:16
Or you can use intval method

If i were to use intval method kindly construct a sample code using my above code.

|