Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Data Laravel Package

atk4/data

ATK Data is a PHP data model abstraction that separates business logic from UI and persistence. Works with SQL/NoSQL/APIs, supports relations, expressions, aggregation, and user actions with ACL metadata—integrates easily with ATK UI and ATK API.

View on GitHub
Deep Wiki
Context7

:::{php:namespace} Atk4\Data :::

(Aggregates)=

Model Aggregates

:::{php:class} Model\AggregateModel :::

In order to create model aggregates the AggregateModel model needs to be used:

Grouping

AggregateModel model can be used for grouping:

$aggregate = new AggregateModel($orders)->setGroupBy(['country_id']);

$aggregate above is a new object that is most appropriate for the model's persistence and which can be manipulated in various ways to fine-tune aggregation. Below is one sample use:

$aggregate = new AggregateModel($orders);
$aggregate->addField('country');
$aggregate->setGroupBy(['country_id'], [
        'count' => ['expr' => 'count(*)', 'type' => 'bigint'],
        'total_amount' => ['expr' => 'sum([amount])', 'type' => 'atk4_money'],
    ],
);

// $aggregate will have following rows:
// ['country' => 'UK', 'count' => 20, 'total_amount' => 123.2];
// ...

Below is how opening balance can be built:

$ledger = new GeneralLedger($db);
$ledger->addCondition('date', '<', $from);

// we actually need grouping by nominal
$ledger->setGroupBy(['nominal_id'], [
    'opening_balance' => ['expr' => 'sum([amount])', 'type' => 'atk4_money'],
]);
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator