You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.4 KiB

8 years ago
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Configuration extends Model
  5. {
  6. protected $table = 'configuration';
  7. private static $instance = null;
  8. public $fillable = [
  9. 'description',
  10. 'info',
  11. 'unregister',
  12. 'restrictsuggestions',
  13. 'locale',
  14. 'loglevel',
  15. 'username',
  16. 'password',
  17. 'xmppdomain',
  18. 'xmppdescription',
  19. 'xmppcountry',
  20. 'xmppwhitelist'
  21. ];
  22. protected $attributes = [
  23. 'id' => 1,
  24. 'unregister' => false,
  25. 'restrictsuggestions' => false,
  26. 'loglevel' => 0,
  27. 'locale' => 'en',
  28. 'xmppwhitelist' => null
  29. ];
  30. public static function get()
  31. {
  32. if (self::$instance != null) {
  33. return self::$instance;
  34. }
  35. self::$instance = self::findOrNew(1);
  36. return self::$instance;
  37. }
  38. public function setPasswordAttribute($value)
  39. {
  40. $this->attributes['password'] = password_hash($value, PASSWORD_DEFAULT);
  41. }
  42. public function getXmppwhitelistAttribute()
  43. {
  44. return (empty($this->attributes['xmppwhitelist']))
  45. ? []
  46. : explode(',', $this->attributes['xmppwhitelist']);
  47. }
  48. public function getXmppwhitelistStringAttribute()
  49. {
  50. return $this->attributes['xmppwhitelist'];
  51. }
  52. }