mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
pleb alert!
This commit is contained in:
32
app/Events/PlebLoggedInEvent.php
Normal file
32
app/Events/PlebLoggedInEvent.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class PlebLoggedInEvent implements ShouldBroadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(public string $name)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the channels the event should broadcast on.
|
||||
* @return \Illuminate\Broadcasting\Channel|array
|
||||
*/
|
||||
public function broadcastOn()
|
||||
{
|
||||
return new Channel('login');
|
||||
}
|
||||
}
|
||||
24
app/Http/Livewire/LaravelEcho.php
Normal file
24
app/Http/Livewire/LaravelEcho.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use WireUi\Traits\Actions;
|
||||
|
||||
class LaravelEcho extends Component
|
||||
{
|
||||
use Actions;
|
||||
|
||||
protected $listeners = ['echo:login,.App\Events\PlebLoggedInEvent' => 'plebLoggedIn'];
|
||||
|
||||
public function plebLoggedIn($data)
|
||||
{
|
||||
$this->notification()
|
||||
->success(title: 'Pleb alert!', description: $data['name'].' logged in');
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.laravel-echo');
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Events\PlebLoggedInEvent;
|
||||
use App\Gamify\Points\LoggedIn;
|
||||
|
||||
class AddLoginReputation
|
||||
@@ -25,5 +26,6 @@ class AddLoginReputation
|
||||
public function handle($event)
|
||||
{
|
||||
$event->user->givePoint(new LoggedIn($event->user));
|
||||
event(new PlebLoggedInEvent($event->user->name));
|
||||
}
|
||||
}
|
||||
|
||||
38
app/Providers/HorizonServiceProvider.php
Normal file
38
app/Providers/HorizonServiceProvider.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Laravel\Horizon\Horizon;
|
||||
use Laravel\Horizon\HorizonApplicationServiceProvider;
|
||||
|
||||
class HorizonServiceProvider extends HorizonApplicationServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
// Horizon::routeSmsNotificationsTo('15556667777');
|
||||
// Horizon::routeMailNotificationsTo('example@example.com');
|
||||
// Horizon::routeSlackNotificationsTo('slack-webhook-url', '#channel');
|
||||
|
||||
// Horizon::night();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the Horizon gate.
|
||||
*
|
||||
* This gate determines who can access Horizon in non-local environments.
|
||||
*/
|
||||
protected function gate(): void
|
||||
{
|
||||
Gate::define('viewHorizon', function ($user) {
|
||||
return in_array($user->email, [
|
||||
//
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user