duanli6834 2018-10-26 13:10
浏览 15

如何在传递视图之前临时更改数据

I am passing one row to the blade. Also doing this for lots of page. But in one page, i need to edit some datas in row, like this. This is eloquent:

$meta = SeoOptimization::find($id)->first();

it has title, description and keywords

what i want to do is, change title and description before passing to the view.

I do like that:

$meta['title'] = $category->translate()->title;

But now worked. Also tried this:

$meta->title = $category->translate()->title;

That didn't worked too.

dd($category->translate()->title); 

is successfully return what i want. How can i pass this, with $meta->title? Any suggestion?

Still can't pass to view, they are chaning but changed in controller. Can't pass.

  • 写回答

1条回答 默认 最新

  • dsvyc66464 2018-10-26 13:29
    关注

    try to use like that for example by using toArray() method

    $user = User::where('id',1)->first();
    $user->name = "Jignesh";
    return view('views.cagegory')->with(['user' => $user->toArray()]);
    

    in view

    @isset($user)
         <h1>{{$user['name']}}</h1>
    @endif
    
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?