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.

66 lines
1.5 KiB

7 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. 'disableregistration',
  11. 'info',
  12. 'unregister',
  13. 'gifapikey',
  14. 'restrictsuggestions',
  15. 'locale',
  16. 'loglevel',
  17. 'username',
  18. 'password',
  19. 'twittertoken',
  20. 'xmppdomain',
  21. 'xmppdescription',
  22. 'xmppwhitelist'
  23. ];
  24. protected $attributes = [
  25. 'id' => 1,
  26. 'unregister' => false,
  27. 'disableregistration' => false,
  28. 'restrictsuggestions' => false,
  29. 'loglevel' => 0,
  30. 'locale' => 'en',
  31. 'xmppwhitelist' => null
  32. ];
  33. public static function get()
  34. {
  35. if (self::$instance != null) {
  36. return self::$instance;
  37. }
  38. self::$instance = self::findOrNew(1);
  39. return self::$instance;
  40. }
  41. public function setPasswordAttribute($value)
  42. {
  43. $this->attributes['password'] = password_hash($value, PASSWORD_DEFAULT);
  44. }
  45. public function getXmppwhitelistAttribute()
  46. {
  47. return (empty($this->attributes['xmppwhitelist']))
  48. ? []
  49. : explode(',', $this->attributes['xmppwhitelist']);
  50. }
  51. public function getXmppwhitelistStringAttribute()
  52. {
  53. return $this->attributes['xmppwhitelist'];
  54. }
  55. }