Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Add mergeFillable and mergeGuarded #32679

Merged
merged 2 commits into from
May 5, 2020
Merged

[7.x] Add mergeFillable and mergeGuarded #32679

merged 2 commits into from
May 5, 2020

Conversation

hailwood
Copy link
Contributor

@hailwood hailwood commented May 5, 2020

These new methods are to be inline with the mergeCasts method that was merged a few months ago.

They're mostly useful in traits that add new attributes for example

trait HasActiveVisit
{
    protected function initializeHasActiveVisit()
    {
        $this->mergeFillable([
            'is_indefinite',
            'finished_at'
        ]);

        $this->mergeCasts([
            'is_indefinite' => 'bool',
            'finished_at'   => 'datetime'
        ]);
    }

    public function scopeActive(Builder $query)
    {
        $query->where('is_indefinite', false)->whereNull('finished_at');
    }
}

hailwood added 2 commits May 5, 2020 12:30
These new methods are to be inline with the `mergeCasts` method that was merged a few months ago.

They're mostly useful in traits that add new attributes for example

```
trait HasActiveVisit
{
    protected function initializeHasActiveVisit()
    {
        $this->mergeFillable([
            'is_indefinite',
            'finished_at'
        ]);

        $this->mergeCasts([
            'is_indefinite' => 'bool',
            'finished_at'   => 'datetime'
        ]);
    }

    public function scopeActive(Builder $query)
    {
        $query->where('is_indefinite', false)->whereNull('finished_at');
    }
}
```
@taylorotwell taylorotwell merged commit 7701103 into laravel:7.x May 5, 2020
@hailwood hailwood deleted the patch-1 branch May 5, 2020 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants