Base.php
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Base extends Model
{
public $allCount = 1;
/**
* @name 列表数据
* @return void
* @author :liyuhang
* @method
*/
public function lists($map, $p, $row, $order = 'id desc', $fields = true){
//TODO::where(['id'=>'','name'=>''])
$lists = $this::select($fields)->forPage($p,$row)->where($map)->orderBy($order)->get()->toArray();
if (!empty($lists)) {
$this->allCount = $this->where($map)->count();
}
return $lists;
}
/**
* @param array:$condition
* @name :获取单条数据详情
* @return mixed
* @author :liyuhang
* @method get
*/
public function read($condition,$files)
{
$info = $this->select($files)->where($condition)->find();
if (!empty($info)) {
$info = $info->toArray();
}
return $info;
}
/**
* @name :新增
* @return void
* @author :liyuhang
* @method post
*/
public function add($data){
return $this->insert($data);
}
/**
* @name :编辑
* @return void
* @author :liyuhang
* @method post
*/
public function edit($data,$condition){
return $this->where($condition)->update($data);
}
/**
* @name :删除数据
* @return bool|void|null
* @author :liyuhang
* @method post
*/
public function delete($condition){
return $this->where($condition)->delete();
}
}