MOON
Server: Apache
System: Linux u18017238.onlinehome-server.com 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64
User: emblazeone (1003)
PHP: 7.3.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/emblazeone/public_html/lyyt/frontend/models/CartItem.php
<?php

namespace frontend\models;

use backend\modules\products\models\Products;
use Yii;
use yii\base\Model;

class CartItem extends Model{
    public $product_id;
    public $size;
    public $date;

    public function rules()
    {
        return [
            [['product_id','size','date'], 'safe']
        ];
    }

    public function getProduct(){
        return Products::findOne($this->product_id);
    }

    public function getPrice(){
        return (int)$this->product->{'price_'.$this->size};
    }

    public function getDayPrice(){
        $days=Products::getLengths()[$this->size];
        return (int)($this->product->{'price_'.$this->size}/$days);
    }

    public function getDayTitle(){
        return Products::getLengthsDays()[$this->size];
    }
}