Back-end/laravel-iamport/iamport-payments/app/Http/Controllers/OrderController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        $orders = Order::unpaid()->get();
        $unpaidPayment = Payment::create([
           'amount' => $orders->reduce(function ($amount, $order) {
               return $amount += $order->amount;
           })
        ]);
        return view('orders.index', [
            'orders' => $orders,
            'merchant_uid' => $unpaidPayment->merchant_uid,
            'amount' => $unpaidPayment->amount
        ]);
    }
public function index ( ) { $ orders = Order :: unpaid ( ) -> get ( ) ; $ unpaidPayment = Payment :: create ( [ 'amount' => $ orders -> reduce ( function ( $ amount , $ order ) { return $ amount += $ order -> amount ; } ) ] ) ; return view ( 'orders.index' , [ 'orders' => $ orders , 'merchant_uid' => $ unpaidPayment -> merchant_uid , 'amount' => $ unpaidPayment -> amount ] ) ; }
Display a listing of the resource.
Display a listing of the resource .