Skip to content

First model

Our first model

  1. Open your www-project folder. alt text
  2. in App/Model folder, create a new .php file and edit it in your favourite code editor. alt text
  3. Paste the following code, save:
    <?php
    
    namespace App\Model;
    
    use System\DateProperty;
    use System\ModelMeta;
    use System\StringProperty;
    use System\TextProperty;
    
    class MyFirstModel extends \System\Model\DefaultModel
    {
    
        public static function meta(): ?ModelMeta
        {
            return (new ModelMeta('MyFirstModel'))->enable();
        }
    
        protected function getAdditionalProperties(): array
        {
            return [
                new StringProperty("name"),
                new TextProperty("description"),
                new DateProperty("date")
            ];
        }
    }
    
  4. Reload index.php:
    alt text

Congratulations

You've successfully modeled your first business entity!

OnError

Next