Created
January 12, 2014 13:58
-
-
Save cronoh/8384851 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Setting Model */ | |
class Setting extends Eloquent { | |
public function setValue($name, $value) { | |
$setting = $this->firstOrCreate(array('name' => $name)); | |
$setting->value = $value; | |
return $setting->save() ? $setting : false; | |
} | |
} | |
/* Controller */ | |
public function showLogin() { | |
$s = Setting::firstOrCreate(array('name' => 'testing')); // Works fine | |
$setting = Setting::setValue('test', 123); // Fails | |
$this->layout->content = View::make('portal.pages.login'); | |
} | |
Error: | |
Non-static method Setting::setValue() should not be called statically, assuming $this from incompatible context |
wing5wong
commented
Jan 12, 2014
setting = $setting;
}
public function dumpAllSettings()
{
dd($this->setting->all());
}
```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment