-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from digitalrisks/feature/AddsUserMetaData
- Loading branch information
Showing
8 changed files
with
163 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace DigitalRisks\LaravelEventStore; | ||
|
||
class EventStore | ||
{ | ||
/** | ||
* Variable for event to class. | ||
* | ||
* @var callable | ||
*/ | ||
public static $eventToClass; | ||
|
||
/** | ||
* Set the event class based on current event key. | ||
* | ||
* @param callable|null $callback | ||
* @return void | ||
*/ | ||
public static function eventToClass(?callable $callback = null) | ||
{ | ||
$callback = $callback ?: function ($event) { | ||
return 'App\Events\\' . $event->getType(); | ||
}; | ||
|
||
static::$eventToClass = $callback; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace DigitalRisks\LaravelEventStore\Traits; | ||
|
||
trait AddsUserMetaData | ||
{ | ||
/** | ||
* @metadata | ||
*/ | ||
public function collectUserMetaData() | ||
{ | ||
$user = request()->user(); | ||
|
||
if (!$user) { | ||
return []; | ||
} | ||
|
||
return [ | ||
'user' => $user->toArray() | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters