Newbie struggling with a 'Call to undefined method' error in Laravel Eloquent ORM query
0
Hi everyone, I'm quite new to Laravel development and struggling with a 'Call to undefined method' error while trying to fetch data using Eloquent ORM.
I'm not sure what I'm doing wrong with the query, so here's a simplified version of my code and the error I'm encountering:
// My Model
class Product extends Model
{
protected $fillable = ['name', 'price'];
}
// My Controller Method
public function showActiveProducts()
{
$products = Product::where('is_active', true)->get_active(); // This line causes the error
return view('products.index', compact('products'));
}
// The Error Log
Call to undefined method App\Models\Product::get_active()
in file .../app/Http/Controllers/ProductController.php on line X
Could anyone please advise on how to correctly structure this Eloquent ORM query? Thanks in advance!
0 Answers
No answers yet.
Be the first to provide a helpful answer!
Your Answer
You must Log In to post an answer and earn reputation.
Hot Discussions
2
Better ISP finder data?
168 Views
5
ISP finder not working!
153 Views