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 Eloquent ORM guide from the Laravel framework documentation.

To create models:
  1. Create 3 files with the names "GanttTask.php", "GanttLink.php","SchedulerEvent.php" in the "laravel_dhtmlx/app" directory.
  2. Open the "GanttTask.php" file and add the following code there:

    "GanttTask.php" file

    <?php
    namespace App;
    use Illuminate\Database\Eloquent\Model;
     
    class GanttTask extends Model
    {
        protected $table = "gantt_tasks";
        public $primaryKey = "id";
        public $timestamps = false;
    }


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

    "GanttLink.php" file

    <?php
    namespace App;
    use Illuminate\Database\Eloquent\Model;
     
    class GanttLink extends Model
    {
        protected $table = "gantt_links";
        public $primaryKey = "id";
        public $timestamps = false;
    }


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

    "SchedulerEvent.php" file

    <?php
    namespace App;
    use Illuminate\Database\Eloquent\Model;
     
    class SchedulerEvent extends Model
    {
        protected $table = "scheduler_events";
        public $primaryKey = "event_id";
        public $timestamps = false;
    }


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