PHP code example of datpmwork / laravel-auth-queue
1. Go to this page and download the library: Download datpmwork/laravel-auth-queue library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
datpmwork / laravel-auth-queue example snippets
class SampleJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, WasAuthenticated;
public function handle()
{
# auth()->user() was the authenticated user who dispatched this job
logger()->info('Auth ID: '. auth()->id());
}
}
class SampleNotification extends Notification implements ShouldQueue
{
use Queueable, WasAuthenticated;
public function via(): array
{
return ['database'];
}
public function toDatabase(): array
{
# auth()->user() was the authenticated user who triggered this notification
return [auth()->id()];
}
}
class SampleSubscriber implements ShouldQueue
{
use Queueable, WasAuthenticated;
public function subscribe(Dispatcher $dispatcher)
{
$dispatcher->listen('eloquent.updated: ' . User::class, [self::class, 'onUserUpdated']);
}
public function onUserUpdated(User $user)
{
# auth()->user() was the authenticated user who triggered this event
logger()->info('Auth ID: '. auth()->id());
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.