Source of file Brand.php
Size: 2,338 Bytes - Last Modified: 2021-12-24T06:40:39+00:00
/var/www/docs.ssmods.com/process/src/src/model/Brand.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 | <?php namespace Cita\eCommerce\Model; use SilverStripe\ORM\DataObject; use SilverStripe\Assets\Image; use Leochenftw\Extension\SlugifyExtension; /** * Description * * @package silverstripe * @subpackage mysite */ class Brand extends DataObject { /** * Defines the database table name * @var string */ private static $table_name = 'Cita_eCommerce_Brand'; /** * Database fields * @var array */ private static $db = [ 'Title' => 'Varchar(128)', 'Content' => 'HTMLText' ]; /** * Has_one relationship * @var array */ private static $has_one = [ 'Logo' => Image::class ]; /** * Relationship version ownership * @var array */ private static $owns = [ 'Logo' ]; private static $cascade_deletes = ['Logo']; /** * Defines extension names and parameters to be applied * to this object upon construction. * @var array */ private static $extensions = [ SlugifyExtension::class ]; /** * Has_many relationship * @var array */ private static $has_many = [ 'Products' => Product::class ]; /** * Defines summary fields commonly used in table columns * as a quick overview of the data for this dataobject * @var array */ private static $summary_fields = [ 'getLogoThumb' => 'Logo', 'Title' => 'Title', 'Products.Count' => 'Products' ]; public function getLogoThumb() { if ($this->Logo()->exists()) { return $this->Logo()->ScaleWidth(128); } return null; } /** * CMS Fields * @return FieldList */ public function getCMSFields() { $fields = parent::getCMSFields(); return $fields; } public function getData() { return [ 'title' => $this->Title, 'slug' => $this->Slug, 'url' => $this->Link(), 'logo' => $this->Logo()->getData('ScaleWidth', 64) ]; } private function Link() { if ($catalog = Catalog::get()->first()) { return $catalog->Link() . '?brand=' . $this->Slug; } return '?brand=' . $this->Slug; } } |