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

canBe() does not consider wildcards. Is that intentional? #42

Open
mabdelfattah opened this issue Aug 31, 2023 · 0 comments
Open

canBe() does not consider wildcards. Is that intentional? #42

mabdelfattah opened this issue Aug 31, 2023 · 0 comments

Comments

@mabdelfattah
Copy link

<?php

namespace App\StateMachines;

use Asantibanez\LaravelEloquentStateMachines\StateMachines\StateMachine;

class OrderStateMachine extends StateMachine
{
    public function recordHistory(): bool
    {
        return false;
    }

    public function transitions(): array
    {
        return [
            '*' => ['enqueued', 'processing'],
            'failed' => ['processing'],
            'processing' => ['ready', 'failed'],
        ];
    }

    public function defaultState(): string
    {
        return 'not_started';
    }
}
$model->orderState()->state(); // 'not_started'
$model->orderState()->canBe('processing'); // false
$model->orderState()->transitionTo('processing'); // true

Is that intentional/by design? if not, please let me know to do a pull request that makes canBe() respects the wilecards too.

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

No branches or pull requests

1 participant