Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d0432cb1b |
@@ -57,7 +57,7 @@ class SendExpirationAlerts extends Command
|
|||||||
|
|
||||||
if ($assets->count() > 0) {
|
if ($assets->count() > 0) {
|
||||||
|
|
||||||
Mail::to($recipients)->send(new ExpiringAssetsMail($assets, $alert_interval));
|
Mail::to($recipients)->locale($settings->use_locale)->send(new ExpiringAssetsMail($assets, $alert_interval));
|
||||||
|
|
||||||
$this->table(
|
$this->table(
|
||||||
[
|
[
|
||||||
@@ -91,7 +91,7 @@ class SendExpirationAlerts extends Command
|
|||||||
->orderBy('termination_date', 'ASC')
|
->orderBy('termination_date', 'ASC')
|
||||||
->get();
|
->get();
|
||||||
if ($licenses->count() > 0) {
|
if ($licenses->count() > 0) {
|
||||||
Mail::to($recipients)->send(new ExpiringLicenseMail($licenses, $alert_interval));
|
Mail::to($recipients)->locale($settings->use_locale)->send(new ExpiringLicenseMail($licenses, $alert_interval));
|
||||||
|
|
||||||
$this->table(
|
$this->table(
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class SendUpcomingAuditReport extends Command
|
|||||||
|
|
||||||
|
|
||||||
$this->info('Sending Admin SendUpcomingAuditNotification to: ' . $settings->alert_email);
|
$this->info('Sending Admin SendUpcomingAuditNotification to: ' . $settings->alert_email);
|
||||||
Mail::to($recipients)->send(new SendUpcomingAuditMail($assets, $settings->audit_warning_days));
|
Mail::to($recipients)->locale($settings->use_locale)->send(new SendUpcomingAuditMail($assets, $settings->audit_warning_days));
|
||||||
|
|
||||||
$this->table(
|
$this->table(
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
@@ -120,6 +121,36 @@ class Setting extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the locale to use in some places in the app where we don't
|
||||||
|
* have access to the user context (i.e. email notifications where the alert address
|
||||||
|
* might not be an actual user object or it's being run via cli.)
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Casts\Attribute
|
||||||
|
*/
|
||||||
|
protected function useLocale(): Attribute
|
||||||
|
{
|
||||||
|
|
||||||
|
return Attribute:: make(
|
||||||
|
get: function(mixed $value, array $attributes) {
|
||||||
|
|
||||||
|
// Use current user's language
|
||||||
|
if ((request()->user()) && (request()->user()->locale)) {
|
||||||
|
return request()->user()->locale;
|
||||||
|
|
||||||
|
// Fall back to app settings
|
||||||
|
} elseif ($attributes['locale'] != '') {
|
||||||
|
return $attributes['locale'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall back to env
|
||||||
|
return config('app.locale');
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current Laravel version.
|
* Get the current Laravel version.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user