Skip to content

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