-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BaseEvent is now DefaultEvent and no longer extends ShouldBroadcast
BaseEvent is now deprecated
- Loading branch information
Showing
5 changed files
with
96 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace GemaDigital\Framework\app\Events; | ||
|
||
use GemaDigital\Framework\app\Events\DefaultEvent; | ||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
|
||
abstract class BroadcastEvent extends DefaultEvent implements ShouldBroadcast | ||
{ | ||
|
||
} |
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,11 @@ | ||
<?php | ||
|
||
namespace GemaDigital\Framework\app\Events; | ||
|
||
use GemaDigital\Framework\app\Events\DefaultEvent; | ||
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow; | ||
|
||
abstract class BroadcastNowEvent extends DefaultEvent implements ShouldBroadcastNow | ||
{ | ||
|
||
} |
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,66 @@ | ||
<?php | ||
|
||
namespace GemaDigital\Framework\app\Events; | ||
|
||
use Auth; | ||
use Carbon\Carbon; | ||
use GemaDigital\Framework\app\Events\SerializesEvents; | ||
use Illuminate\Broadcasting\Channel; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
abstract class DefaultEvent | ||
{ | ||
use Dispatchable; | ||
use InteractsWithSockets; | ||
use SerializesModels; | ||
use SerializesEvents; | ||
|
||
public $channel; | ||
public $user; | ||
public $timestamp; | ||
|
||
/** | ||
* Create a new event instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(string $channel) | ||
{ | ||
$this->channel = $channel; | ||
$this->user = $this->getUserData(); | ||
$this->timestamp = Carbon::now(); | ||
} | ||
|
||
public function broadcastAs() | ||
{ | ||
return (new \ReflectionClass($this))->getShortName(); | ||
} | ||
|
||
public function broadcastOn() | ||
{ | ||
return new Channel($this->channel); | ||
} | ||
|
||
public function getChannel() | ||
{ | ||
return $this->channel; | ||
} | ||
|
||
public function getUserData() | ||
{ | ||
$user = Auth::user(); | ||
|
||
return $user ? (object) $user->only(['id', 'name', 'email']) : null; | ||
} | ||
|
||
public function __toString() | ||
{ | ||
return json_encode([ | ||
get_class_name($this), | ||
$this->broadcastOn()->name, | ||
$this, | ||
]); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.