it seems to be the first one inside the "if"
Can show the ->toJson()?
I get this error when I add up the toJson() in the code:
FatalErrorException in Handler.php line 25: Uncaught TypeError: Argument 1 passed to L5\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /home4/inspedd3/app/inspectionplatform.com/production/app/Exceptions/Handler.php:25 Stack trace: #0 /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): L5\Exceptions\Handler->report(Object(Error)) #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) #2 {main} thrown
please show your entire error log, why does it keep going back to ::report()
[2020-11-01 14:05:14] local.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught TypeError: Argument 1 passed to L5\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /longpath/app/Exceptions/Handler.php:25 Stack trace: #0 /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): L5\Exceptions\Handler->report(Object(Error)) #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) #2 {main} thrown in /longpath/app/Exceptions/Handler.php:25 Stack trace: #0 {main} [2020-11-01 14:05:37] local.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught TypeError: Argument 1 passed to L5\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /longpath/app/Exceptions/Handler.php:25 Stack trace: #0 /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): L5\Exceptions\Handler->report(Object(Error)) #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) #2 {main} thrown in /longpath/app/Exceptions/Handler.php:25 Stack trace: #0 {main} [2020-11-01 14:05:55] local.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught TypeError: Argument 1 passed to L5\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /longpath/app/Exceptions/Handler.php:25 Stack trace: #0 /longpath/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): L5\Exceptions\Handler->report(Object(Error)) #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) #2 {main} thrown in /longpath/app/Exceptions/Handler.php:25 Stack trace: #0 {main}
public function getIndex($id = null)
{
if($id == null)
{
$companies = Company::hasPermission(array('c', 'r', 'u', 'd'), Sentry::getUser()->id, false)->with('peoples', 'country', 'industries')->filter()->get();
dd($companies->first()->toJson()); // expand everything and show us the output
...
}
else
{
$company = Company::hasPermission(array('c', 'r', 'u', 'd'), Sentry::getUser()->id, false)->with('peoples', 'country', 'industries')->filter()->find($id);
dd($company->toJson()); // expand everything and show us the output
...
}
}
"{"id":179,"name":"Global","address":"Jan Bat","city":"Canggu","zipcode":"80361","country_id":102,"telephone":"+692","fax":"","email":"[email protected]","website":"","sales_turnover":1,"purchase_turnover":1,"linkedin":"","industry_id":0,"bank_name":"","bank_address":"","bank_no":"","bank_beneficiary":"","bank_swift":"","tags":"","priority":"Low","status":"Prospect","logo":null,"profile":null,"facebook":"","twitter":"","state":"","user_id":0,"created_at":"2017-02-28 10:58:31","updated_at":"2017-08-30 14:30:22","registered":1,"remote_addr":"2.58.193.82","http_user_agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36","short_tag":"GLO0001","rank_id":null,"annual_turnover":"","staffs_count":"","mobile_phone":"","company_personal_note":"","interested_in":"["service_name"]","account_manager_id":115,"provenance":"registered","peoples":[{"id":2,"company_id":179,"title":"","first_name":"Ec","last_name":"Br","position":"","email1":"[email protected]","email2":null,"personal_email":null,"skype":null,"mobile":"","phone":null,"fax":"","linkedin":"","dob":null,"created_at":"2017-02-28 10:58:31","updated_at":"2017-02-28 10:58:31","landline":"","tags":"","facebook":"","twitter":"","personal_note":null}],"country":null,"industries":[]}"
Can you see that the JSON you pasted has null for country?
I hope you now accept the fact that country is null.. for whatever reason. Telling me it cannot be null will not solve your problem.
Yes I see it here but I also see this : "country_id":102 and this is from country_id that i should get the name of the country. So how to make this ?
We are 40 messages deep.
You are going to get the error anytime country shows up as null. I have explained how to fix your initial Trying to get property of non-object problem by not showing country when it is null.
As to why country is null, that is another problem.
... country_id that i should get the name of the country. So how to make this ?
We have gone through this. https://laracasts.com/discuss/channels/general-discussion/12-errorexception-in-44812f12bcefe0281da2f29a7f94d872-line-40-trying-to-get-property-of-non-object?page=1#reply=660124
But this don't work: "When Laravel sees $company->country->name, it automatically knows to use country_id to query country table and get the name." since i have country_id filled and still not showing the country name...
If you insist country is not null, then I cannot help anymore.
country is null (not sure why) , but country_id is not. so the question is how to get country name from country_id ?
As I tried to explain here https://laracasts.com/discuss/channels/general-discussion/12-errorexception-in-44812f12bcefe0281da2f29a7f94d872-line-40-trying-to-get-property-of-non-object?page=1#reply=660124
Laravel understands country_id is referring to the look up table country. country_id and country are the same. Laravel strips off the _id as necessary.
but why i can not get country_name then ?
I solved this problem by reinstall the the app in a folder named L5 as I suspected and it worked back as it should. so it was the real problem... there was probably something in the path configuration poiting to a subfolder /L5 which make that mess up my query.. not sure why...
Please or to participate in this conversation.