Skip to content

Instantly share code, notes, and snippets.

@cronoh
Created January 12, 2014 13:58
Show Gist options
  • Save cronoh/8384851 to your computer and use it in GitHub Desktop.
Save cronoh/8384851 to your computer and use it in GitHub Desktop.
/* 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
Copy link

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