I have a class in a file like:
class foo
{
public function something()
{
return "something"
}
}
Then in an other file I have a class like:
class bar extends foo
{
}
Now I want to call the something method.
I can do this like foo::something();
, but I want to just do something()
. just like it is in Laravel.
Ofcourse I can require
the file where foo
is in, but I dont want that, because I think thats kind of dirty.
So, how do I do that? I've looked around on the internet but did not find an answer. Everthing I find is from like 5-7 years ago.
EDIT:
Look, you just return view();
Without self::
or this->
And I am wondering how you do that. IN VANILLA PHP
public function index()
{
$categories = Category::categories();
$posts = Post::latest()->get();
return view('welcome', compact('posts', 'categories'));
}