<?php

use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Assets\File;
use SilverStripe\Assets\Image;
use SilverStripe\AssetAdmin\Forms\UploadField;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldConfig_Base;
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor;
use SilverStripe\ORM\DataObject;
use UndefinedOffset\SortableGridField\Forms\GridFieldSortableRows;
use SilverStripe\Versioned\Versioned;

class IndustryPage extends Page
{
    private static $db = [

    ];

    private static $has_one = [
        'Icon' => Image::class,
    ];
    
    private static $has_many = [
       // 'Industries' => Industry::class,
    ];
   
    private static $owns = [
       //  'Industries'
    ];
    
public function getCMSFields() 
  {
    $fields = parent::getCMSFields();

    $fields->addFieldToTab('Root.Main', UploadField::create('Icon'), 'Content');
  /*  $IndustryField =  GridField::create(
            'Industries',
            'Industries on this page',
            $this->Industries(),
            GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldSortableRows('SortOrder'))
        );
  //  $IndustryField->addComponent(new GridFieldSortableRows('SortOrder'));
    $fields->addFieldToTab('Root.Industries',$IndustryField);
    */
    return $fields;
  }
}

/*
class Industry extends DataObject{
    private static $extensions = [
        Versioned::class
    ]; 
    private static $db = [
         'Title' => 'Text',
         'Description' => 'HTMLText',
         'SortOrder' => 'Int',
         'Active' => 'Boolean'
    ];
    
    private static $has_one = [
        'Icon' => Image::class,

        'IndustryPage' => IndustryPage::class,
    ];
    
    private static $summary_fields = [
        'Title' => 'Title',
        'Active' => 'Active',
        'SortOrder' => 'Sort Order'
    ];
    
    private static $owns = [
        'Icon'
    ];
    
}*/