尝试在 Laravel 5.4 上获取非对象错误的属性

问题描述 投票:0回答:1

(2/2) 错误异常 尝试获取非对象的属性(查看:C:\xampp\htdocs gcbus esources iews\usercrud\sendView.blade.php)

Visit `https://pastebin.com/wuV2zzhp` for link of the complete code that I 
think that took part on the token sending or verification process.

我希望我的应用程序将验证令牌发送到新用户的电子邮件地址(只有系统管理员可以添加新用户)

enter image description here

laravel laravel-5.4
1个回答
1
投票

ErrorException 尝试获取非对象的属性(查看:C:\xampp\htdocs gcbus esources iews\usercrud\sendView.blade.php)

此错误表明错误来自您的

sendView.blade.php
视图文件,您已声明该文件具有以下内容:

TO veerify <a href="{{ route('sendEmailDone', ["email" => $user->email,"verifyToken"=>$user->verifyToken]) }}" click here />

在此视图中唯一访问的对象是

$user
。让我们看看能否找出为什么它不是一个对象。

您的

sendView
视图正在通过
verifyEmail
可邮寄加载。通过 Mailable 加载视图时,可以从 Mailable 的公共属性中提取其“视图数据”。您的 Mailable does 已定义 public $user;,因此应将其发送到视图。那么为什么它不是一个对象呢?
假设您已粘贴 Mailable 的确切内容,则构造函数中似乎存在拼写错误:

public function __construct(User $user) { // $this->userC=$user; }

这会将提供的 
User

对象保存到公共属性

$userC
不是
$user
    

© www.soinside.com 2019 - 2024. All rights reserved.