Skip to content

Commit 0094fba

Browse files
committed
chore
1 parent 28a2512 commit 0094fba

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

readme.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Laravel Hooks
2-
3-
[![License](https://img.shields.io/github/license/claudye/laravel-hooks.svg)](https://github.com/claudye/laravel-hooks/blob/main/LICENSE)
2+
43

54
`Laravel Hooks` is a Laravel trait that allows you to register hooks (callbacks) before and after calling specified methods in a Laravel controllers. This helps you modify or extend the behavior of methods without altering their core logic.
65

@@ -65,15 +64,20 @@ class ExampleController extends Controller
6564
{
6665
// Register a before hook for the 'index' method
6766
$this->beforeCalling(['index', 'show'], function ($request,...$parameters, $method) {
67+
6868
$this->queryBuilder->filters($request->all());
69+
6970
logger('Before calling index method');
7071
});
7172

7273
// Register an after hook for the 'index' method
7374
$this->afterCalling(['index',"show","edit"], function ($request, $result,...$parameters, $method) {
75+
7476
// Modify the result after the 'index' method is called
7577
logger('After calling index method');
78+
7679
event(new SomeEvent($result))
80+
7781
return response()->json([
7882
'data'=>$result
7983
]);

0 commit comments

Comments
 (0)