Search
 
SCRIPT & CODE EXAMPLE
 

PHP

oder system make in laravel

public function store(Request $request)
{
    $order = Order::create([
        'user_id' => $request->input('user_id'),
        'total' => 0,
    ]);
    $total = 0;
    $size = count(collect($request)->get('quantity'));
    for ($i = 0; $i < $size; $i++) {
        $orderitem = Orderitem::create([
            'order_id' => $order->id,
            'product_id' => $request->get('product_id')[$i],
            $quantity = $request->get('quantity')[$i],
            'quantity' => $quantity,
            $price = Product::find($request->get('product_id')[$i])->price,
            'price' => $price,
            'total' => $quantity * $price,
        ]);
        $total += $orderitem['quantity']*$orderitem['price'];
    }
    $order['total'] = $total;
    $order->save()

    return redirect()->route('orders.index');
}
Comment

PREVIOUS NEXT
Code Example
Php :: Call to a member function move() on null 
Php :: php iterate through objects 
Php :: cake php 2.x group 
Php :: Parse error: syntax error, unexpected token "implements" in C:xampphtdocsmastervendoryiisoftyii2aseObject.php on line 78 
Php :: dequeue recaptcha wordpress 
Php :: laravel mix build as umd 
Php :: how to rrestart brew php 
Php :: laravel get user aget from request 
Php :: PHP: how to "clone from" another object of same class 
Php :: Dropzone Attachment Required is not working 
Php :: wordpress deny user to access wp-admin programmatically 
Php :: how to call a function in model from a controller 
Php :: add image thumb on checkout woo 
Php :: php ajax registration form validation 
Php :: modifier un formulaire php 
Php :: auto check a category when creating new post 
Php :: Display HTML text from a variable in laravel 
Php :: correction of controller 
Php :: run php after product added 
Php :: jsondecodephparray 
Php :: set session expire time in php 
Php :: get session token in wp_login hook 
Php :: codeigniter query Profiling 
Php :: laravel validation on gropu route 
Php :: Josn_encode php api encoding issue 
Php :: How to add page heading in FPDF PHP 
Php :: wp_signon wordpress login subdomain 
Php :: php sum 2 arrays 
Php :: Calculate the remaining days on view Laravel, negative days if date has passed 
Php :: wp_remote_post decode data 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =