Skip to content

Example (1): Fleet Management

This is what we are going to build:

  • vehicles with licenseplate, model etc.
  • mileage readings
  • additional information about repairs
  • additional information about leasing conditions
  • contracts and other documents (pdf-attachments)
  • last inspection and upcoming inspections

Models

Model vehicle

  • id automatically created
  • licenseplate
  • chassisnumber
  • model will be a fixed list (Array) of car-models at first
  • manufacture_month
  • purchase_month
  • purchase_mileage mileage at the time of purchase

PHP

File: App\Model\FLM\Vehicle.php

<?php

namespace App\Model\FLM;

use System\Model\DefaultModel;
use System\ModelMeta;
use System\MonthProperty;
use System\NumericWithUnitProperty;
use System\SelectProperty;
use System\StringProperty;

class Vehicle extends DefaultModel
{
    public static function meta(): ?ModelMeta
    {
        // args:
        //  label (plural)
        //  icon (from phosphoricons.com)
        return (new ModelMeta('Vehicles', 'car'))
            ->withNamespace('FLM-Fleet Management')
            ->enable(); // important! 
    }

    protected function getAdditionalProperties(): array
    {
        return [
            (new StringProperty("licenseplate"))->required(),
            (new StringProperty("chassisnumber"))->required(),

            // simple lookup list for now (array or models) 
            (new SelectProperty("model", [
                'Audi A4',
                'Audi A6',
                'Audi A8',
            ]))->required(),

            (new MonthProperty("manufacture_month")),
            (new MonthProperty("purchase_month")),
            (new NumericWithUnitProperty("purchase_mileage", ['km', 'ml'], 'km', 1, false)),
        ];
    }
}

This will already create necessary tables and relations and provide nodes in our TreeView:

alt text

Let us create a new Vehicle:

alt text

The details area (right hand side) shows our properties:

alt text

required properties are highlighted. Note the dropdown-lists for Model and Mileage-Units (km/ml). Also, our month-properties render as month-selectors.

Let us fill some data and save:

alt text

Congratulations, we have our first Vehicle record:

alt text

Notes

  1. Tree View showing our namespaces and models.
  2. List View showing records of selected model.
  3. Detail View showing data of selected record.
  4. Audit Trail of selected record (history of changes)
  5. Search bar - just try!

Next

Change ListView Label