hanze/lollipop

Model/Grade.php in master
Repositories | Summary | Log | Files

Grade.php (1359B) download


 1<?php
 2
 3namespace Model {
 4
 5    use Lollipop\Utils;
 6
 7    class Grade extends \Lollipop\DatabaseObject
 8    {
 9        public static function get_table(): string
10        {
11            return "grade";
12        }
13
14        public static function get_primary(): string
15        {
16            return "id";
17        }
18
19        public static function get_schema(): string
20        {
21            return "lollipop";
22        }
23
24        public function add_grade(): bool
25        {
26            $missing_fields = Utils::missing_fields($this->notNullable());
27            if(sizeof($missing_fields) == 0) {
28                foreach($_POST as $key => $post) {
29                    if(in_array($key, $this->get_col_names_no_ai())) {
30                        $this->{$key} = $post;
31                    }
32                }
33                return $this->add();
34            }
35            return false;
36        }
37        public function update_grade(): bool
38        {
39            $missing_fields = Utils::missing_fields($this->notNullable());
40            if(sizeof($missing_fields) == 0) {
41                foreach($_POST as $key => $post) {
42                    if(in_array($key, $this->get_column_names())) {
43                        $this->{$key} = $post;
44                    }
45                }
46                return $this->save();
47            }
48            return false;
49        }
50
51    }
52}