File tree 5 files changed +59
-11
lines changed
5 files changed +59
-11
lines changed Original file line number Diff line number Diff line change
1
+ # Workflow Resource Tool for Laravel Nova
2
+
3
+ This package helps you to create workflow on your Nova application
4
+
5
+ ![ screenshot] ( ./diagram.png )
6
+
7
+ ![ screenshot] ( ./details.png )
8
+
9
+
10
+ ## Installation
11
+
12
+ You can install the package in to a Laravel app that uses [ Nova] ( https://nova.laravel.com ) via composer:
13
+
14
+ ``` bash
15
+ composer require cammac/nova-workflow
16
+ ```
17
+
18
+ Next, publish the config file
19
+
20
+ ``` bash
21
+ php artisan vendor:publish --tag workflow
22
+ ```
23
+
24
+ open ` config/workflow.php ` and define your workflow
25
+
26
+ ## Usage
27
+
28
+ To display the workflow that are associated with a given Nova resource, you need to add the workflow Resource Tool to your resource.
29
+
30
+ For example, in your ` app/Nova/Order.php ` file:
31
+
32
+ ``` php
33
+ public function fields(Request $request)
34
+ {
35
+ return [
36
+ ID::make()->sortable(),
37
+
38
+ // Your other fields
39
+
40
+ Workflow::make('request')->onlyOnDetail() // request is the workflow name defined in workflow configuration file
41
+
42
+ ];
43
+ }
44
+ ```
45
+
46
+ This will automatically search possible transitions for the current status
47
+
48
+ ## License
49
+ The MIT License (MIT). Please see [ License File] ( LICENSE.md ) for more information.
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- use App \Request ;
4
3
5
4
return [
6
5
'workflows ' => [
7
6
8
- 'request ' => [
9
- 'model ' => Request::class,
10
- 'column ' => 'status ' ,
11
- 'states ' => [
7
+ 'request ' => [ // workflow name
8
+ 'model ' => \ App \ Request::class, //workflow applied to this model
9
+ 'column ' => 'status ' , // on this column
10
+ 'states ' => [ // the possible statuses
12
11
'pending ' ,
13
12
'escalated ' ,
14
13
'approved ' ,
15
14
'rejected ' ,
16
15
],
16
+
17
17
'transitions ' => [
18
18
'Approve ' => [
19
19
'from ' => ['pending ' , 'escalated ' ],
20
20
'to ' => 'approved ' ,
21
- 'event ' => \App \Events \RequestApproved::class,
21
+ 'event ' => \App \Events \RequestApproved::class, // fire event
22
22
],
23
23
'Escalate ' => [
24
24
'from ' => ['pending ' ],
25
25
'to ' => 'escalated ' ,
26
- 'with_reasons ' => 'escalation_note ' , // the column name
27
26
],
28
27
'Reject ' => [
29
28
'from ' => ['pending ' , 'escalated ' ],
30
29
'to ' => 'rejected ' ,
31
30
'with_reasons ' => [ // to create a dropdown
32
31
'model ' => \App \RejectionReason::class,
33
32
'columns ' => [
34
- 'id ' => 'id ' ,
35
- 'label ' => 'title ' ,
33
+ 'id ' => 'id ' , // value of the option
34
+ 'label ' => 'title ' , // option label
36
35
],
37
36
],
38
37
],
39
38
40
-
41
39
'Back to My Employee ' => [
42
40
'from ' => ['escalated ' ],
43
41
'to ' => 'pending ' ,
42
+ 'with_reasons ' => 'escalation_note ' , // display a free textarea to write the comment on the this column name
44
43
],
45
44
],
46
45
],
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ public function boot()
28
28
29
29
$ this ->publishes ([
30
30
__DIR__ .'/../config/workflow.php ' => config_path ('workflow.php ' ),
31
- ], 'nova-config ' );
31
+ ], 'workflow ' );
32
32
}
33
33
34
34
/**
You can’t perform that action at this time.
0 commit comments