1 | <?php |
||
28 | class OrganizationLimit extends BaseBlameableModel |
||
29 | { |
||
30 | public $contentAttribute = 'limit'; |
||
31 | public $contentAttributeRule = ['integer', 'min' => 0]; |
||
32 | public $updatedByAttribute = false; |
||
33 | public $idAttribute = false; |
||
34 | /** |
||
35 | * @var string The host who owns this model. |
||
36 | * Note: Please assign it with your own User model. |
||
37 | */ |
||
38 | public $hostClass = User::class; |
||
39 | public $defaultLimit = 10; |
||
40 | |||
41 | /** |
||
42 | * @return string |
||
43 | */ |
||
44 | 51 | public static function tableName() |
|
48 | |||
49 | /** |
||
50 | * @return array |
||
51 | */ |
||
52 | 51 | protected function getLimitRules() |
|
58 | |||
59 | /** |
||
60 | * @return array |
||
61 | */ |
||
62 | 51 | public function rules() |
|
66 | |||
67 | /** |
||
68 | * @return array |
||
69 | */ |
||
70 | public function attributeLabels() |
||
82 | |||
83 | /** |
||
84 | * Get the upper limit of organizations the user could set up. |
||
85 | * @param User|integer|string $user |
||
86 | * @return int|boolean False if no limit. |
||
87 | */ |
||
88 | 51 | public static function getLimit($user) |
|
107 | |||
108 | /** |
||
109 | * Set the upper limit of organizations the user could set up. |
||
110 | * @param User|integer|string $user |
||
111 | * @param int $limit |
||
112 | * @return boolean |
||
113 | */ |
||
114 | public static function setLimit($user, $limit = 1) |
||
130 | } |
||
131 |