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

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.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor