Check documentation for the latest version of dhtmlxSuite Step 3. Create a Model DHTMLX Docs

Step 3. Create a Model

To access the data we need to specify the appropriate model class.

To know more about using models, read the Database Access & ORM article from the framework documentation.

To create models:
  1. Create 3 files with the names "GanttTaskTable.php", "GanttLinkTable.php","SchedulerEventTable.php" in the "cakephp_dhtmlx/src/Model/Table" directory.
  2. Open the "GanttTaskTable.php" file and add the following code there:

    "GanttTaskTable.php" file

    <?php
    namespace App\Model\Table;
    use Cake\ORM\Table;
     
    class GanttTaskTable extends Table {
        public function initialize(array $config){
            $this->table('gantt_tasks');
            $this->primaryKey('id');
        }
    }


  3. Add the code below into the "GanttLinkTable.php" file:

    "GanttLinkTable.php" file

    <?php
    namespace App\Model\Table;
    use Cake\ORM\Table;
     
    class GanttLinkTable extends Table {
        public function initialize(array $config){
            $this->table('gantt_links');
            $this->primaryKey('id');
        }
    }


  4. Put the following code to the "SchedulerEventTable.php" file:

    "SchedulerEventTable.php" file

     <?php
    namespace App\Model\Table;
    use Cake\ORM\Table;
     
    class SchedulerEventTable extends Table {
        public function initialize(array $config){
            $this->table('scheduler_events');
            $this->primaryKey('event_id');
        }
    }


  5. For Grid we'll use the same model as the one used for Scheduler - 'scheduler_events'.
Back to top