htmlspecialchars() expects parameter 1 to be string, object given

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


htmlspecialchars() expects parameter 1 to be string, object given



This is Controller. I named it CartController


<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use GloudemansShoppingcartFacadesCart;
use AppProduct;

class CartController extends Controller
{

public function index()
{
$cartItems=Cart::content();
return view('cart.index', compact('cartItems'));
}

public function edit($id)
{
$product=Product::find($id);

Cart::add($id,$product->name,'1',$product->price);
}



This is my welcome.blade.php. This is the page where I display all my Items.


<div class="row">
@forelse($books->chunk(4) as $chunk)
@foreach($chunk as $book)
<div class="column-prod">
<a href="{{url('view')}}">
<div class="card-prod">
<center><img src="{{url('images',$book->image)}}" style="width: 300px; height: 300px;"></center> </a>
<div class="container-prod">
<h2></h2>
<p class="title">{{$book->name}}</p>
<p class="price">₱ {{$book->price}}</p>

<p><a href="{{ route('cart.edit',$book->id)}}" class="button"><i class="fas fa-cart-arrow-down"></i>Add to Cart</button></a></p>
<p><button class="button"><i class="fas fa-heart"></i> Add to Wishlist</button></p>
</div>
</div>
</div>

@endforeach
@empty
<h3> No Books </h3>
@endforelse


</div> <!--Div all end-->



This is the codes of my Cart Page. When the user click add to cart in the welcome page, his/her chosen items will be place in this page.


<h3> Cart Items </h3>

<!--TABLE NAMESSS-->
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Image</th>
<th scope="col">Name</th>
<th scope="col">Price</th>
<th scope="col">Quantity</th>

</tr>
</thead>


<tbody>
@foreach($cartItems as $cartItem)
<li>{{$cartItem->name}}</li>
<tr>

<td>{{url('images',$cartItem->image)}}</td>
<td>{{$cartItem->name}}</td>
<td>{{$cartItem->price}}</td>
<td>{{$cartItem->qty}}</td>

</tr>
@endforeach
</tbody>
</table>



This is my route.


Route::get('/', function () {
return view('welcome')->with(['books' => AppProduct::all()]);
});

Route::get('/cart','ShopController@cart');

Route::get('/signin','ShopController@signin');



Route::resource('/cart','CartController');

Route::get('/wishlist','ShopController@wish');



Auth::routes();

Route::get('/logout', 'AuthLoginController@logout');

Route::get('/home', 'HomeController@index');

Route::group(['prefix' => 'admin', 'middleware' => 'auth'], function(){
Route::get('/',function(){
return view('admin.index');
})->name('admin.index');


Route::resource('product','ProductsController');
Route::resource('category','CategoriesController');
});

Route::get('/categ', function(){
return view ('admin.category.categ_index');

});



I'm confused I don't know how to fix my error. This is the complete error that the system return.



"htmlspecialchars() expects parameter 1 to be string, object given (View: C:xampphtdocsShopresourcesviewswelcome.blade.php)"



I hope you can help me in solving this. Your answers are very much appreciated.





Possible duplicate of Laravel 5.3 - htmlspecialchars() expects parameter 1 to be string
– hungrykoala
1 min ago









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived