1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace A17\Twill\Repositories; |
4
|
|
|
|
5
|
|
|
use A17\Twill\Models\Group; |
6
|
|
|
use A17\Twill\Repositories\Behaviors\HandleGroupPermissions; |
7
|
|
|
|
8
|
|
|
class GroupRepository extends ModuleRepository |
9
|
|
|
{ |
10
|
|
|
use HandleGroupPermissions; |
|
|
|
|
11
|
|
|
|
12
|
|
|
public function __construct(Group $model) |
13
|
|
|
{ |
14
|
|
|
$this->model = $model; |
|
|
|
|
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function getFormFields($group) |
18
|
|
|
{ |
19
|
|
|
$fields = parent::getFormFields($group); |
20
|
|
|
|
21
|
|
|
$fields['browsers']['users'] = $this->getFormFieldsForBrowser($group, 'users'); |
22
|
|
|
|
23
|
|
|
return $fields; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function afterSave($group, $fields) |
27
|
|
|
{ |
28
|
|
|
$this->updateBrowser($group, $fields, 'users'); |
29
|
|
|
|
30
|
|
|
parent::afterSave($group, $fields); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function delete($id) |
34
|
|
|
{ |
35
|
|
|
if ($this->model->find($id)->is_everyone_group) { |
|
|
|
|
36
|
|
|
return false; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
return parent::delete($id); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function bulkDelete($ids) |
43
|
|
|
{ |
44
|
|
|
$includes_everyone_group = $this->model->whereIn('id', $ids) |
45
|
|
|
->where('is_everyone_group', true) |
46
|
|
|
->first(); |
47
|
|
|
|
48
|
|
|
if ($includes_everyone_group) { |
49
|
|
|
return false; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
return parent::bulkDelete($ids); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function filter($query, array $scopes = []) |
56
|
|
|
{ |
57
|
|
|
$this->searchIn($query, $scopes, 'search', ['name']); |
58
|
|
|
|
59
|
|
|
return parent::filter($query, $scopes); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|