在Laravel 5.7中更改(电子邮件)按钮颜色

Arn*_*rdt 2 css php html-email laravel laravel-5.7

在Laravel 5.7中更改成功,错误和原色的最佳方法是什么?

我有email.blade.php通过 php artisan vendor:publish --tag=laravel-notifications

...
{{-- Action Button --}}
@isset($actionText)
<?php
    switch ($level) {
        case 'success':
        case 'error':
            $color = $level;
            break;
        default:
            $color = 'primary';
    }
?>
@component('mail::button', ['url' => $actionUrl, 'color' => $color])
...
Run Code Online (Sandbox Code Playgroud)

模板使用'success''error''primary'为按钮上色,但是在哪里可以更改它们的值?

Jqu*_*ons 8

这是最好和正确的方法

https://laracasts.com/series/whats-new-in-laravel-5-4/episodes/7

(我将提取)-运行

php artisan vendor:publish --tag=laravel-mail, this will create vendors/html folder in your views directory.

然后在以下位置创建一个新的主题文件

/resources/views/vendor/mail/html/themes/my_theme.css

然后在

config/mail.php

设定新主题

        'theme' => 'my_theme',

        'paths' => [
            resource_path('views/vendor/mail'),
        ],
    ],
Run Code Online (Sandbox Code Playgroud)

现在,您可以设置自己的CSS并创建任何新的按钮颜色。

@component('mail::button', ['url' => $url, 'color' => 'success'])
View Group
@endcomponent
Run Code Online (Sandbox Code Playgroud)


Egr*_*tos 0

也许,最好的方法是创建 ColorHelper 类?

class ColorHelper {

    public static function level($level) {
        if(method_exists ( $this , $level )) {
            call_user_func($level);
        } else {
            return false;
        }
    }

    public static function success() {
        return '#00FF00';
    }

    public static function error() {
        return '#FF0000';
    }

}
Run Code Online (Sandbox Code Playgroud)