forked from ushahidi/platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPermissionRepository.php
More file actions
55 lines (45 loc) · 1.25 KB
/
Copy pathPermissionRepository.php
File metadata and controls
55 lines (45 loc) · 1.25 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
<?php
/**
* Ushahidi Permission Repository
*
* @author Ushahidi Team <team@ushahidi.com>
* @package Ushahidi\Application
* @copyright 2014 Ushahidi
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3)
*/
namespace Ushahidi\App\Repository;
use Ushahidi\Core\SearchData;
use Ushahidi\Core\Entity\Permission;
use Ushahidi\Core\Entity\PermissionRepository as PermissionRepositoryContract;
class PermissionRepository extends OhanzeeRepository implements
PermissionRepositoryContract
{
// OhanzeeRepository
protected function getTable()
{
return 'permissions';
}
// OhanzeeRepository
public function getEntity(array $data = null)
{
return new Permission($data);
}
public function getSearchFields()
{
return ['q', /* LIKE name */];
}
// SearchRepository
public function setSearchConditions(SearchData $search)
{
$query = $this->search_query;
if ($search->q) {
$query->where('name', 'LIKE', "%" .$search->q ."%");
}
return $query;
}
// UshahidiRepository
public function exists($permission)
{
return (bool) $this->selectCount(['name' => $permission]);
}
}