A bug in Laravel ( Whoops, looks like something went wrong.), how to fix it?

All kind time of day!
Guys, one user for some reason stopped open page after patched phpmyadmin. Error. How to fix it?
Thank you!
March 23rd 20 at 19:41
2 answers
March 23rd 20 at 19:43
Most likely a bug somewhere then, as the follower is simply absent, and consequently to its attributes cannot be
$follower->follower->username_slug

To prevent such errors, you need to use a helper function optional()
optional($follower->follower)->username_slug

But it is better to think of the architecture to check the availability of a subscriber and to display/not display information about it
You can still take advantage of this short design the PHP
$follower->follower->username_slug ?? 'undefined';
The first option gives an error..
1/1 FatalErrorException in 2c05e1cb686ec3fadc7085b804e2e46b line 124: Call to undefined function optional()

 in 2c05e1cb686ec3fadc7085b804e2e46b line 124


The second option..
FatalErrorException in 2c05e1cb686ec3fadc7085b804e2e46b line 124: syntax error, unexpected '?'

 in 2c05e1cb686ec3fadc7085b804e2e46b line 124


Generally, this error climbs only have one user, and we like the whole script is correct. Maybe somehow possible to adjust it individually? Maybe it's somewhere in BD?
Thank you! - karina_Witting6 commented on March 23rd 20 at 19:46
Maybe you're not correctly written? Though like right
https://laravel.com/docs/5.8/helpers#method-old

For the second option you have a PHP version of what? What version of Laravel? - rosemarie_Kub commented on March 23rd 20 at 19:49
PHP - 5.6.40
laravel - 5.1.46

Thank you! - karina_Witting6 commented on March 23rd 20 at 19:52
@karina_Witting6, check for presence of elements a call chain, using the ternary operator, for example. In PHP there is a statement about which wrote above (??), in modern Laravel also has a helper, who came later 5.1.

Update in a timely manner, if you do not want to experience pain in the future. - jorge98 commented on March 23rd 20 at 19:55
Purchased the script on codecanyon, and the developer from time to time makes changes. If you update the web framework, I'm afraid then something is crooked. Are not at risk.

It's not in the script and in the database. All files backup verified, no differences. The old database was loaded and everything works, but the site is full of new articles and don't want to lose them. Need database to verify and correct. That's just what and how to find where is the error? Wanted to try the program Beyond Compare, but something hangs. The base weighs a lot.
Thank you! - karina_Witting6 commented on March 23rd 20 at 19:58
March 23rd 20 at 19:45
The error you have written
ErrorException in 2c05e1cb686ec3fadc7085b804e2e46b line 124: Trying to get property of non-object (View: /home/admin/web/site.com/public_html/resources/themes/boxed/views/pages/users/userapp.blade.php) (View: /home/admin/web/site.com/public_html/resources/themes/boxed/views/pages/users/userapp.blade.php)


In Russian it means that at line 124 of file userapp.blade.php you're calling a field that doesn't exist in the object. Here is an example simpler, which is the same error
<?php
$obj = null;
$obj->a;


Go to the indicated row and figure out why you got an empty object or no object at all. Or do something like
<?php
$obj = null;
if (is_object($obj) && property_exists($obj, 'a')) {
$obj->a;
}
Forgot this file in question to publish. userapp.blade.php. 124 the line is empty. I becaom compared with which everything worked, no change.
Thank you! - karina_Witting6 commented on March 23rd 20 at 19:48
@karina_Witting6, there's just more of a compilation going on, so can be offset.

1) Try to find where the file, something like:
/home/admin/web/site.com/public_html/storage/framework/views/2c05e1cb686ec3fadc7085b804e2e46b where 2c05e1cb686ec3fadc7085b804e2e46b is a hash of errors, and in this file look the specified string

2) Try to leave the file empty template, like:
@extends ('app')
@section('head_title', $userinfo->username.' | '. getenvcong('sitename'))
@section('modedefault', 'mode-add')
@section("content")

@endsection

and see will there be any changes or disappears error

if you disappear, then the elimination method blocks look for the place where it falls - erling commented on March 23rd 20 at 19:51
@erling, file 2c05e1cb686ec3fadc7085b804e2e46b
And this file I checked the file from a backup, the same.
Thank you! - karina_Witting6 commented on March 23rd 20 at 19:54
@erling, the Second option is tried all users including (in order) all information is lost, but the error no longer exists).
Thank you! - karina_Witting6 commented on March 23rd 20 at 19:57
@erling, 118 string is removed, the user error disappears, but all the block is lost. Line..
<a class="follow-image" href="/profile/{{ $follower->follower->username_slug }}" title="{{ $follower->follower->username }}"><img src="{{ makepreview($follower->follower->icon, 's', 'members/avatar') }}" width="52" height="52" alt="{{ $follower->follower->username }}"></a>


Thank you! - karina_Witting6 commented on March 23rd 20 at 20:00

Find more questions by tags Laravel