Weave Code
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 :::

(Static)=

Static Persistence

:::{php:class} Persistence\Static_ :::

Static Persistence extends {php:class}Persistence\Array_ to implement a user-friendly way of specifying data through an array.

Usage

This is most useful when working with "sample" code, where you want to see your results quick:

$table->setModel(new Model(new Persistence\Static_([
    ['VAT_rate' => '12.0%', 'VAT' => '36.00', 'Net' => '300.00'],
    ['VAT_rate' => '10.0%', 'VAT' => '52.00', 'Net' => '520.00'],
])));

Lets unwrap the example:

:::{php:method} __construct :::

Constructor accepts array as an argument, but the array could be in various forms:

  • can be array of strings ['one', 'two']
  • can be array of hashes. First hash will be examined to pick up fields
  • can be array of arrays. Will name columns as 'field1', 'field2', 'field3'.

If you are using any fields without keys (numeric keys) it's important that all your records have same number of elements.

Static Persistence will also make attempt to deduce a "title" field and will set it automatically for the model. If you have a field with key "name" then it will be used. Alternative it will check key "title".

If neither are present you can still manually specify title field for your model.

Finally, static persistence (unlike {php:class}Persistence\Array_) will automatically populate fields for the model and will even attempt to deduce field types.

Currently it recognizes integer, date, boolean, float, array and object types. Other fields will appear as-is.

Saving Records

Models that you specify against static persistence will not be marked as "Read Only" ({php:attr}Model::$readOnly), and you will be allowed to save data back. The data will only be stored inside persistence object and will be discarded at the end of your PHP script.

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.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony