pleb alert!

This commit is contained in:
Benjamin Takats
2023-01-18 23:01:27 +01:00
parent 7bd3efbabc
commit e92fa90962
26 changed files with 3461 additions and 2204 deletions

View 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');
}
}

View 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');
}
}

View File

@@ -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));
}
}

View 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, [
//
]);
});
}
}