Skip to content

Commit ea7e587

Browse files
committed
final touches
1 parent 964dc60 commit ea7e587

File tree

5 files changed

+59
-11
lines changed

5 files changed

+59
-11
lines changed

README.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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.

config/workflow.php

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,45 @@
11
<?php
22

3-
use App\Request;
43

54
return [
65
'workflows' => [
76

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
1211
'pending',
1312
'escalated',
1413
'approved',
1514
'rejected',
1615
],
16+
1717
'transitions' => [
1818
'Approve' => [
1919
'from' => ['pending', 'escalated'],
2020
'to' => 'approved',
21-
'event' => \App\Events\RequestApproved::class,
21+
'event' => \App\Events\RequestApproved::class, // fire event
2222
],
2323
'Escalate' => [
2424
'from' => ['pending'],
2525
'to' => 'escalated',
26-
'with_reasons' => 'escalation_note', // the column name
2726
],
2827
'Reject' => [
2928
'from' => ['pending', 'escalated'],
3029
'to' => 'rejected',
3130
'with_reasons' => [ // to create a dropdown
3231
'model' => \App\RejectionReason::class,
3332
'columns' => [
34-
'id' => 'id',
35-
'label' => 'title',
33+
'id' => 'id', // value of the option
34+
'label' => 'title', // option label
3635
],
3736
],
3837
],
3938

40-
4139
'Back to My Employee' => [
4240
'from' => ['escalated'],
4341
'to' => 'pending',
42+
'with_reasons' => 'escalation_note', // display a free textarea to write the comment on the this column name
4443
],
4544
],
4645
],

details.png

234 KB
Loading

diagram.png

113 KB
Loading

src/ToolServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function boot()
2828

2929
$this->publishes([
3030
__DIR__.'/../config/workflow.php' => config_path('workflow.php'),
31-
], 'nova-config');
31+
], 'workflow');
3232
}
3333

3434
/**

0 commit comments

Comments
 (0)