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 | 51 | public static function tableName() |
|
45 | |||
46 | 51 | protected function getLimitRules() |
|
47 | { |
||
48 | return [ |
||
49 | 51 | [$this->contentAttribute, 'default', 'value' => is_numeric($this->defaultLimit) ? (int)$this->defaultLimit : 10] |
|
50 | 51 | ]; |
|
51 | } |
||
52 | |||
53 | 51 | public function rules() |
|
57 | |||
58 | public function attributeLabels() |
||
70 | |||
71 | /** |
||
72 | * Get the upper limit of organizations the user could set up. |
||
73 | * @param User|integer|string $user |
||
74 | * @return int|boolean False if no limit. |
||
75 | */ |
||
76 | 51 | public static function getLimit($user) |
|
95 | } |
||
96 |