在laravel上回显名字 [英] echo firstname on laravel

查看:65
本文介绍了在laravel上回显名字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在页面上回显first_name,但无法解决.

I'm trying to echo first_name on the page but I couldn't work it out how.

$providerEmail = Auth::user()->email;
  $providerName = Auth::user()->first_name;
    return View::make('account')->with( 'providerEmail', $providerEmail, 'providerName', $providerName);

()-> email位有效,它回显用户电子邮件,但是回显first_name时,给我$ providerName错误(未定义变量:providerName).

the ()->email bit works, it echos the user email but when echoing first_name it gives me $providerName error (Undefined variable: providerName).

推荐答案

您可以进行大量清理.像这样将整个提供者模型发送到您的视图中,而不是为提供者的每个属性分配新的视图变量.

You could clean this up considerably. Rather than assigning a new view variable for each property of your provider, just send the entire provider model to your view like this.

<?php

$provider = Auth::user();

return View::make('account')->with('provider', $provider);

然后,在您的视图中,您可以像在路由或控制器中一样访问电子邮件,名称和其他属性.

Then in your views, you can access the email, name, and other properties just as you would in your route or controller.

可见

$provider->email

这篇关于在laravel上回显名字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆