UserSetting.php 898 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: scstf
  5. * Date: 2018/10/26
  6. * Time: 9:18
  7. */
  8. namespace App\Api\Model;
  9. use \System\Model;
  10. class UserSetting extends Model
  11. {
  12. protected $table = 'user_setting';
  13. public $primaryKey = 'account_identity';
  14. public $incrementing = false;
  15. public $fillable = ['hand_lock', 'hand_pass', 'sound', 'prize_ani', 'shake_rand','prize_games','win_games'];
  16. public function getUserSetting($uuid)
  17. {
  18. return ($ret = $this->where ('account_identity', $uuid)->first ()) ? $ret->toArray () : '';
  19. }
  20. public function setUserSettings($uuid, $data)
  21. {
  22. $us = $this->where ('account_identity', $uuid)->first();
  23. if ($us) {
  24. return $this->where('account_identity',$uuid)->update($data);
  25. }else{
  26. $data['account_identity'] = $uuid;
  27. return $this->insert($data);
  28. }
  29. }
  30. }