【问题标题】:Laravel Controller - template. suppress the master templateLaravel 控制器 - 模板。抑制主模板
【发布时间】:2013-08-18 23:32:06
【问题描述】:

我开始使用 Laravel。我有一个显示和插入数据的控制器。类似于

class UserController extends BaseController {

     protected $layout = 'layouts.master';

     public function showProfile()
     {
         $this->layout->content = View::make('user.profile');
     }

     public function addProfile()
     {
         <Insertion Logic>
         echo "Successfully added";
     }

}

现在 insert 是一个 ajax 调用。所以我想在添加到数据库后只显示成功消息。但在我的情况下,布局内容也会出现。我怎样才能返回回显消息。

谢谢

【问题讨论】:

    标签: php ajax templates laravel


    【解决方案1】:

    由于您在方法中,您将能够访问和更改受保护的属性。

    您只需在执行回显之前添加$this-&gt;layout = '';

    【讨论】:

      猜你喜欢
      • 2016-07-07
      • 1970-01-01
      • 2016-06-16
      • 1970-01-01
      • 2016-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多