<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zaengle / laravel-security-notifications example snippets
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Zaengle\LaravelSecurityNotifications\Traits\Securable;
class User extends Authenticatable
{
use Securable, Notifiable;
}
public function getSecureFields(): array
{
return [
'first_name',
'last_name',
'email',
];
}
namespace App\Http\Controllers;
use Zaengle\LaravelSecurityNotifications\Facades\IPAddress;
class LoginController extends Controller
{
public function login(Request $request)
{
// Your existing login logic
IPAddress::process([
'ipAddress' => $request->ip(),
'userId' => auth()->id(),
'userType' => auth()->user()->getMorphClass(),
]);
// return
}
}
public function sendSecurityEmailsTo(): string
{
return $this->getOriginal('alternate_email') ?? $this->alternate_email;
}
use Zaengle\LaravelSecurityNotifications\Services\DigestIPAddress;
readonly class CustomIPAddressDriver implements DigestIPAddress
{
public function __construct(
private readonly string $ipAddress,
private readonly string $customField,
)
{
}
public function handle(): void
{
// Custom logic to handle IP address
}
}