Initial commit

This commit is contained in:
Ronald Huynen
2026-03-23 21:37:59 +01:00
commit 2547717edb
2193 changed files with 972171 additions and 0 deletions

View File

@@ -0,0 +1,89 @@
<?php
namespace App\Notifications\Auth;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class CredentialsGenerated extends Notification // implements ShouldQueue // Implement ShouldQueue if desired
{
// use Queueable;
/**
* The plain-text password.
*
* @var string
*/
public string $plainPassword;
/**
* Create a new notification instance.
*
* @param string $plainPassword
* @return void
*/
public function __construct(string $plainPassword)
{
$this->plainPassword = $plainPassword;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable The profile model (User, Org, etc.)
* @return array
*/
public function via($notifiable)
{
return ['mail']; // Send via email
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable The profile model
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
// TODO: make better email. Note that $notifiable is the new created user/org/bank/admin model.
// only model properties from db are available here!
// --- Derive the profile type directly from the model class ---
try {
$reflection = new \ReflectionClass($notifiable);
$profileType = $reflection->getShortName(); // Gets 'User', 'Bank', etc.
} catch (\ReflectionException $e) {
// Fallback in case reflection fails
$profileType = __('Profile');
\Illuminate\Support\Facades\Log::error('Reflection failed in CredentialsGenerated notification: ' . $e->getMessage());
}
$profileName = $notifiable->full_name ?? $notifiable->name;
$loginUrl = route('login');
return (new MailMessage())
->subject(__('Your :profileType profile credentials', ['profileType' => $profileType]))
->greeting(__('Hello :name,', ['name' => $profileName]))
->line(__('A :profileType profile has been created for you by our administrator.', ['profileType' => $profileType]))
->line(__('Your temporary password is: :password', ['password' => $this->plainPassword]))
->line(__('Please keep this password secure.'))
->action(__('Login Now'), $loginUrl)
->line(__('We highly recommend changing your password after logging in for the first time.'));
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
// Data for database or other channels if needed
];
}
}

View File

@@ -0,0 +1,145 @@
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Lang;
class NonUserPasswordResetNotification extends Notification implements ShouldQueue
{
use Queueable;
/**
* The password reset URL.
*
* @var string
*/
public $resetUrl;
/**
* The name of the profile.
*
* @var string
*/
public $profileName;
/**
* The type of the profile (e.g., 'admin', 'bank').
*
* @var string
*/
public $profileType;
/**
* The locale for the notification.
*
* @var string
*/
public $locale;
/**
* Create a new notification instance.
*
* @param string $resetUrl
* @param object $notifiable The profile model (Admin, Bank, etc.)
* @return void
*/
public function __construct(string $resetUrl, $notifiable)
{
$this->resetUrl = $resetUrl;
// Assuming the notifiable (Admin, Bank model) has a 'name' or 'full_name' attribute
$this->profileName = $notifiable->name ?? $notifiable->full_name ?? 'your account';
// Determine profile type for more specific messaging if needed
if ($notifiable instanceof \App\Models\Admin) {
$this->profileType = 'Admin';
} elseif ($notifiable instanceof \App\Models\Bank) {
$this->profileType = 'Bank';
} elseif ($notifiable instanceof \App\Models\Organization) {
$this->profileType = 'Organization';
} else {
$this->profileType = 'Profile';
}
// Support lang_preference for Organization, Bank, and Admin models
$this->locale = $notifiable->lang_preference ?? config('app.fallback_locale');
// Ensure locale is not empty
if (empty($this->locale)) {
$this->locale = config('app.fallback_locale');
}
$this->onQueue('high');
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
// Set application locale for this email
app()->setLocale($this->locale);
$subject = trans('Reset Password Notification', [], $this->locale);
$expireMinutes = config('auth.passwords.' . $this->getBroker($notifiable) . '.expire');
return (new MailMessage())
->from(timebank_config('mail.support.email'), timebank_config('mail.support.name'))
->subject($subject)
->view('emails.auth.reset-password', [
'notifiable' => $notifiable,
'resetUrl' => $this->resetUrl,
'subject' => $subject,
'expireMinutes' => $expireMinutes,
'locale' => $this->locale,
]);
}
/**
* Get the broker for the notifiable.
*/
protected function getBroker($notifiable)
{
if ($notifiable instanceof \App\Models\Admin) {
return 'admins';
}
if ($notifiable instanceof \App\Models\Bank) {
return 'banks';
}
if ($notifiable instanceof \App\Models\Organization) {
return 'organizations';
}
return 'users'; // Default
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}

View File

@@ -0,0 +1,103 @@
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Lang;
class UserPasswordResetNotification extends Notification implements ShouldQueue
{
use Queueable;
/**
* The password reset token.
*
* @var string
*/
public $token;
/**
* The locale for the notification.
*
* @var string
*/
public $locale;
/**
* Create a new notification instance.
*
* @param string $token
* @param string|null $locale
* @return void
*/
public function __construct(string $token, string $locale = null)
{
$this->token = $token;
$this->locale = $locale ?? config('app.fallback_locale');
// Ensure locale is not empty
if (empty($this->locale)) {
$this->locale = config('app.fallback_locale');
}
$this->onQueue('high');
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
// Set application locale for this email
app()->setLocale($this->locale);
$resetUrl = url(route('password.reset', [
'token' => $this->token,
'email' => $notifiable->getEmailForPasswordReset(),
], false));
$subject = trans('Reset Password Notification', [], $this->locale);
$expireMinutes = config('auth.passwords.users.expire');
return (new MailMessage())
->from(timebank_config('mail.support.email'), timebank_config('mail.support.name'))
->subject($subject)
->view('emails.auth.reset-password', [
'notifiable' => $notifiable,
'resetUrl' => $resetUrl,
'subject' => $subject,
'expireMinutes' => $expireMinutes,
'locale' => $this->locale,
]);
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Notifications;
use Illuminate\Auth\Notifications\VerifyEmail;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
class VerifyProfileEmail extends VerifyEmail
{
/**
* Get the name of the queue the notification should be sent on.
*
* @return string
*/
public function viaQueue()
{
return 'high';
}
protected function verificationUrl($notifiable)
{
$baseName = class_basename($notifiable); // e.g. "Organization"
$type = Str::lower($baseName);
// Use $notifiable->id for an organization, bank, admin ID
return URL::temporarySignedRoute(
'verification.verify',
Carbon::now()->addMinutes(60),
[
'type' => $type,
'id' => $notifiable->id,
'hash' => sha1($notifiable->getEmailForVerification()),
]
);
}
}