Laravel与十月CMS

时间:2017-11-09 08:41:11

标签: laravel octobercms

我正在使用10月CMS和Laravel。 但我不知道如何插入数据进行查看。 这是我路线上的代码。

    Route::post('/sendmail', function (\Illuminate\Http\Request $request, \Illuminate\Mail\Mailer $mailer) {
//function(vendor\laravel\framework\src\Illuminate\Http\Request $request, vendor\laravel\framework\src\Illuminate\Mail\Mailer $mailer)
  $mailer
  ->to('test@test.com')//specify where to send
  ->send( new SendMail(
    $request->input('name'),
    $request->input('email'),
    $request->input('message')
  ));

  return redirect()->back();
})->name('sendmail');

这是我的SendMail.php

class SendMail extends Mailable
{
    use Queueable, SerializesModels;

    public $name;
    public $email;
    public $msg;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($name, $email, $msg )
    {
        $this->name = $name;
        $this->email = $email;
        $this->msg = $msg;

    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        //dump($this);
        //exit;
        return $this
        ->from('cebpac-autoloan@noreply-unionbank.com')
        // ->from('customer.service@unionbankph.com')
        ->view('email.send');
    }

但问题是由于此错误,我无法将数据插入视图

查看[email.send]未找到。

抛出新的InvalidArgumentException(“查看[$ name] not found。”);

这些文件位于我10月CMS的“插件”中

3 个答案:

答案 0 :(得分:0)

我猜你遇到的问题就像这里一样:

请看这个答案:https://stackoverflow.com/a/47197399/3076866

您需要提供视图的完整绝对路径

/var/www/etc/extra/plugin/.../yourplugin/<view_folder>/email/send

我们假设电子邮件是目录,发送是视图名称。

如果不能处理错误,请发表评论:)

答案 1 :(得分:0)

您还可以通过定位电子邮件视图来使其更加整洁:

article

尽管我认为OcotberCms要求您将视图文件夹命名为“视图”

在最近的一个项目中,我将其与邮件视图结构如下:

article

答案 2 :(得分:0)

您可以通过创建覆盖视图路径的路径 config / view.php

inside view.php

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | View Storage Paths
    |--------------------------------------------------------------------------
    |
    | Most templating systems load templates from disk. Here you may specify
    | an array of paths that should be checked for your views. Of course
    | the usual Laravel view path has already been registered for you.
    |
    */

    'paths' => [
        // Default Laravel Blade template location
        // realpath(base_path('resources/views'))
        realpath(base_path('plugins/a/b/views/pdf'))
    ],

    /*
    |--------------------------------------------------------------------------
    | Compiled View Path
    |--------------------------------------------------------------------------
    |
    | This option determines where all the compiled Blade templates will be
    | stored for your application. Typically, this is within the storage
    | directory. However, as usual, you are free to change this value.
    |
    */

    'compiled' => realpath(storage_path('framework/views')),

];