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

Events

There are several events that will automatically be called when interacting with Atlas mappers.

Note:

These mapper-level events are called in addition to the various table-level events.

The insert(), update(), and delete() methods all have 3 events associated with them: a before*(), a modify*(), and an after*(). In addition, there is a modifySelect() event.

// Runs after the Select object is created, but before it is executed
modifySelect(Mapper $mapper, MapperSelect $select)

// Runs before the Insert object is created
beforeInsert(Mapper $mapper, Record $record)

// Runs after the Insert object is created, but before it is executed
modifyInsert(Mapper $mapper, Record $record, Insert $insert)

// Runs after the Insert object is executed
afterInsert(Mapper $mapper,
            Record $record,
            Insert $insert,
            PDOStatement $pdoStatement)

// Runs before the Update object is created
beforeUpdate(Mapper $mapper, Record $record)

// Runs after the Update object is created, but before it is executed
modifyUpdate(Mapper $mapper, Record $record, Update $update)

// Runs after the Update object is executed
afterUpdate(Mapper $mapper,
            Record $record,
            Update $update,
            PDOStatement $pdoStatement)

// Runs before the Delete object is created
beforeDelete(Mapper $mapper, Record $record)

// Runs after the Delete object is created, but before it is executed
modifyDelete(Mapper $mapper, Record $record, Delete $delete)

// Runs after the Delete object is executed
afterDelete(Mapper $mapper,
            Record $record,
            Delete $delete,
            PDOStatement $pdoStatement)

Here is a simple example with the assumption that the Record object has a validate() method and a getErrors() method. See the section on Adding Logic to Records and RecordSets.

namespace Blog\DataSource\Posts;

use Atlas\Mapper\Mapper;
use Atlas\Mapper\MapperEvents;
use Atlas\Mapper\Record;

/**
 * [@inheritdoc](https://github.com/inheritdoc)
 */
class PostsEvents extends MapperEvents
{
    public function beforeUpdate(Mapper $mapper, Record $record)
    {
        if (! $record->validate())
            throw new \Exception('Update Error');
        }

    }
}

And you might have something like this in your code:

try {
    $atlas->update($post);
} catch (\Exception $e) {
    foreach ($post->getErrors() as $error) {
        echo $error . '<br/>';
    }
}
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