It’s really quite simple. You haven’t been exposed to the proper process of developing. The code is just a small part of it. Your stress and frustration are coming from the lack of planning and refining what you are building. Acceptance criteria on what it should be doing, and more importantly, writing solid tests around your code to cut down on the number of bugs.
You need to join the church of Laravel, my friend. Our lord and savior Taylor will help you find peace in the unnecessarily complicated pastures of web development.