File: /home/artinside/www/lhh/source/Models/Ecommerce/ProductVariations.php
<?php
namespace Source\Models\Ecommerce;
use Source\Core\Model;
/**
* Class ProductVariations
* @package Source\Models\Ecommerce
*/
class ProductVariations extends Model
{
/**
* Post constructor.
*/
public function __construct()
{
parent::__construct("product_variations", ["id"], ["product_id", "width", "height", "depth", "weight", "price"]);
}
/**
* @param string $gallery_link
* @param string $columns
* @return null|Post
*/
public function findByGLink(string $gallery_link, string $columns = "*"): ?ProductVariations
{
$find = $this->find("gallery_link = :gallery_link", "gallery_link={$gallery_link}", $columns);
return $find->fetch();
}
/**
* @return null|Product
*/
public function product(): ?Product
{
if ($this->product_id) {
return (new Product())->find("gallery_link = :gl", "gl={$this->product_id}")->fetch();
}
return null;
}
}