|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Eddy <[email protected]> |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace App\Repository\Admin; |
|
7
|
|
|
|
|
8
|
|
|
use App\Model\Admin\SensitiveWord; |
|
9
|
|
|
use App\Repository\Searchable; |
|
10
|
|
|
|
|
11
|
|
|
class SensitiveWordRepository |
|
12
|
|
|
{ |
|
13
|
|
|
use Searchable; |
|
14
|
|
|
|
|
15
|
|
|
public static function list($perPage, $condition = []) |
|
16
|
|
|
{ |
|
17
|
|
|
$data = SensitiveWord::query() |
|
18
|
|
|
->where(function ($query) use ($condition) { |
|
19
|
|
|
Searchable::buildQuery($query, $condition); |
|
20
|
|
|
}) |
|
21
|
|
|
->orderBy('id', 'desc') |
|
22
|
|
|
->paginate($perPage); |
|
23
|
|
|
$data->transform(function ($item) { |
|
24
|
|
|
xssFilter($item); |
|
25
|
|
|
$item->editUrl = route('admin::SensitiveWord.edit', ['id' => $item->id]); |
|
26
|
|
|
$item->deleteUrl = route('admin::SensitiveWord.delete', ['id' => $item->id]); |
|
27
|
|
|
return $item; |
|
28
|
|
|
}); |
|
29
|
|
|
|
|
30
|
|
|
return [ |
|
31
|
|
|
'code' => 0, |
|
32
|
|
|
'msg' => '', |
|
33
|
|
|
'count' => $data->total(), |
|
34
|
|
|
'data' => $data->items(), |
|
35
|
|
|
]; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public static function add($data) |
|
39
|
|
|
{ |
|
40
|
|
|
return SensitiveWord::query()->create($data); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public static function update($id, $data) |
|
44
|
|
|
{ |
|
45
|
|
|
return SensitiveWord::query()->where('id', $id)->update($data); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public static function find($id) |
|
49
|
|
|
{ |
|
50
|
|
|
return SensitiveWord::query()->find($id); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public static function delete($id) |
|
54
|
|
|
{ |
|
55
|
|
|
return SensitiveWord::destroy($id); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
public static function exist($condition) |
|
59
|
|
|
{ |
|
60
|
|
|
return SensitiveWord::where($condition)->first(); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|