error with laravel 5.3

0

I'm following a tour for Laravel 5.3 and I'm in the implementation of a shopping bug but I have an error in the whole project for having called a variable in the following file:

resourses / layouts / app.blade

where I place:

<li>
    Mi carrito
    <span class="circle-shopping-cart">
        {{$shopping_cart->productsSize()}}
    </span>
</li>

I have created the ShoppingCArt model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class ShoppingCart extends Model
{
    protected $fillable = ["status"];
    
    public function productsSize(){
        return 20;
    }
    
    public static function findOrCreateBySessionID($shopping_cart_id){
        if($shopping_cart_id)
            return ShoppingCart::findBySession($shopping_cart_id);
        else
            
            return ShoppingCart::createWithoutSession();
    }
    
    public static function findBySession($shopping_cart_id){
        return ShoppingCart::find($shopping_cart_id);
    }
    
    public static function createWithoutSession(){
        
        return ShoppingCart::created([
            "status" => "incompleted"
        ]);
    }
}

and this is your controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

use App\ShoppingCart;

class MainController extends Controller
{
    public function home()
    {
        $shopping_cart = ShoppingCart::findOrCreateBySessionID(null);
        return view('main.home',["shopping_cart" => $shopping_cart]);
    }
}

But it gives me an error that tells me that the error is here:

<li>
    Mi carrito
    <span class="circle-shopping-cart">
        {{$shopping_cart->productsSize()}}
    </span>
</li>

I DO NOT SEE THE ERROR

    
asked by jofret 04.12.2018 в 14:50
source

0 answers