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', ...

Get Magento 2 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.