Permission.php (1070B) download
1<?php
2
3namespace Model {
4 class Permission extends \Lollipop\DatabaseObject
5 {
6 public static function get_table(): string
7 {
8 return "permission";
9 }
10
11 public static function get_primary(): string
12 {
13 return "id";
14 }
15 public static function get_schema(): string
16 {
17 return "panda";
18 }
19 public function get_checkboxes(): array
20 {
21 $all_permissions = $this->db->all($this::class);
22 $html = "<div class='check_this_box'>";
23 foreach($all_permissions as $permission) {
24 $html .= '<input type="checkbox" id="'. $permission->name .'" name="permissions[]" value="'. $permission->id .'"';
25 if($permission->id == 0) {
26 $html .= ' checked';
27 }
28 $html .= '>';
29 $html .= '<label for="'. $permission->name .'">'. $permission->name .'</label>';
30 }
31 $html .= "</div>";
32 return [0 => $html];
33 }
34 }
35}