2016-06-13 9 views
0

ユーザーが注文すると、彼は彼が支払いをしたかどうかを確認する別のページにリダイレクトします。コントローラは準備が整っており、これを行うボックスを初期化する必要があり、変数を取る必要があります。これをpayment.blade.phpに実装する方法はわかりません。これは私が試みたもので、うまくいかないようです。Laravelのコントローラから表示する変数を渡す方法

このコントローラ

public function paymentView($orderId, $userId) { 

    $order = Session::all(); 

    $order = Order::where('order_id', $orderId)->first(); 

    if (!$order) { 
     App::abort(404); 
    } 


    $userID   = $order['user_id'];       
    $orderID  = $order['order_id'];   

    $options = array(
     ... 
    ); 

    // Initialise Payment Class 
    $box = new Cryptobox ($options); 

    // coin name 
    $coinName = $box->coin_name(); 

    // Successful Cryptocoin Payment received 
    if ($box->is_paid()) 
    { 
     if (!$box->is_confirmed()) { 
      $message = "Thank you for payment (payment #".$box->payment_id()."). Awaiting transaction/payment confirmation"; 
     }           
     else 
     { 

      if (!$box->is_processed()) 
      { 

       $message = "Thank you for order (order #".$orderID.", payment #".$box->payment_id()."). We will send soon"; 

       $box->set_status_processed(); 
      } 
      else $message = "Thank you. Your order is in process"; // General message 
     } 
    } 
    else $message = "This invoice has not been paid yet"; 

    $languages_list = display_language_box($def_language); 

    return View::make('site.cart.payment', [ 
       'order' => $order, 
    ]); 
} 

は今、私はboxが定義されていないというエラーを持っているページを実行すると、私の見解では

@section('content') 
    @foreach($order->getOrderData(true) as $productId => $item) 
    <?php if (!$box->is_paid()) echo "<h2>Pay Invoice Now - </h2>"; else echo "<br><br>"; ?> 

    <?php echo $box->display_cryptobox(true, 580, 230); ?> 
    @endforeach 
@endsection 

これを置くしようとしています。この情報をビューでどのように取ることができますか?

+1

yy ... $ orderを追加したのとまったく同じです。 – nospor

答えて

0

同様に、$orderをビューに渡しました。あなたの一番下にあるreturnをこの戻り値に置き換えます。

return View::make('site.cart.payment', [ 
    'order' => $order, 
    'box' => $box 
]); 

View::make()に渡される第二の引数は、ビューに利用可能にされるべきデータの配列です。

+0

さて、なぜ私は2倍のボックスを今すぐ入手したのですか? –

+0

問題はforeachにありますが、何や理由が理解できません。 –

関連する問題