Извеждане на цена от базата

vinsbg

Registered
Здравейте,

Пак с тоз Laravel ще ви занимавам...
В базата данни при поръчка се запазва order_id, user_id и поле data, което съдържа това:
Код:
{"12":
	{
		"title":"Test Product 2",
		"description":"The perfect way to explain a visual platform is to make a product page that demonstrates the abilities of that visual platform. The entire page lets users see all of Wistia's features and how they'd fit into their day-to-day.",
		"quantity":1,
		"image":
		"\/uploads\/AYUM0ro6TKux6KBnCa10.jpg",
		"price":"1120.00"
	},
	"shipping": 
		{
			"quantity":1,
			"image":"\/img\/noimage.png",
			"description":"",
			"title":
			"Normal Delivery",
			"price":0
		}
}

Как мога да взема само цената - price и да я сетна тук
Код:
    public function paymentView( $orderId, $userId ) {

        $order = Session::all();

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

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

	    $userID 		= $order['user_id'];			
	    $userFormat	= "SESSION";			
	    $orderID 		= $order['order_id'];	      
	    $amount		= $order['price'];

Ето тук:
$amount = $order['price'];

С другите няма проблем тъй като те са си в отделни колони...
 
lam3r4370 каза:
$data = json_decode($order['data'],true);
$price = $data[$orderID]['price']
Благодаря, но в този случай дали ще вземе и цената ако има тука
Код:
"shipping": 
      { 
         "quantity":1, 
         "image":"\/img\/noimage.png", 
         "description":"", 
         "title": 
         "Normal Delivery", 
         "price":0 
      }
В смисъл дали ще ги събере?
 
Ами както виждаш, няма да ги събере, но няма никакъв проблем да го направиш
$price = $data[$orderID]['price'] + $data['shipping']['price']
 

Back
Горе