I have a problem where a data cannot be displayed on blade but can be recognized on debug
This is The Controller
public function cart($cid)
{
// $cart = DB::select("select*from carts where id = ?", [$cid]);
$cart = Cart::find( $cid );
// dd($cart);
$pizza = Pizza::find( $cart->Pizzaid );
// dd($pizza);
return view('cart')->with('cart', $cart)->with('pizza', $pizza);
}
this is the "cart.blade.php"
@extends('layouts.app')
@section('content')
{{-- View Cart--}}
<div class="container">
@foreach($cart as $c)
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-xl-3">
<img class="card-img-top" src="{{asset("assets/$pizza->Image")}}" alt="" style="object-fit:cover">{{-- taking the image of the pizza that the user bought --}}
</div>
<div class="col-xl-7">
<p class="font-weight-bold">{{ $pizza->Name }}</p>
<p>{{ $pizza->Price }}{{-- Price --}}</p>
<p>{{ $c->Quantity }}</p>
<div class="row">
<p class="col-4">Quantity: </p>
<input class="form-control col-7" type="text" placeholder="">
</div>
<p>{{ $pizza->Price * $c->Quantity }}</p>
</div>
</div>
</div>
</div>
@endforeach
</div>
@endsection
this is the "dd(cart)"
App\Cart {#1078 ▼
#connection: "mysql"
#table: "carts"
#primaryKey: "id"
#keyType: "int"
+incrementing: true
#with: []
#withCount: []
#perPage: 15
+exists: true
+wasRecentlyCreated: false
#attributes: array:6 [▼
"userid" => 2
"Pizzaid" => 1
"id" => 2
"Quantity" => 1
"created_at" => "2020-12-15 13:10:43"
"updated_at" => "2020-12-15 13:10:43"
]
#original: array:6 [▶]
#changes: []
#casts: []
#classCastCache: []
#dates: []
#dateFormat: null
#appends: []
#dispatchesEvents: []
#observables: []
#relations: []
#touches: []
+timestamps: true
#hidden: []
#visible: []
#fillable: []
#guarded: array:1 [▶]
}
So the Quantity can be seen as 1 in the debug but when being displayed, it shows an error. Is there anything I can do to resolve this? I already tried different syntax on the controller like using "where" instead of "find" but it still does not work