定制 lukasss93/laravel-extra-mailable 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lukasss93/laravel-extra-mailable

Composer 安装命令:

composer require lukasss93/laravel-extra-mailable

包简介

Extra tools for Laravel Mailables

README 文档

README

Laravel Extra Mailable

Version Downloads PHP Laravel License Build Coverage

Extra tools for Laravel Mailables

🚀 Installation

You can install the package using composer

composer require lukasss93/laravel-extra-mailable

👓 Usage

  1. Add the ExtraMailable Trait in your Mailable class:
<?php

namespace App\Mail;

use Illuminate\Mail\Mailable;
use Lukasss93\ExtraMailable\ExtraMailable;

class MyMail extends Mailable
{
    use ExtraMailable;

    protected int $value;

    public function __construct(int $value = 0)
    {
        $this->value = $value;
    }

    public function build() 
    {
        return $this->markdown('emails.myview', ['myvalue' => $this->value]);
    }
}
  1. How to use the trait:
<?php

use App\Mail\MyMail;

// send mail to recipient (string)
MyMail::create()->sendTo('foo@bar.org');

// send mail to recipients (string with semicolon separator)
MyMail::create()->sendTo('foo@bar.org;bar@foo.org');

// send mail to recipients (array)
MyMail::create()->sendTo(['foo@bar.org','bar@foo.org']);

// send mail to recipients (User)
MyMail::create()->sendTo(User::first());

// send mail to recipients (User collection)
MyMail::create()->sendTo(User::all());

// you can pass parameters in the create method
MyMail::create(69)->sendTo('foo@bar.org');

// send mail to recipients when condition is true
MyMail::create()->sendToWhen(true, 'foo@bar.org');

// execute custom code when there is no recipients
MyMail::create()
    ->onEmptyRecipients(fn() => print('No emails sent! No recipient found.'))
    ->sendTo([]);
    
// execute custom code before sending emails
MyMail::create()
    ->onBeforeSendingMails(fn() => print('This message will be printed before sending emails'))
    ->sendTo('foo@bar.org');

// execute custom code after sending emails
MyMail::create()
    ->onAfterSendingMails(fn() => print('This message will be printed after sending emails'))
    ->sendTo('foo@bar.org');

⚗️ Testing

composer test

📃 Changelog

Please see the CHANGELOG.md for more information on what has changed recently.

🏅 Credits

📖 License

Please see the LICENSE.md file for more information.

统计信息

  • 总下载量: 76
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固