Untitled

 avatar
unknown
plain_text
2 years ago
1.3 kB
7
Indexable
<?php

namespace App\Models;

// use Illuminate\Database\Eloquent\Factories\HasFactory;
// use Illuminate\Database\Eloquent\Model;

// class Account extends Model
// {
//     use HasFactory;
// }

class Account{


    public $items=[];
    public $totalAmount;
    public $totalQty;

    public function _construct($cart=null)
    {
        if($cart)
        {
            $this->items = $cart->items;
            $this->totalAmount= $cart->$totalAmount;
            $this->totalQty=$cart->$totalQty;
        }
        else{
            $this->items=[];
            $this->totalAmount=0;
            $this->totalQty=0;

        }
    }

    public function add($about)
    {
        //$item
        $items =[
            'id'=>$about->id, 
            'name'=>$about->name,
            'amount'=>$about->amount,
            'qty'=>0,
            'image'=>$about->image,
            'file'=>$about->file
        ];
        if(!array_key_exists($about->id, $this->items))
        {
            $this->totalQty=1;   
            $this->totalAmount=$totalAmount;   
        }
        else{
            $this->totalQty=1;   
            $this->totalAmount=$totalAmount;   
        }

        $this->items[$about->id]['qty']=1;

        
    }


}
Editor is loading...