thybag/pseudo-model

PseudoModel is an eloquent like model base for backing on to custom data structures.

0.2.0 2023-05-31 15:26 UTC

This package is auto-updated.

Last update: 2024-04-30 00:26:22 UTC


README

PseudoModel is an eloquent-like base model for laravel, aiming to mirror the majority of the laravels basic model functionality.

Using PseudoModel you can represent and interact with none-database based data in much the same way you would any normal Model, hopefully simplifying the code you need the write. In the past I've used this approach for mapping on to LDAP as well as 3rd party API's.

In order to provide the standard eloquent eventing behaviors, you can use the persist method to define your save logic. The method will change depending on whether the change is create, update or delete.

    /**
     * Persist model changes. Called on save & delete.
     *
     * @param  string $action  create|update|delete
     * @param  array  $options
     * @return boolean true|false
     */
    protected function persist($action, array $options = []): bool
    {
        return true;
    }

This library is still in progress so not yet recommended for use in production.