Skip to content

Commit e0727f5

Browse files
authored
Update README.md
1 parent f0d9d51 commit e0727f5

File tree

1 file changed

+50
-4
lines changed

1 file changed

+50
-4
lines changed

README.md

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
This package extends [zerodahero/laravel-workflow](https://github.com/zerodahero/laravel-workflow) by adding option to store workflow configuration in database. Laravel workflow only support loading configuration form Laravel configuration. This package provides user to change workflow configuration without helping from developers.
1010

1111
## Support us
12-
12+
You can suggest for any approvement, sponsor this project or make a pull request. I am happy to consider any recommendation. I am not a good programmer so my design may not be the best one. My background is not computer programming. I am an Electrical engineer.
1313

1414
## Installation
1515

@@ -36,17 +36,63 @@ This is the contents of the published config file:
3636

3737
```php
3838
return [
39+
'loaders' => [
40+
'database' => [
41+
'tableNames' => [
42+
'workflows' => 'workflows',
43+
'workflow_states' => 'workflow_states',
44+
'workflow_transitions' => 'workflow_transitions',
45+
'workflow_state_transitions' => 'workflow_state_transitions',
46+
],
47+
'class' => \Soap\WorkflowLoader\DatabaseLoader::class,
48+
],
49+
],
3950
];
4051
```
4152

53+
To use this package to load workflow configuration from database, you need to register workflow service provider provided by the package. Zerodahero 's workflow registry will be used to load configuration retreiving from database.
54+
```
55+
php artisan venodr:publish --tag="workflow-loader-provider"
56+
```
4257

43-
## Usage
44-
45-
To use this package to store workflow configuration you need to register workflow binding in your application service provider. You have to instruct Laravel to use new 'workflow' binding instead of the one provided by zerodahero/laravel-workflow.
58+
This will copy the following WorkflowServiceProvider.php to application providers folder, ensure that it was included in application bootstrap. The following is the content of the file.
4659

4760
```php
4861

62+
namespace App\Providers;
63+
64+
use Illuminate\Support\ServiceProvider;
65+
66+
class WorkflowServiceProvider extends ServiceProvider
67+
{
68+
public function register() {}
69+
70+
public function boot()
71+
{
72+
$registry = app()->make('workflow');
73+
$workflowLoaderRegistry = app()->make('workflowLoaderRegistry');
74+
foreach ($workflowLoaderRegistry->all() as $workflow => $config) {
75+
$registry->addFromArray($workflow, $config);
76+
}
77+
}
78+
}
79+
```
80+
This package doesnot provide user interface for user to manage workflow configuration. By design it should be in separate package. I have a plan to create filament plugin to handle this.
81+
82+
## Usage
83+
After you have completed setup, create workflow configuration in database using your own way or provided by other package. Then use them like the one you use by zerohadero/laravel-workflow. Storing configuration in database is easy to develop workflow for user.
84+
85+
## To Do
86+
Curently guards should be created via event subscriber. I have a plan to use Symfony expression as upper guard layer. For example, you can write;
87+
88+
```
89+
guard => $subject.isWaitingFor($user) || !$subject.isOwnedBy($user)
90+
```
91+
or
92+
```
93+
guard => $subject.isApprovers($user) || $subject.isReviewers($user)
4994
```
95+
Then the package will inject $subject and $user for you and use Symfony expression to evaluate blocking of the transition.
5096

5197
## Testing
5298

0 commit comments

Comments
 (0)