Skip to content

Commit

Permalink
📚 Update Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
lorisleiva committed Aug 5, 2019
1 parent dbccd5d commit e89a9d6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,15 @@ Note that the `run` method also accepts additional attributes to be merged.
]);
```

Alternatively, you can run a action like a function call.

```php
(new PublishANewArticle)([
'title' => 'My blog post',
'body' => 'Lorem ipsum.',
]);
```

## Actions as jobs

### How are attributes filled?
Expand Down Expand Up @@ -451,17 +460,15 @@ Route::post('articles', 'PublishANewArticle');

### Registering middleware

You can register middleware using the `register` method.
You can register middleware using the `middleware` method.

```php
public function register()
public function middleware()
{
$this->middleware('auth');
return ['auth'];
}
```

Note that this is basically the equivalent of using the `__construct` method except that you don’t need to worry about the attributes being given as arguments and calling `parent::__construct`.

### Returning HTTP responses

It is good practice to let the action return a value that makes sense for your domain. For example, the article that was just created or the filtered list of topics that we are searching for.
Expand Down

0 comments on commit e89a9d6

Please sign in to comment.