The answer is in the error message: you're trying to use $this when in a static context, wich is not allowed.
To set/get data in models, you can use "default" methods, there's no need to declare them static.
Behind the scenes, Laravel will instantiate the class and call the desired methods, so it isn't "everything static".
Edit: another way is by getting/setting data directly in attributes. In your example, $foo is a public attribute, so you can do something like this:
$object = new Foo;
$object->foo = 'Hello!';
echo $object->foo;
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community