<?php
/**
 * Created by PhpStorm.
 * User: scstf
 * Date: 2018/10/26
 * Time: 9:18
 */

namespace App\Api\Model;

use \System\Model;

class UserSetting extends Model
{
    protected $table = 'user_setting';
    public $primaryKey = 'account_identity';
    public $incrementing = false;
    public $fillable = ['hand_lock', 'hand_pass', 'sound', 'prize_ani', 'shake_rand','prize_games','win_games'];

    public function getUserSetting($uuid)
    {

        return ($ret = $this->where ('account_identity', $uuid)->first ()) ? $ret->toArray () : '';

    }

    public function setUserSettings($uuid, $data)
    {   
        $us = $this->where ('account_identity', $uuid)->first();
        if ($us) {
            return $this->where('account_identity',$uuid)->update($data);
        }else{
            $data['account_identity'] = $uuid;
            return $this->insert($data);
        }
    }
}



