laravellaravel-5.4

Trying to get property of non-object error on laravel 5.4


(2/2) ErrorException Trying to get property of non-object (View: C:\xampp\htdocs\bgcbus\resources\views\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.

I want my application to send a verification token to email address of new users(only the admin of the system can add new users)

enter image description here


Solution

  • ErrorException Trying to get property of non-object (View: C:\xampp\htdocs\bgcbus\resources\views\usercrud\sendView.blade.php)

    This error indicates that the bug is coming from your sendView.blade.php view file, which you've stated has the following content:

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

    The only object being accessed in this view is $user. Let's see if we can figure out why it isn't an object.

    Your sendView view is being loaded through the verifyEmail Mailable. When loading a view via a Mailable, its view data can be pulled from the public properties of the Mailable. Your Mailable does have public $user; defined, so it should be sent to the view. So why isn't it an object?

    Assuming you've pasted the exact content of your Mailable, there appears to be a typo in your constructor:

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

    This is saving the supplied User object to the public property $userC, not $user.