Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
dtemaster committed Oct 19, 2021
2 parents 90c414f + b0cf3da commit 3793800
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions demo/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@
use Atk4\Ui\Columns;
use Atk4\Ui\Layout;

$t = [
$t = [
['name' => 'January', 'sales' => 20000, 'purchases' => 10000],
['name' => 'February', 'sales' => 23000, 'purchases' => 12000],
['name' => 'March', 'sales' => 16000, 'purchases' => 11000],
['name' => 'April', 'sales' => 14000, 'purchases' => 13000]];

$m = new Model(new Array_($t));
$m = new \Atk4\Data\Model(new \Atk4\Data\Persistence\Array_($t));
$m->getField('id')->required=false; // Bug in Array_ persistence assigning id=0 to first record.

$m->addFields(['name', 'sales', 'purchases', 'profit']);

$m->onHook($m::HOOK_AFTER_LOAD, function ($m) { $m->set('profit', $m->get('sales') - $m->get('purchases')); });
$app = new App('Chart Demo');
$app->initLayout([Layout\Centered::class]);
Expand Down

0 comments on commit 3793800

Please sign in to comment.