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

Orm Laravel Package

atlas/orm

View on GitHub
Deep Wiki
Context7

Record and RecordSet Behaviors

Atlas makes it easy to add your own behaviors to both Records and RecordSets.

It's important to note that the Record and RecordSet objects described below should only be used for very simple behaviors. Any non-trivial domain work may be an indication that you need a domain layer. See the documentation on Domain Models for examples of how you can use Atlas to build a domain layer.

For example:

namespace App\DataSource\Thread;

use Atlas\Mapper\Record;

class ThreadRecord extends Record
{
    // Format the date_created property
    public function formatDate($format = 'M jS, Y')
    {
        $dateTime = new \DateTime($this->date_created);
        return $dateTime->format($format);
    }
}

$thread = $atlas->fetchRecord(Thread::CLASS, $id);
echo $thread->formatDate(); // outputs something like `Aug 21st, 2017`

The same concept is available for RecordSets using the RecordSet class. In our example ThreadRecordSet.php.

namespace App\DataSource\Thread;

use Atlas\Mapper\RecordSet;

class ThreadRecordSet extends RecordSet
{
    public function getAllTitles()
    {
        $titles = []
        foreach ($this as $record) {
            $titles[$record->thread_id] = $record->title;
        }
        return $titles;
    }
}
$threads = $atlas->fetchRecordSet(Thread::CLASS, [1, 2, 3]);

print_r($threads->getAllTitles());
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