Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.

Get Started Now!

Why I’m getting ‘Non-static method should not be called statically’ when invoking a method in a Eloquent model?

I don’t know why I am getting this error:

Non-static method App\Userevent::returnopretor() should not be called statically

This is my blade file method:

This is my model:

Can you help me? I am trying to do dynamic dependency dropdown menu in view with this. Want to get user names and id from Userevent model for dropdown in view and than connect returnopretor with users and save data to product table with user id.

Relationships is to be called on models, so you have to fetch them from a user model. Change your controller logic to just fetch Userevent, not anything with returnopretor.

So in your blade file where you create your drop down, loop the users and then you can loop the returnopretor.

solved this error.

Related Posts

How to Deploy a Laravel Project on a Linux Server Using HTDOCS and GitHub – Complete Step-by-Step Guide

Deploying a Laravel project on a Linux server becomes simple when you follow a structured process. In this guide, we will deploy a Laravel project by cloning Read More

Read More

How to Install and Enable GMP Extension in XAMPP PHP on Linux (Step-by-Step Guide)

Introduction If you are using XAMPP PHP on a Linux server and encounter errors like: then this usually means the GMP extension is not installed, not just Read More

Read More

How to Run an HTML Website Alongside a Laravel Project on the Same Server

Running a Laravel application is common for dynamic web platforms, dashboards, and APIs. However, many businesses and developers also want to run a simple HTML website on Read More

Read More
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x