O'Reilly logo

Magento 2 Developer's Guide by Branko Ajzele

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Managing entity persistence (model, resource, collection)

With InstallSchema in place, we now have conditions for entity persistence. Our next step is to define model, resource, and collection classes for the Ticket entity.

The Ticket entity model class is defined under the app/code/Foggyline/Helpdesk/Model/Ticket.php file with content as follows:

<?php namespace Foggyline\Helpdesk\Model; class Ticket extends \Magento\Framework\Model\AbstractModel { const STATUS_OPENED = 1; const STATUS_CLOSED = 2; const SEVERITY_LOW = 1; const SEVERITY_MEDIUM = 2; const SEVERITY_HIGH = 3; protected static $statusesOptions = [ self::STATUS_OPENED => 'Opened', self::STATUS_CLOSED => 'Closed', ]; protected static $severitiesOptions = [ self::SEVERITY_LOW => 'Low', ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required