A drop-in library for certain database functionality in Laravel, that allows for extra features that may never make it into the main project.

Related tags

Database eloquence
Overview

Eloquence

Version Downloads Status

Eloquence is a package to extend Laravel's base Eloquent models and functionality.

It provides a number of utilities and classes to work with Eloquent in new and useful ways, such as camel cased attributes (for JSON apis), count caching, uuids and more.

Installation

Install the package via composer:

composer require kirkbushell/eloquence:~4.0

For Laravel 6, please install:

composer require kirkbushell/eloquence:~3.0

For Laravel 5, please install the ~2.0 suite of releases.

composer require kirkbushell/eloquence:~2.0

For Laravel 4, please install the 1.1.5 release. Please note that this is no longer supported.

composer require kirkbushell/eloquence:1.1.5

Usage

First, add the eloquence service provider to your config/app.php file:

'Eloquence\EloquenceServiceProvider',

It's important to note that this will automatically re-bind the Model class that Eloquent uses for many-to-many relationships. This is necessary because when the Pivot model is instantiated, we need it to utilise the parent model's information and traits that may be needed.

You should now be good to go with your models.

Camel case all the things!

For those of us who prefer to work with a single coding standard right across our applications, using the CamelCaseModel trait will ensure that all those attributes, relationships and associated data from our Eloquent models persist through to our APIs in a camel-case manner. This is important if you are writing front-end applications, which are also using camelCase. This allows for a better standard across our application. To use:

use \Eloquence\Behaviours\CamelCasing;

Put the above line in your models and that's it.

Note!

Eloquence DOES NOT CHANGE how you write your schema migrations. You should still be using snake_case when setting up your fields and tables in your database schema migrations. This is a good thing - snake_case of field names is the defacto standard within the Laravel community :)

UUIDs

Eloquence comes bundled with UUID capabilities that you can use in your models.

Simply include the Uuid trait:

use Eloquence\Behaviours\Uuid;

And then disable auto incrementing ids:

public $incrementing = false;

This will turn off id auto-incrementing in your model, and instead automatically generate a UUID4 value for your id field. One benefit of this is that you can actually know the id of your record BEFORE it's saved!

You must ensure that your id column is setup to handle UUID values. This can be done by creating a migration with the following properties:

$table->char('id', $length = 36)->index();

It's important to note that you should do your research before using UUID functionality and whether it works for you. UUID field searches are much slower than indexed integer fields (such as autoincrement id fields).

Custom UUIDs

Should you need a custom UUID solution (aka, maybe you don't want to use a UUID4 id), you can simply define the value you wish on the id field. The UUID model trait will not set the id if it has already been defined. In this use-case however, it's probably no good to use the Uuid trait, as it's practically useless in this scenario.

Behaviours

Eloquence comes with a system for setting up behaviours, which are really just small libraries that you can use with your Eloquent models. The first of these is the count cache.

Count cache

Count caching is where you cache the result of a count of a related table's records. A simple example of this is where you have a user who has many posts. In this example, you may want to count the number of posts a user has regularly - and perhaps even order by this. In SQL, ordering by a counted field is slow and unable to be indexed. You can get around this by caching the count of the posts the user has created on the user's record.

To get this working, you need to do two steps:

  1. Use the Countable trait on the model and
  2. Configure the count cache settings

Configure the count cache

To setup the count cache configuration, we need to have the model use Countable trait, like so:

class Post extends Eloquent {
    use Countable;
    
    public function countCaches() {
        return [User::class];
    }
}

This tells the count cache that the Post model has a count cache on the User model. So, whenever a post is added, or modified or deleted, the count cache behaviour will update the appropriate user's count cache for their posts. In this case, it would update post_count on the user model.

The example above uses the following standard conventions:

  • post_count is a defined field on the User model table
  • user_id is the field representing the foreign key on the post model
  • id is the primary key on the user model table

These are, however, configurable:

class Post extends Eloquent {
    use Countable;
    
    public function countCaches() {
        return [
            'num_posts' => ['User', 'users_id', 'id']
        ];
    }
}

This example customises the count cache field, and the related foreign key, with num_posts and users_id, respectively.

Alternatively, you can be very explicit about the configuration (useful if you are using count caching on several tables and use the same column name on each of them):

class Post extends {
    use Countable;
    
    public function countCaches() {
        return [
            [
                'model'      => 'User',
                'field'      => 'num_posts',
                'foreignKey' => 'users_id',
                'key'        => 'id'
            ]
        ];
    }
}

If using the explicit configuration, at a minimum you will need to define the "model" parameter. The "countField", "foreignKey", and "key" parameters will be calculated using the standard conventions mentioned above if they are omitted.

With this configuration now setup - you're ready to go!

Sum cache

Sum caching is similar to count caching, except that instead of caching a count of a related table's records, you cache a sum of a particular field on the related table's records. A simple example of this is where you have an order that has many items. Using sum caching, you can cache the sum of all the items' prices, and store that sum in the order table.

To get this working -- just like count caching -- you need to do two steps:

  1. Utilise the Summable trait on the model and
  2. Configure the model for any sum caches

Configure the sum cache

To setup the sum cache configuration, simply do the following:

class Item extends Eloquent {
    use Summable;
    
    public function sumCaches() {
        return [Order::class];
    }
}

This tells the sum cache manager that the Item model has a sum cache on the Order model. So, whenever an item is added, modified, or deleted, the sum cache behaviour will update the appropriate order's sum cache for their items. In this case, it would update item_total on the Order model.

The example above uses the following conventions:

  • item_total is a defined field on the Order model table
  • total is a defined field on the Item model table (the column we are summing)
  • order_id is the field representing the foreign key on the item model
  • id is the primary key on the order model table

These are, however, configurable:

class Item extends Eloquent {
    use Summable;
    
    public function sumCaches() {
        return [
            'item_total' => ['Order', 'total', 'order_id', 'id']
        ];
    }
}

Or using the verbose syntax:

class Item extends Eloquent {
    use Summable;
    
    public function sumCaches() {
        return [
            [
                'model'       => 'Order',
                'columnToSum' => 'total',
                'field'       => 'item_total'
                'foreignKey'  => 'order_id',
                'key'         => 'id'
            ]
        ];
    }
}

Both of these examples implements the default settings.

With these settings configured, you will now see the related model's sum cache updated every time an item is added, updated, or removed.

Sluggable models

Sluggable is another behaviour that allows for the easy addition of model slugs. To use, implement the Sluggable trait:

class User extends Eloquent {
    use Sluggable;

    public function slugStrategy() {
        return 'username';
    }
}

In the example above, a slug will be created based on the username field of the User model. There are two other slugs that are supported however, as well:

  • id and
  • uuid

The only difference between the two above, is that if you're using UUIDs, the slug will be generated previous to the save, based on the uuid field. With ids, which are generally auto-increase strategies - the slug has to be generated after the record has been saved - which results in a secondary save call to the database.

That's it! Easy huh?

Changelog

8.0.0

  • Boost in version number to match Laravel

  • Support for Laravel 7.3+

  • Fixes a bug that resulted with the new guarded attributes logic in eloquent

4.0.1

  • Fixes a bug that resulted with the new guarded attributes logic in eloquent

4.0.0

  • Laravel 7 support (thanks, @msiemens!)

3.0.0

  • Laravel 6 support
  • Better slug creation and handling

2.0.7

  • Slug uniqueness check upon slug creation for id-based slugs.

2.0.6

  • Bug fix when restoring models that was resulting in incorrect count cache values.

2.0.3

  • Slugs now implement Jsonable, making them easier to handle in API responses
  • New artisan command for rebuilding caches (beta, use at own risk)

2.0.2

  • Updated PHP dependency to 5.6+
  • CountCache and SumCache behaviours now supported via a service layer

2.0.0

  • Sum cache model behaviour added
  • Booting of behaviours now done via Laravel trait booting
  • Simplification of all behaviours and their uses
  • Updated readme/configuration guide

1.4.0

  • Slugs when retrieved from a model now return Slug value objects.

1.3.4

  • More random, less predictable slugs for id strategies

1.3.3

  • Fixed a bug with relationships not being accessible via model properties

1.3.2

  • Slugged behaviour
  • Fix for fillable attributes

1.3.1

  • Relationship fixes
  • Fillable attributes bug fix
  • Count cache update for changing relationships fix
  • Small update for implementing count cache observer

1.3.0

  • Count cache model behaviour added
  • Many-many relationship casing fix
  • Fixed an issue when using ::create

1.2.0

  • Laravel 5 support
  • Readme updates

1.1.5

  • UUID model trait now supports custom UUIDs (instead of only generating them for you)

1.1.4

  • UUID fix

1.1.3

  • Removed the schema binding on the service provider

1.1.2

  • Removed the uuid column creation via custom blueprint

1.1.1

  • Dependency bug fix

1.1.0

  • UUIDModel trait added
  • CamelCaseModel trait added
  • Model class updated to use CamelCaseModel trait - deprecated, backwards-compatibility support only
  • Eloquence now its own namespace (breaking change)
  • EloquenceServiceProvider added use this if you want to overload the base model automatically (required for pivot model camel casing).

1.0.2

  • Relationships now support camelCasing for retrieval (thanks @linxgws)

1.0.1

  • Fixed an issue with dependency resolution

1.0.0

  • Initial implementation
  • Camel casing of model attributes now available for both setters and getters

License

The Laravel framework is open-sourced software licensed under the MIT license.

Comments
  • Ability to recalculate a count cache (instead of just incrementing/decrementing)

    Ability to recalculate a count cache (instead of just incrementing/decrementing)

    I can't think of a use case off the top of my head, except for what I just did when I added cache counting to an existing set of models and relations.

    The behaviour only calculates if the count should be incremented or decremented from the current value, but there is no way to tell it to do a "hard" recalculation of the value (i.e. get $model->relation()->count() and store it in $model->count_field).

    I'm not sure how that could be handled (maybe an artisan command?), or if there should be an option in the countCaches() configuration to tell it to do full recalculations on updates instead of simple increments/decrements.

    Thoughts?

    opened by cviebrock 18
  • This Breaks Many To Many

    This Breaks Many To Many

    In Laravel 5, if I have a Many to Many relationship, such as:

    public function roles()
    {
        return $this->belongsToMany(Role::class);
    }
    

    and have the tables all set up correct, when I do this in a controller:

    return User::with('roles')->all();
    

    it will always return an empty array for roles if the User model has use CamelCaseModel in it. If I remove that line, it grabs the relationship as expected.

    I am still investigating, but I suspect it has something to do with Laravel doing something specific with attribute starting with pivot_ in these cases, but it's not there cuz we camel cased it, so it can't connect the relationship...?

    bug 
    opened by CWSpear 18
  • Class schema does not exist

    Class schema does not exist

    Just updated to the latest version and added the service provider and can't seem to avoid getting this error bombing the site:

    ReflectionException
    Class schema does not exist
    
    bug 
    opened by ncskrypt 16
  • Eager loading not working

    Eager loading not working

    I'm not sure if I'm missing a step somewhere but my eager loaded belongsTo relationship breaks when I use this package. This code works without the CamelCasing trait but when I add it get an error: ErrorException Undefined property: App\Models\User::$status. My versions of PHP, Laravel and Eloquence are all > 8.

    
    namespace App\Models;
    
    use Eloquence\Behaviours\CamelCasing;
    
    class User extends Authenticatable
    {
        use CamelCasing;
    
        protected $fillable = [
            'status',
        ];
    
        protected $with = ['status'];
    
        public function status()
        {
            return $this->belongsTo(UserStatus::class, 'status', 'status');
        }
    }```
    opened by eempey 14
  • Can't extends orginal Model class

    Can't extends orginal Model class

    Hi,

    when i follow your readme.md, il loaded with composer, i included the service provider in app.php but when i create a new model object it doesn't execute the uuid generation. By the way the closure is loaded in the core laravel Model object but it doesn't affect this class...

    Even when i try to call

    $user= new User(); $user->generateNewUuid(); it throw undefined method in user (and it try to search the method in query builder)

    any idea?

    Thanks in advance

    Cedric LE ROY

    opened by agence86 11
  • Feature request: TotalCache (similar to CountCache)

    Feature request: TotalCache (similar to CountCache)

    In the same way we can add count caching to a model, it would be nice to have a behaviour that cached the sum of some value.

    As an example, a User has many Orders. Right now, we could add a order_count field to the User model and use the existing behaviour to update that. I'm suggesting something that allows one to add a an order_total field as well, that is a cached copy of the sum of some field on the Orders table for that User. e.g.

    UPDATE users SET order_total = (
      SELECT SUM(orders.amount) AS total FROM orders WHERE orders.user_id = users.id
    ) WHERE users.id = ?
    

    Not sure how the configuration would look, but maybe something like this on the Order class:

    public function totalCaches()
    {
        // short syntax
        return [
            // class => fieldToSum
            User::class => 'amount'
        ];
    
        // full syntax
        return [
            // fieldName => [ class, foreignKey, key, fieldToSum ]
            'order_total' => [User::class, 'user_id', id', 'amount'],
        ];
    }
    
    opened by cviebrock 8
  • Adding support for Polymorphic relationships

    Adding support for Polymorphic relationships

    I've come across this package and noticed that only basic relation types are currently supported. I'm currently working on a pull request to add support for polymorphic relationships. I should have the PR ready in the next couple of days but I wanted to see what the initial reaction would be to adding such a feature.

    opened by bronxct1 7
  • Add a Force option to force-use the `rebuild` instead of the `update` method

    Add a Force option to force-use the `rebuild` instead of the `update` method

    I think it should be nice to have a force option (default to false) to permit to use the rebuildCacheRecord method instead of the updateCacheRecord :

    'force' => true
    

    Because for me, a counter cache based only on an increment/decrement is not very efficient and can cause some issues in some cases. Of course this option can be applied to the Sum Behavior also.

    This PR is only to show you the feature (with tests btw) i'm pretty sure you will implement it better then me. ^^

    interesting 
    opened by Xety 6
  • CamelCaseModel doesn't work with hidden/visible/dates fields

    CamelCaseModel doesn't work with hidden/visible/dates fields

    Hi!

    I've been attempting to use this trait in a Laravel 5.1 application, but have hit a problem with the $hidden property.

    If I define a property to be hidden in camel case, it is ignored:

    ...
    protected $hidden = [
        'lastLogin', // Ignored (model renders out lastLogin field)
        'is_active', // Hidden as expected
    ];
    ...
    

    This appears to be the case for the $dates and $visible properties as well (and there could be others I guess).

    Digging in to the core Eloquent model, it seems that getHidden could be overridden to correct this behaviour, but the withHidden method would not work properly either because it uses the $hidden array directly instead of through the accessor.

    Are there any plans to support these properties in a consistent way?

    This one came as a bit of a surprise and it has some security implications if the developer expects their fields to be hidden and they are not.

    Thanks, Chris

    opened by cgwyllie 6
  • Error thrown in model when trying to implement a custom pivot model relationship

    Error thrown in model when trying to implement a custom pivot model relationship

    I've created a custom pivot model with the following code, and am getting an error:

    Edit :: Sorry this isn't the custom pivot model, this is a normal model, but contains the newPivot method necessary to use a custom pivot model, which is related to this model. I'm adjusting the title too.

    ErrorException: Declaration of LandUseType::newPivot() should be compatible with Illuminate\Database\Eloquent\Model::newPivot(Illuminate\Database\Eloquent\Model $parent, array $attributes, $table, $exists)
    
    class LandUseType extends \Eloquent {
    
      protected $table = "land_use_types";
    
      protected $guarded = [
        "id"
      ];
    
      protected $fillable = [
        "unit_name",
        "ite_trip_gen",
        "sf_per_unit",
        "sp_per_unit",
        "site_acreage_multiplier",
        "gallons_per_unit_per_year",
        "tons_per_unit_per_year",
        "icon",
        "short_description",
        "long_description"
      ];
    
      public function sites()
      {
        return $this->belongsToMany("Site", "site_land_use_types");
      }
    
      public function newPivot(Eloquent $parent, array $attributes, $table, $exists) {
    
        if($parent instanceof Site){
    
          return new SiteLandUseType($parent, $attributes, $table, $exists);
    
        }
    
        return parent::newPivot($parent, $attributes, $table, $exists);
    
      }
    
    }
    

    Any thoughts on this?

    I have added the service provider, adjusted my aliases, and ran a dump-autoload

    opened by bryantAXS 6
  • Problem if receiving camelCase input

    Problem if receiving camelCase input

    for example:

    {firstName: "Example", email: "[email protected]", password: "asdasd"}
    

    On saving to database , the firstName value is not saved. I see you have setAttribute function but seems to not working convert it to snake case.

    opened by stefensuhat 5
  • Eloquence does not work correctly when using Laravel Attributes

    Eloquence does not work correctly when using Laravel Attributes

    Here is my use case: In database I have a keep_updated column. In my model I have following attribute:

        protected function keepUpdated(): Attribute
        {
            return Attribute::make(
                get: fn($value) => json_decode($value) ?? [],
                set: fn($value) => json_encode($value),
            );
        }
    

    If my database contains two rows with values null and ["test"], then this gives me following output:

            $deployment = ProjectDeployment::find(121);
            dump($deployment->keepUpdated);
            dump($deployment->keep_updated);
    
            $deployment = ProjectDeployment::find(122);
            dump($deployment->keepUpdated);
            dump($deployment->keep_updated);
    
    null // app/Http/Controllers/TestController.php:13
    
    [] // app/Http/Controllers/TestController.php:14
    
    null // app/Http/Controllers/TestController.php:17
    
    array:1 [▼ // app/Http/Controllers/TestController.php:18
      0 => "test"
    ]
    

    After switching to using a Cast class I get following (correct) result:

    class AsArray implements CastsAttributes
    {
        public function get($model, string $key, $value, array $attributes)
        {
            return json_decode($value) ?? [];
        }
    
        public function set($model, string $key, $value, array $attributes)
        {
            return json_encode($value);
        }
    }
    
    [] // app/Http/Controllers/TestController.php:13
    
    [] // app/Http/Controllers/TestController.php:14
    
    array:1 [▼ // app/Http/Controllers/TestController.php:17
      0 => "test"
    ]
    
    array:1 [▼ // app/Http/Controllers/TestController.php:18
      0 => "test"
    ]
    
    

    It seems that Eloquence does not work correctly with Laravel Attributes possibly because of the if (method_exists($this, $key)) { line that will detect the attribute as relationship and use wrong method.

    opened by hubertnnn 0
  • `firstOrNew` appears to be broken when using CamelCasing.

    `firstOrNew` appears to be broken when using CamelCasing.

    (new AutomationStep)->firstOrNew($attributes);
    

    fails when using softDeletes:

    [previous exception] [object] (PDOException(code: 42703): SQLSTATE[42703]: Undefined column: 7 ERROR:  column \"deletedAt\" does not exist
    LINE 1: ...ct * from \"automation_steps\" where (\"id\" = $1 and \"deletedAt...
                                                                 ^
    HINT:  Perhaps you meant to reference the column \"automation_steps.deleted_at\". at /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php:401)
    [stacktrace]
    #0 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php(401): PDOStatement->execute()
    #1 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php(735): Illuminate\\Database\\Connection->Illuminate\\Database\\{closure}()
    #2 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php(702): Illuminate\\Database\\Connection->runQueryCallback()
    #3 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php(404): Illuminate\\Database\\Connection->run()
    #4 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2630): Illuminate\\Database\\Connection->select()
    #5 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2618): Illuminate\\Database\\Query\\Builder->runSelect()
    #6 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(3154): Illuminate\\Database\\Query\\Builder->Illuminate\\Database\\Query\\{closure}()
    #7 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2619): Illuminate\\Database\\Query\\Builder->onceWithColumns()
    #8 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(698): Illuminate\\Database\\Query\\Builder->get()
    #9 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(682): Illuminate\\Database\\Eloquent\\Builder->getModels()
    #10 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(296): Illuminate\\Database\\Eloquent\\Builder->get()
    #11 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(533): Illuminate\\Database\\Eloquent\\Builder->first()
    #12 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(23): Illuminate\\Database\\Eloquent\\Builder->firstOrNew()
    #13 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2163): Illuminate\\Database\\Eloquent\\Model->forwardCallTo()
    #14 /home/forge/mike-b.totalitylms.com/app/Http/Livewire/Automation.php(81): Illuminate\\Database\\Eloquent\\Model->__call()
    #15 [internal function]: App\\Http\\Livewire\\Automation->App\\Http\\Livewire\\{closure}()
    #16 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(558): array_map()
    #17 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(723): Illuminate\\Support\\Arr::map()
    #18 /home/forge/mike-b.totalitylms.com/app/Http/Livewire/Automation.php(87): Illuminate\\Support\\Collection->map()
    #19 /home/forge/mike-b.totalitylms.com/vendor/livewire/livewire/src/HydrationMiddleware/CallPropertyHydrationHooks.php(20): App\\Http\\Livewire\\Automation->hydrateSteps()
    #20 /home/forge/mike-b.totalitylms.com/vendor/livewire/livewire/src/LifecycleManager.php(89): Livewire\\HydrationMiddleware\\CallPropertyHydrationHooks::hydrate()
    #21 /home/forge/mike-b.totalitylms.com/vendor/livewire/livewire/src/Connection/ConnectionHandler.php(13): Livewire\\LifecycleManager->hydrate()
    #22 /home/forge/mike-b.totalitylms.com/vendor/livewire/livewire/src/Controllers/HttpConnectionHandler.php(20): Livewire\\Connection\\ConnectionHandler->handle()
    #23 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(48): Livewire\\Controllers\\HttpConnectionHandler->__invoke()
    #24 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Routing/Route.php(261): Illuminate\\Routing\\ControllerDispatcher->dispatch()
    #25 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Routing/Route.php(204): Illuminate\\Routing\\Route->runController()
    #26 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(725): Illuminate\\Routing\\Route->run()
    #27 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
    #28 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #29 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
    #30 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #31 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
    #32 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #33 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
    #34 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #35 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
    #36 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Session\\Middleware\\StartSession->handle()
    #37 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #38 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
    #39 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #40 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
    #41 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #42 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(726): Illuminate\\Pipeline\\Pipeline->then()
    #43 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(703): Illuminate\\Routing\\Router->runRouteWithinStack()
    #44 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(667): Illuminate\\Routing\\Router->runRoute()
    #45 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Routing/Router.php(656): Illuminate\\Routing\\Router->dispatchToRoute()
    #46 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\\Routing\\Router->dispatch()
    #47 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
    #48 /home/forge/mike-b.totalitylms.com/vendor/livewire/livewire/src/DisableBrowserCache.php(19): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #49 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Livewire\\DisableBrowserCache->handle()
    #50 /home/forge/mike-b.totalitylms.com/vendor/genealabs/laravel-governor/src/Http/Middleware/ParseCustomPolicyActions.php(23): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #51 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): GeneaLabs\\LaravelGovernor\\Http\\Middleware\\ParseCustomPolicyActions->handle()
    #52 /home/forge/mike-b.totalitylms.com/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(60): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #53 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle()
    #54 /home/forge/mike-b.totalitylms.com/vendor/genealabs/laravel-casts/src/Http/Middleware/AssetInjection.php(10): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #55 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): GeneaLabs\\LaravelCasts\\Http\\Middleware\\AssetInjection->handle()
    #56 /home/forge/mike-b.totalitylms.com/vendor/mikefrancis/laravel-secureheaders/src/ApplySecureHeaders.php(48): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #57 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): MikeFrancis\\LaravelSecureHeaders\\ApplySecureHeaders->handle()
    #58 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #59 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
    #60 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(36): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #61 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
    #62 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #63 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
    #64 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #65 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
    #66 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #67 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\HandleCors->handle()
    #68 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #69 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\TrustProxies->handle()
    #70 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
    #71 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\\Pipeline\\Pipeline->then()
    #72 /home/forge/mike-b.totalitylms.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
    #73 /home/forge/mike-b.totalitylms.com/public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle()
    
    opened by mikebronner 2
  • Backwards-compatibility for camel-casing is broken when using Livewire's nested model binding in JSON fields.

    Backwards-compatibility for camel-casing is broken when using Livewire's nested model binding in JSON fields.

    When trying to access data in json attributes in models, Livewire is unable to access the snake-case format, which makes it problematic if you are in a transition period between moving from snake_case to camelCase.

    I haven't dug into this yet to see how Livewire accesses model properties, but I'll try and give it a go and submit a PR if I can.

    opened by mikebronner 6
  • Laravel Octane

    Laravel Octane

    Is this package compatibile with Laravel Octane?

    Configuration Repository Injection https://laravel.com/docs/master/octane#configuration-repository-injection

    Managing Memory Leaks https://laravel.com/docs/master/octane#managing-memory-leaks

    opened by gajosadrian 0
  • can't install the package

    can't install the package

    The Error I am getting is here

    `./composer.json has been updated Running composer update kirkbushell/eloquence Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages.

    Problem 1 - Root composer.json requires kirkbushell/eloquence 4.0 -> satisfiable by kirkbushell/eloquence[4.0.0]. Updating dependencies Your requirements could not be resolved to an installable set of packages.

    Problem 1 - Root composer.json requires kirkbushell/eloquence 4.0.0 -> satisfiable by kirkbushell/eloquence[4.0.0]. - kirkbushell/eloquence 4.0.0 requires illuminate/database ~7.0 -> found illuminate/database[v7.0.0, ..., 7.x-dev] but these were not loaded, likely because it conflicts with another require.

    Installation failed, reverting ./composer.json and ./composer.lock to their original content. `

    to reproduce the error simply install the package using the command composer require kirkbushell/eloquence:~4.0 on a fresh laravel 8 project

    opened by rushi7997 1
Owner
Kirk Bushell
Kirk Bushell
Extra RedBean ORM

RedBeanPHP 5 RedBeanPHP is an easy to use ORM tool for PHP. Automatically creates tables and columns as you go No configuration, just fire and forget

GingTeam Development 5 Nov 23, 2022
Install extra packages for advanced users.

unRAID-NerdTools Install and Uninstall extra packages easily. NerdTools is the new plugin that allows you to install additional packages in UnRAID eas

UnRAID_ES 13 Dec 31, 2022
A drop-in Doctrine ORM 2 implementation for Laravel 5+ and Lumen

Laravel Doctrine ORM A drop-in Doctrine ORM 2 implementation for Laravel 5+ $scientist = new Scientist( 'Albert', 'Einstein' ); $scientist->a

Laravel Doctrine 777 Dec 17, 2022
The query filter bundle allows you to filter data from QueryBuilder and the Database

The query filter bundle allows you to filter data from QueryBuilder and the Database. you can filter multiple columns at the same time and also you can filter relation fields with two-level deep and without any join in your query builder.

Milad Ghofrani 0 Apr 8, 2022
The query sorting bundle allows you to sort data from QueryBuilder and the Database

The query sorting bundle allows you to sort data from QueryBuilder and the Database. you can sort multiple columns at the same time and also you can sort relation fields with two-level deep and without any join in your query builder.

Bugloos 12 Oct 6, 2022
Pure PHP NoSQL database with no dependency. Flat file, JSON based document database.

Please give it a Star if you like the project ?? ❤️ SleekDB - A NoSQL Database made using PHP Full documentation: https://sleekdb.github.io/ SleekDB i

Kazi Mehedi Hasan 745 Jan 7, 2023
SleekwareDB is a NoSQL database storage service. A database storage service that can be used for various platforms and is easy to integrate.

SleekwareDB is a NoSQL database storage service. A database storage service that can be used for various platforms and is easy to integrate. NoSQL API

SleekwareDB 12 Dec 11, 2022
Food delivery app :fries: that allows users to order food from different restaurants. The project is built using a microservice architecture. :boom:

Food Delivery App Description ?? This is a food delivery app ?? that allows users to order food from different restaurants. The project is built using

Younes Lamkhanter 7 Dec 12, 2022
Tiny php mysql lib (PDO-based) with handy fetch/update functionality, supports both SQL and parametric queries

Micro PHP mysql lib (~ 200 lines of code) with ultra powerful CRUD for faster than ever development: parametric fetch/insert/update/delete (based on a

Mr Crypster 18 Dec 10, 2022
Connect and work with MySQL/MariaDB database through MySQLi in PHP. This is an introductory project, If you need a simple and straightforward example that takes you straight to the point, you can check out these examples.

First MySQLi PHP Connect and work with MySQL/MariaDB database through MySQLi in PHP. The above exercises are designed for students. This is an introdu

Max Base 4 Feb 22, 2022
Support for many missing PostgreSQL specific features

Laravel supports many different databases and therefore has to limit itself to the lowest common denominator of all databases. PostgreSQL, however, of

Tobias Petry 359 Jan 3, 2023
A simple library to access and manipulate database records. Built on top of Dibi and hardwired for PostgreSQL.

grifart/tables A simple library to access and manipulate database records. Built on top of Dibi and hardwired for PostgreSQL. This library is develope

GRIFART 5 Nov 11, 2022
Just another PDO database library

PDO Just another PDO database library Installation Use Composer $ composer require faapz/pdo Usage Examples selecting, inserting, updating and deletin

Fabian de Laender 313 Oct 11, 2022
A simple library for managing database connections, results pagination and building queries in PHP

PHP lions-software-database-manager This is a simple library for managing database connections, results pagination and building queries in PHP. Esta é

Lions Software 0 Feb 7, 2022
The Enobrev\ORM library is a small framework of classes meant to be used for simply mapping a mysql database to PHP classes, and for creating simply SQL statements using those classes.

The Enobrev\ORM library is a small framework of classes meant to be used for simply mapping a mysql database to PHP classes, and for creating simply SQL statements using those classes.

Mark Armendariz 0 Jan 7, 2022
This project is about import CSV to Laravel with Laravel Excel library.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Abraham Víctor Zaragoza Rodríguez 1 Nov 20, 2021
Driver to seamlessly integrate the Backup Manager into Laravel applications.

Laravel Driver for the Database Backup Manager This package pulls in the framework agnostic Backup Manager and provides seamless integration with Lara

Backup Manager 636 Dec 30, 2022
Laravel Thermite is an extended PostgreSQL Laravel database driver to connect to a CockroachDB cluster.

Laravel Thermite Laravel Thermite is an extended PostgreSQL Laravel database driver to connect to a CockroachDB cluster. ?? Supporting If you are usin

Renoki Co. 9 Nov 15, 2022
[READ ONLY] Subtree split of the Illuminate Database component (see laravel/framework)

Illuminate Database The Illuminate Database component is a full database toolkit for PHP, providing an expressive query builder, ActiveRecord style OR

The Laravel Components 2.5k Dec 27, 2022