Skip to content

v0.2.5

Compare
Choose a tag to compare
@lorisleiva lorisleiva released this 02 Jan 19:12

Add support for dependency injection to the following methods: rules(), messages() and attributes().

This means you can now resolve your Eloquent models or Service classes before even reaching the handle() method.

This could be helpful, for example, when excluding a model in a unique rule.

class UpdateTeamProfile extends Action
{
    public function rules(Team $team)
    {
        return [
            'name' => ['filled', 'max:255'],
            'slug' => [
                'filled',
                'alpha_dash',
                Rule::exists('teams')->ignore($team->id),
            ],
        ];
    }
    
    public function handle(Team $team)
    {
        $team->update($this->validated());

        return $team;
    }
}