林一峰
7 years ago
4 changed files with 101 additions and 12 deletions
-
5app/Http/Controllers/Api/CommentController.php
-
2app/Http/Model/Comment.php
-
86app/Http/Model/UserWithdraw.php
-
20composer.lock
@ -0,0 +1,86 @@ |
|||
<?php |
|||
namespace App\Http\Model; |
|||
|
|||
use App\Common\Token; |
|||
use DB; |
|||
|
|||
class UserWithdraw extends BaseModel |
|||
{ |
|||
//用户余额明细
|
|||
|
|||
protected $table = 'user_withdraw'; |
|||
public $timestamps = false; |
|||
|
|||
/** |
|||
* 不能被批量赋值的属性 |
|||
* |
|||
* @var array |
|||
*/ |
|||
protected $guarded = []; |
|||
|
|||
//获取列表
|
|||
public static function getList(array $param) |
|||
{ |
|||
extract($param); //参数:limit,offset
|
|||
|
|||
$where['user_id'] = Token::$uid; |
|||
$limit = isset($limit) ? $limit : 10; |
|||
$offset = isset($offset) ? $offset : 0; |
|||
|
|||
$model = new UserWithdraw; |
|||
|
|||
if(isset($type)){$where['type'] = $type;} |
|||
|
|||
$model = $model->where($where); |
|||
|
|||
$res['count'] = $model->count(); |
|||
$res['list'] = array(); |
|||
|
|||
if($res['count']>0) |
|||
{ |
|||
$res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get()->toArray(); |
|||
} |
|||
else |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return $res; |
|||
} |
|||
|
|||
public static function getOne($id) |
|||
{ |
|||
return self::where('id', $id)->first()->toArray(); |
|||
} |
|||
|
|||
public static function add(array $data) |
|||
{ |
|||
if ($id = self::insertGetId($data)) |
|||
{ |
|||
return $id; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
public static function modify($where, array $data) |
|||
{ |
|||
if (self::where($where)->update($data)) |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
//删除一条记录
|
|||
public static function remove($id) |
|||
{ |
|||
if (!self::whereIn('id', explode(',', $id))->delete()) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue