You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
8
+
Using [Zerodahero's Laravel Workflow (based on Symfony Workflow)](https://github.com/zerodahero/laravel-workflow) to handle state-transition workflow is great. However, coding transition guard in event is hard. This package provides a simple way, you can add Symfony Expression Language as a transition guard for each transition. This configuration must provided in transiton metadata using 'guard' as a key.
9
+
This package subscribes for all workflows' transition guard events and uses provided Symfony Expression Language to allow to block the transition.
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
15
-
16
-
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
17
13
18
14
## Installation
19
15
@@ -23,13 +19,6 @@ You can install the package via composer:
Task that you have to do is providing guard configuration like the following example. This is in laravel-workflow 's configuration file (config/workflow.php). If you want to store workflow configuration in database, please visis [my Laravel Workflow Loader package](https://github.com/soap/laravel-workflow-loader).
53
37
54
38
```php
55
-
$laravelWorkflowProcess = new Prasit Gebsaap\LaravelWorkflowProcess();
'guard' => 'authenticated and subject.isOwnedBy(user)',
58
+
],
59
+
],
60
+
'approve' => [
61
+
'from' => 'pending_for_review',
62
+
'to' => 'approved',
63
+
],
64
+
'reject' => [
65
+
'from' => 'pending_for_review',
66
+
'to' => 'rejected',
67
+
],
68
+
'publish' => [
69
+
'from' => 'approved',
70
+
'to' => 'published',
71
+
],
72
+
'archive' => [
73
+
'from' => ['draft', 'rejected'],
74
+
'to' => 'archived',
75
+
],
76
+
],
77
+
]
78
+
79
+
];
57
80
```
81
+
Currenty these variables/objects were injected into Symfony Expression Language.
82
+
83
+
- "subject" is the Eloquent model which is subject of a workflow
84
+
- "user" is authenticated user.
85
+
- "authenticated" boolean, true if user was authenticated.
86
+
87
+
So you can call any method on the injected object.
88
+
89
+
## Todo
90
+
I have a plan to prover document role for user. For example, some users may be assign as "reviewer" or "approver" for Eloquent model. So we can use something like subject.hasActorRole('reviewer') or subject.canBeReviewedBy(user). Any suggestion is welcome.
0 commit comments