我试图检索数据,如视图、和标记的名称(不呈现视图)--例如:app/Mail目录中的每个可邮件类的emails.user.welcome。
Var转储UserWelcome邮件类:
Route::get('rendermail', function() {
$email = ( new App\Mail\UserWelcome() );
return dd($email);
});无功转储输出
UserWelcome {#441 ▼
+locale: null
+from: []
+to: []
+cc: []
+bcc: []
+replyTo: []
+subject: null
#markdown: null
#html: null
+view: null
+textView: null
+viewData: []
+attachments: []
+rawAttachments: []
+callbacks: []
+connection: null
+queue: null
+chainConnection: null
+chainQueue: null
+delay: null
+chained: []发布于 2018-11-26 19:12:37
路由/web.php
$return = [];
$files = scandir("./Mail");
foreach ($files as $key => $value) {
$fullFileName = explode(".", $value);
if ($fullFileName[1] === "php") {
$fileName = $fullFileName[0];
$className = "App\Mail\". $fileName ."()";
array_push($return, (new $className)->returnArray());
}
}
return $return;在所有returnArray中添加一个MailableClasses方法
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
class testMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
$this->form = "Test";
$this->view = "home";
$this->subject = "home";
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this;
}
/**
* Build the message.
*
* @return $this
*/
public function returnArray()
{
return [$this->view];
}
}https://stackoverflow.com/questions/53487456
复制相似问题