Attempt to read property "id" on null

Solved
vranaaff

Jun 6th, 2022 11:53 PM

when i click update on billing page this error came Conditions fulfilled: New User Billing Controller and Billing Blade is same as saas adventure class 8 source codes database is also same

thinkverse

Jun 7th, 2022 12:02 AM

Cannot provide help with the limited information given. Where does the error occur? When is it triggered?

Most importantly, what does it say? Which line and file did the error occur, that information should be included in the errors stack trace.

What day of the course did this error occur? Is it solved by the course for the next day?

vranaaff

Jun 7th, 2022 07:46 AM

hey check attached gdrive gif https://drive.google.com/file/d/1HvJG_Z4T6wNiwlkvNzovRal6PtoAcq3b/view?usp=drivesdk

its on day 8

thinkverse

Jun 7th, 2022 11:32 AM

Best Answer

The plan you are trying to update to doesn't exist in your database.

You can change to firstOrFail() instead of first() to make sure the billing update fails if a user tried to update to a plan that doesn't exist. Or check if the $plan fails with an if statement.

if (!$plan) {

}

Make sure you've migrated the latest migrations and used the PlansTableSeeder with artisan db:seed to seed the demo plans as per the day 8 video.

Also make sure the radio input contains the value attribute with the plan name and that the checkbox name attribute is set to plan.

<input type="radio" id="{{ $plan->name }}-plan" name="plan"  value="{{ $plan->name }}">