-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract common code from email notifications to HasTranslations trait
- Loading branch information
1 parent
3b57c09
commit 77734f4
Showing
4 changed files
with
68 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace App\Notifications\Traits; | ||
|
||
use Illuminate\Support\Facades\Lang; | ||
use Illuminate\Support\Str; | ||
|
||
/** | ||
* @property array $lang | ||
* @property array $placeholdersMap | ||
*/ | ||
trait HasTranslations | ||
{ | ||
protected array $placeholdersMap = []; | ||
|
||
/** | ||
* Get translated text and replace placeholders with actual content. | ||
*/ | ||
public function lang(string $key): string | ||
{ | ||
return Str::swap($this->placeholdersMap, $this->lang[Lang::getLocale()][$key]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters