【问题标题】:Laravel with October CMSLaravel 与十月 CMS
【发布时间】:2018-04-22 04:21:07
【问题描述】:

我在 Laravel 中使用十月 CMS。 但我不知道如何插入数据来查看。 这是我路线中的代码。

    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]。

throw new InvalidArgumentException("View [$name] not found.");

这些文件在我十月 CMS 的“插件”中

【问题讨论】:

  • 检查config/view.php,如果是标准的laravel,你可以找到适合你的视图的地方。

标签: laravel octobercms


【解决方案1】:

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

内部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')),

];

【讨论】:

    【解决方案2】:

    您还可以通过像这样定位电子邮件视图来使其更简洁:

    pluginauthor.pluginname::email.send
    

    虽然我认为 OcotberCms 要求您将视图文件夹命名为“views”

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

    /views/mail/{{email template name}}
    

    【讨论】:

      【解决方案3】:

      我猜你也面临同样的问题:

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

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

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

      我们假设 email 是目录,send 是视图名称。

      如果没有错误,请发表评论:)

      【讨论】:

      • 我试试这个。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多