sydante/laravel-eloquent-with-not-overwritten

Add a method to Eloquent that does not overwrite the established relationship when relating 'with'.

v1.0.0 2021-10-21 07:35 UTC

This package is auto-updated.

Last update: 2024-12-20 11:07:28 UTC


README

Add a method to eloquent that does not overwrite the established relationship when relating with..

Installing

$ composer require sydante/laravel-eloquent-with-not-overwritten -vvv

Usage

$eloquentModel
    ->with(
        'progresses',
        function (HasMany $builder) {
            $builder->select(['id', 'eloquent_model_id', 'workflow_id', 'status', 'admin_id'])
                ->orderBy('id');
        }
    )
    // Do not overwrite defined eager loaded relations
    ->withNotOverwritten('progresses.admin:id,name')
    ->withNotOverwritten('progresses.workflow:id,name')
    ->withNotOverwritten('progresses.workflow.adminRole:id,name,slug');

Purpose

See laravel/framework#39210

Contributing

You can contribute in one of three ways:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. Contribute new features or update the wiki.

The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.

License

MIT