inc('num', $num)->update(); return $res; } public static function expend($lake_id, $type, $num, $link_id = 0, $mark = '') { $lake = AwardLake::find($lake_id); if (!$lake) throw new Exception('invalid lake'); if ($lake->num < $num) { throw new Exception('lake num not enough'); } $pm = 0; $add_time = time(); $res = self::create(compact('lake_id', 'type', 'num', 'link_id', 'mark', 'pm', 'add_time')); $res = $res && AwardLake::where('id', $lake_id)->dec('num', $num)->update(); return $res; } }