Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor email template to use Blade syntax instead of raw PHP #54028

Closed
wants to merge 1 commit into from

Conversation

alisalehi1380
Copy link

No description provided.

Comment on lines +21 to +26
@php
$color = match ($level) {
'success', 'error' => $level,
default => 'primary',
};
?>
@endphp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also do

Suggested change
@php
$color = match ($level) {
'success', 'error' => $level,
default => 'primary',
};
?>
@endphp
@php($color = in_array($test, ['success', 'error']) ? $level : 'primary')

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is possible to refactor this code as you wrote it, but I think it was written this way for extensibility and customization by developers. (match is used)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, the logic shouldn't be in the template at all in the first place but in a method to be called in the template

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alisalehi1380 alisalehi1380 deleted the patch-1 branch December 30, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants