What does the error say?

|
Denno_IT 2022-08-26 20:41:53
Arbaaz Nakhwa 2022-08-26 20:40:44
foreach($data as $row) { $output .= ‘ <tr> <td>’.$row->CustomerName.'</td> <td>’.$row->Address.'</td> <td>’.$row->City.'</td> <td>’.$row->PostalCode.'</td> <td>’.$row->Country.'</td> </tr>

the same way we use in the blade?

Arbaaz Nakhwa 2022-08-26 20:42:38
Denno_IT 2022-08-26 20:41:53
the same way we use in the blade?

Yes

Denno_IT 2022-08-26 21:09:37
Arbaaz Nakhwa 2022-08-26 20:42:38
Yes

still error

Denno_IT 2022-08-26 21:09:47
foreach($product_id as $key=> $request->product_id){
$order_details = new Order_Detail;
$order_details->order_id =$order_id;
$order_details->product_id =$request->product_id[$product_id];
$order_details->unitprice =$request->unitprice[$product_id];
$order_details->quantity =$request->quantity[$product_id];
$order_details->discount =$request->discount[$product_id];
$order_details->amount =$request->amount[$product_id];
$order_details->save();

}

Denno_IT 2022-08-26 21:09:58
i still got an error
Denno_IT 2022-08-26 21:10:23
i need to return product_id from the products table with increments
Oshincyber 2022-08-26 21:10:25
Oshincyber 2022-08-26 16:06:37
Okay will see to this first

laravel_discuss-135528.jpg
I still get this error all the time

Arbaaz Nakhwa 2022-08-26 21:11:11
Don’t add then it will auto increment
DesolatorMagno 2022-08-26 21:17:48
Denno_IT 2022-08-26 21:09:47
foreach($product_id as $key=> $request->product_id){
$order_details = new Order_Detail;
$order_details->order_id =$order_id;
$order_details->product_id =$request->product_id[$product_id];
$order_details->unitprice =$request->unitprice[$product_id];
$order_details->quantity =$request->quantity[$product_id];
$order_details->discount =$request->discount[$product_id];
$order_details->amount =$request->amount[$product_id];
$order_details->save();

}

That for each don’t make sense.

Oshincyber 2022-08-26 21:23:44
Oshincyber 2022-08-26 21:10:25
I still get this error all the time

Anyone please

Denno_IT 2022-08-26 21:25:53
Arbaaz Nakhwa 2022-08-26 21:11:11
Don’t add then it will auto increment

can you help me on how it should be

Denno_IT 2022-08-26 21:26:24
for($product_id = 0; $product_id<count($request->product_id); $product_id++)
Denno_IT 2022-08-26 21:26:40
Denno_IT 2022-08-26 21:26:24
for($product_id = 0; $product_id<count($request->product_id); $product_id++)

this are the values i want to pass in the loop

Denno_IT 2022-08-26 21:26:51
product_id from the products table
Mav123456 2022-08-26 21:26:52
Denno_IT 2022-08-26 20:15:35

why don’t u use for each?

Denno_IT 2022-08-26 21:27:03
Mav123456 2022-08-26 21:26:52
why don’t u use for each?

it is saying error

Mav123456 2022-08-26 21:27:18
but u aren’t using foreach here
Denno_IT 2022-08-26 21:28:13
Mav123456 2022-08-26 21:27:18
but u aren’t using foreach here

i dont know how i can change to using foreach

Denno_IT 2022-08-26 21:29:06
foreach($product_id as $request->product_id){
$order_details = new Order_Detail;
$order_details->order_id =$order_id;
$order_details->product_id =$request->product_id[$product_id];
$order_details->unitprice =$request->unitprice[$product_id];
$order_details->quantity =$request->quantity[$product_id];
$order_details->discount =$request->discount[$product_id];
$order_details->amount =$request->amount[$product_id];
$order_details->save();

endforeach
}

Denno_IT 2022-08-26 21:29:16
Denno_IT 2022-08-26 21:29:06
foreach($product_id as $request->product_id){
$order_details = new Order_Detail;
$order_details->order_id =$order_id;
$order_details->product_id =$request->product_id[$product_id];
$order_details->unitprice =$request->unitprice[$product_id];
$order_details->quantity =$request->quantity[$product_id];
$order_details->discount =$request->discount[$product_id];
$order_details->amount =$request->amount[$product_id];
$order_details->save();

endforeach
}

if i use this way still an error

Mav123456 2022-08-26 21:29:16
Denno_IT 2022-08-26 21:26:24
for($product_id = 0; $product_id<count($request->product_id); $product_id++)

are u returning multiple requests here ?

Mav123456 2022-08-26 21:29:28
Denno_IT 2022-08-26 21:29:16
if i use this way still an error

what does the error say ?

Denno_IT 2022-08-26 21:29:50
but i need it to be compacted with the product_id while incrementing
Denno_IT 2022-08-26 21:30:17
Mav123456 2022-08-26 21:29:28
what does the error say ?

laravel_discuss-135545.jpg

Mav123456 2022-08-26 21:31:24
first try this
dd($request);
Mav123456 2022-08-26 21:31:35
and see the results
Mav123456 2022-08-26 21:32:11
notice if the data you want is returned with the result or not
Denno_IT 2022-08-26 21:33:08
Mav123456 2022-08-26 21:31:24
first try this
dd($request);

inside the loop?

Mav123456 2022-08-26 21:34:21
Denno_IT 2022-08-26 21:33:08
inside the loop?

no need.
this is only to test if you have the correct data.

comment everything inside the function (you will uncomment it later) and just put

dd($request);

Mav123456 2022-08-26 21:38:39
and from this answer you can figure out how to get your data
Oshincyber 2022-08-26 21:45:22
Oshincyber 2022-08-26 21:10:25
I still get this error all the time

Please anyone

Ismart_akash 2022-08-26 21:46:48
webkuteer 2022-08-26 15:11:37
So complete code rewrite karna padega

Hmm

Denno_IT 2022-08-26 21:49:56
Mav123456 2022-08-26 21:34:21
no need.
this is only to test if you have the correct data.

comment everything inside the function (you will uncomment it later) and just put

dd($request);

it does not return

odoolens 2022-08-26 22:12:53
Vedant Brahmbhatt 2022-08-26 12:25:13
but how to implement in all controller ??
i have number of controller so i want to develop one route or controller in my whole project

Define a Route Group Controller

Oshincyber 2022-08-26 22:14:35
Oshincyber 2022-08-26 21:45:22
Please anyone

So no one

|