@@ -12,101 +12,101 @@ |
||
12 | 12 | |
13 | 13 | class View |
14 | 14 | { |
15 | - private $renderer; |
|
16 | - private $template; |
|
17 | - private $params = []; |
|
15 | + private $renderer; |
|
16 | + private $template; |
|
17 | + private $params = []; |
|
18 | 18 | |
19 | - private static $intance; |
|
19 | + private static $intance; |
|
20 | 20 | |
21 | - public static function getInstance() { |
|
22 | - if (!self::$intance) { |
|
23 | - self::$intance = (new View); |
|
24 | - } |
|
25 | - return self::$intance; |
|
26 | - } |
|
21 | + public static function getInstance() { |
|
22 | + if (!self::$intance) { |
|
23 | + self::$intance = (new View); |
|
24 | + } |
|
25 | + return self::$intance; |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - public function __construct() { |
|
30 | - $config = Config::getInstance(); |
|
31 | - $view_engine = $config->get('views.engine'); |
|
32 | - $view_folder = $config->get('views.path_views'); |
|
33 | - $view_cache = $config->get('views.path_cache'); |
|
29 | + public function __construct() { |
|
30 | + $config = Config::getInstance(); |
|
31 | + $view_engine = $config->get('views.engine'); |
|
32 | + $view_folder = $config->get('views.path_views'); |
|
33 | + $view_cache = $config->get('views.path_cache'); |
|
34 | 34 | |
35 | - $paths = new \SplPriorityQueue(); |
|
36 | - $paths->insert($view_folder, 1); |
|
35 | + $paths = new \SplPriorityQueue(); |
|
36 | + $paths->insert($view_folder, 1); |
|
37 | 37 | |
38 | - switch ($view_engine) { |
|
39 | - case 'blade': |
|
40 | - $this->renderer = new BladeRenderer($paths, ['cache_path' => $view_cache]); |
|
41 | - break; |
|
42 | - case 'twig': |
|
43 | - $this->renderer = new TwigRenderer($paths); |
|
44 | - break; |
|
45 | - default: |
|
46 | - $this->renderer = new BladeRenderer($paths, $view_cache); |
|
47 | - break; |
|
48 | - } |
|
38 | + switch ($view_engine) { |
|
39 | + case 'blade': |
|
40 | + $this->renderer = new BladeRenderer($paths, ['cache_path' => $view_cache]); |
|
41 | + break; |
|
42 | + case 'twig': |
|
43 | + $this->renderer = new TwigRenderer($paths); |
|
44 | + break; |
|
45 | + default: |
|
46 | + $this->renderer = new BladeRenderer($paths, $view_cache); |
|
47 | + break; |
|
48 | + } |
|
49 | 49 | |
50 | - } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Render the view specified |
|
54 | - * |
|
55 | - * @param string $view |
|
56 | - */ |
|
57 | - public function render($view = null , $params = null) |
|
58 | - { |
|
59 | - $params = ($params) ? $params : $this->params; |
|
60 | - $view = $view ?: $this->template; |
|
61 | - echo $this->renderer->render($view, $params); |
|
62 | - } |
|
52 | + /** |
|
53 | + * Render the view specified |
|
54 | + * |
|
55 | + * @param string $view |
|
56 | + */ |
|
57 | + public function render($view = null , $params = null) |
|
58 | + { |
|
59 | + $params = ($params) ? $params : $this->params; |
|
60 | + $view = $view ?: $this->template; |
|
61 | + echo $this->renderer->render($view, $params); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Set the view file to be rendered. |
|
66 | - * |
|
67 | - * @param string $template |
|
68 | - */ |
|
69 | - public function setView($template) |
|
70 | - { |
|
71 | - $this->template = $template; |
|
72 | - } |
|
64 | + /** |
|
65 | + * Set the view file to be rendered. |
|
66 | + * |
|
67 | + * @param string $template |
|
68 | + */ |
|
69 | + public function setView($template) |
|
70 | + { |
|
71 | + $this->template = $template; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * Adds a parameter in the view. |
|
76 | - * |
|
77 | - * @param string $name |
|
78 | - * @param mixed $value |
|
79 | - */ |
|
80 | - public function addParam($name, $value) |
|
81 | - { |
|
82 | - $this->params[$name] = $value; |
|
83 | - } |
|
74 | + /** |
|
75 | + * Adds a parameter in the view. |
|
76 | + * |
|
77 | + * @param string $name |
|
78 | + * @param mixed $value |
|
79 | + */ |
|
80 | + public function addParam($name, $value) |
|
81 | + { |
|
82 | + $this->params[$name] = $value; |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * Add array parameters in view, each position of the array will become a variable |
|
87 | - * available to the view. |
|
88 | - * |
|
89 | - * @param array $array |
|
90 | - */ |
|
91 | - public function addParams($array) |
|
92 | - { |
|
93 | - foreach ($array as $name => $value) { |
|
94 | - $this->addParam($name, $value); |
|
95 | - } |
|
96 | - } |
|
97 | - /** |
|
98 | - * Returns the specified parameter. |
|
99 | - * |
|
100 | - * @param string $name |
|
101 | - * |
|
102 | - * @return void|mixed |
|
103 | - */ |
|
104 | - public function getParam($name) |
|
105 | - { |
|
106 | - if (isset($this->params[$name])) { |
|
107 | - return $this->params[$name]; |
|
108 | - } |
|
109 | - return true; |
|
110 | - } |
|
85 | + /** |
|
86 | + * Add array parameters in view, each position of the array will become a variable |
|
87 | + * available to the view. |
|
88 | + * |
|
89 | + * @param array $array |
|
90 | + */ |
|
91 | + public function addParams($array) |
|
92 | + { |
|
93 | + foreach ($array as $name => $value) { |
|
94 | + $this->addParam($name, $value); |
|
95 | + } |
|
96 | + } |
|
97 | + /** |
|
98 | + * Returns the specified parameter. |
|
99 | + * |
|
100 | + * @param string $name |
|
101 | + * |
|
102 | + * @return void|mixed |
|
103 | + */ |
|
104 | + public function getParam($name) |
|
105 | + { |
|
106 | + if (isset($this->params[$name])) { |
|
107 | + return $this->params[$name]; |
|
108 | + } |
|
109 | + return true; |
|
110 | + } |
|
111 | 111 | |
112 | 112 | } |
113 | 113 | \ No newline at end of file |
@@ -9,52 +9,52 @@ |
||
9 | 9 | |
10 | 10 | class Safe |
11 | 11 | { |
12 | - public static $salt = 'tfju=fiM148We4oYuyojjzmA6b9UKGhQ'; |
|
12 | + public static $salt = 'tfju=fiM148We4oYuyojjzmA6b9UKGhQ'; |
|
13 | 13 | |
14 | - /** |
|
15 | - * @param $text |
|
16 | - * |
|
17 | - * @return string |
|
18 | - */ |
|
19 | - public static function encrypt($text) { |
|
20 | - return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, self::$salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)))); |
|
21 | - } |
|
14 | + /** |
|
15 | + * @param $text |
|
16 | + * |
|
17 | + * @return string |
|
18 | + */ |
|
19 | + public static function encrypt($text) { |
|
20 | + return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, self::$salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)))); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * @param $text |
|
25 | - * |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public static function decrypt($text) { |
|
29 | - return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, self::$salt, base64_decode($text), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))); |
|
30 | - } |
|
23 | + /** |
|
24 | + * @param $text |
|
25 | + * |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public static function decrypt($text) { |
|
29 | + return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, self::$salt, base64_decode($text), MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))); |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param $value |
|
34 | - * |
|
35 | - * @return bool|string |
|
36 | - */ |
|
37 | - public static function hashEncode($value) { |
|
38 | - return password_hash($value, PASSWORD_DEFAULT); |
|
39 | - } |
|
32 | + /** |
|
33 | + * @param $value |
|
34 | + * |
|
35 | + * @return bool|string |
|
36 | + */ |
|
37 | + public static function hashEncode($value) { |
|
38 | + return password_hash($value, PASSWORD_DEFAULT); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param $array |
|
43 | - */ |
|
44 | - public static function secure(&$array) { |
|
45 | - if (isset($array)) { |
|
46 | - foreach ($array as $key => $value) { |
|
47 | - if (is_array($array[$key])) { |
|
48 | - self::secure($array[$key]); |
|
49 | - } else { |
|
50 | - $array[$key] = trim($array[$key]); |
|
51 | - $array[$key] = htmlspecialchars($array[$key], ENT_QUOTES, 'UTF-8'); |
|
52 | - $array[$key] = strip_tags($array[$key]); |
|
53 | - $array[$key] = addslashes($array[$key]); |
|
54 | - $array[$key] = filter_var($array[$key], FILTER_SANITIZE_STRING); |
|
55 | - $array[$key] = html_entity_decode($array[$key], ENT_COMPAT, 'UTF-8'); |
|
56 | - } |
|
57 | - } |
|
58 | - } |
|
59 | - } |
|
41 | + /** |
|
42 | + * @param $array |
|
43 | + */ |
|
44 | + public static function secure(&$array) { |
|
45 | + if (isset($array)) { |
|
46 | + foreach ($array as $key => $value) { |
|
47 | + if (is_array($array[$key])) { |
|
48 | + self::secure($array[$key]); |
|
49 | + } else { |
|
50 | + $array[$key] = trim($array[$key]); |
|
51 | + $array[$key] = htmlspecialchars($array[$key], ENT_QUOTES, 'UTF-8'); |
|
52 | + $array[$key] = strip_tags($array[$key]); |
|
53 | + $array[$key] = addslashes($array[$key]); |
|
54 | + $array[$key] = filter_var($array[$key], FILTER_SANITIZE_STRING); |
|
55 | + $array[$key] = html_entity_decode($array[$key], ENT_COMPAT, 'UTF-8'); |
|
56 | + } |
|
57 | + } |
|
58 | + } |
|
59 | + } |
|
60 | 60 | } |
61 | 61 | \ No newline at end of file |
@@ -21,7 +21,7 @@ |
||
21 | 21 | return self::$instance; |
22 | 22 | } |
23 | 23 | |
24 | - /** |
|
24 | + /** |
|
25 | 25 | * @param $data |
26 | 26 | * |
27 | 27 | * @return int |
@@ -9,20 +9,20 @@ |
||
9 | 9 | |
10 | 10 | class Json |
11 | 11 | { |
12 | - /** |
|
13 | - * @param $json |
|
14 | - * @param bool $group |
|
15 | - * |
|
16 | - * @return string |
|
17 | - */ |
|
18 | - public static function encode($json, $group = false) |
|
19 | - { |
|
20 | - $jsonSafed = []; |
|
21 | - if ($group) { |
|
22 | - $jsonSafed[$group] = $json; |
|
23 | - } else { |
|
24 | - $jsonSafed = $json; |
|
25 | - } |
|
26 | - return json_encode($jsonSafed, JSON_HEX_QUOT | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_PRETTY_PRINT); |
|
27 | - } |
|
12 | + /** |
|
13 | + * @param $json |
|
14 | + * @param bool $group |
|
15 | + * |
|
16 | + * @return string |
|
17 | + */ |
|
18 | + public static function encode($json, $group = false) |
|
19 | + { |
|
20 | + $jsonSafed = []; |
|
21 | + if ($group) { |
|
22 | + $jsonSafed[$group] = $json; |
|
23 | + } else { |
|
24 | + $jsonSafed = $json; |
|
25 | + } |
|
26 | + return json_encode($jsonSafed, JSON_HEX_QUOT | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_PRETTY_PRINT); |
|
27 | + } |
|
28 | 28 | } |
29 | 29 | \ No newline at end of file |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | class Utils extends Controller{ |
8 | 8 | |
9 | 9 | private static $instance; |
10 | - public $debug; |
|
10 | + public $debug; |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * @return Utils |
@@ -21,33 +21,33 @@ discard block |
||
21 | 21 | return self::$instance; |
22 | 22 | } |
23 | 23 | |
24 | - /** |
|
25 | - * @param $useragent |
|
26 | - * |
|
27 | - * @return bool |
|
28 | - */ |
|
29 | - public static function detect_mobile($useragent) |
|
30 | - { |
|
31 | - if (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $useragent) || preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', substr($useragent, 0, 4))) { |
|
32 | - return true; |
|
33 | - } else { |
|
34 | - return false; |
|
35 | - } |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * @param $email |
|
40 | - * |
|
41 | - * @return bool |
|
42 | - */ |
|
43 | - public static function is_email($email) |
|
44 | - { |
|
45 | - if (filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
46 | - return true; |
|
47 | - } else { |
|
48 | - return false; |
|
49 | - } |
|
50 | - } |
|
24 | + /** |
|
25 | + * @param $useragent |
|
26 | + * |
|
27 | + * @return bool |
|
28 | + */ |
|
29 | + public static function detect_mobile($useragent) |
|
30 | + { |
|
31 | + if (preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $useragent) || preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i', substr($useragent, 0, 4))) { |
|
32 | + return true; |
|
33 | + } else { |
|
34 | + return false; |
|
35 | + } |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * @param $email |
|
40 | + * |
|
41 | + * @return bool |
|
42 | + */ |
|
43 | + public static function is_email($email) |
|
44 | + { |
|
45 | + if (filter_var($email, FILTER_VALIDATE_EMAIL)) { |
|
46 | + return true; |
|
47 | + } else { |
|
48 | + return false; |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @param $rawData |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | return $string; |
70 | 70 | } |
71 | 71 | |
72 | - /** |
|
73 | - * @param $uri |
|
74 | - */ |
|
75 | - public function active($uri){ |
|
76 | - echo (str_replace('/','.',substr($_SERVER['REQUEST_URI'], 1)) == $uri)? "class='active'" : ""; |
|
77 | - } |
|
72 | + /** |
|
73 | + * @param $uri |
|
74 | + */ |
|
75 | + public function active($uri){ |
|
76 | + echo (str_replace('/','.',substr($_SERVER['REQUEST_URI'], 1)) == $uri)? "class='active'" : ""; |
|
77 | + } |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @return bool |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | } |
109 | 109 | |
110 | 110 | |
111 | - /** |
|
111 | + /** |
|
112 | 112 | * @param $data |
113 | 113 | * @param $key |
114 | 114 | * @param $iv |
@@ -151,46 +151,46 @@ discard block |
||
151 | 151 | return $res; |
152 | 152 | } |
153 | 153 | |
154 | - public static function setDebug($exceptionCode){ |
|
155 | - $exception = null; |
|
156 | - switch ($exceptionCode){ |
|
157 | - case 23000 : $exception = "Erro ao inserir os dados!"; break; |
|
158 | - } |
|
159 | - $print = "<div class='debug'>"; |
|
160 | - $print .= $exception; |
|
161 | - $print .= "</div>"; |
|
162 | - self::getInstance()->debug = $print; |
|
163 | - } |
|
164 | - |
|
165 | - public static function getDebug(){ |
|
166 | - echo self::getInstance()->debug; |
|
167 | - } |
|
168 | - |
|
169 | - /** |
|
170 | - * @param int $length |
|
171 | - * |
|
172 | - * @return string |
|
173 | - */ |
|
174 | - public static function generateToken($length = 20) { |
|
175 | - if(function_exists('openssl_random_pseudo_bytes')) { |
|
176 | - $token = base64_encode(openssl_random_pseudo_bytes($length, $strong)); |
|
177 | - if($strong == TRUE) |
|
178 | - return strtr(substr($token, 0, $length), '+/=', '-_,'); |
|
179 | - } |
|
180 | - |
|
181 | - $characters = '0123456789'; |
|
182 | - $characters .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
|
183 | - $charactersLength = strlen($characters)-1; |
|
184 | - $token = ''; |
|
185 | - |
|
186 | - for ($i = 0; $i < $length; $i++) { |
|
187 | - $token .= $characters[mt_rand(0, $charactersLength)]; |
|
188 | - } |
|
189 | - |
|
190 | - return $token; |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
154 | + public static function setDebug($exceptionCode){ |
|
155 | + $exception = null; |
|
156 | + switch ($exceptionCode){ |
|
157 | + case 23000 : $exception = "Erro ao inserir os dados!"; break; |
|
158 | + } |
|
159 | + $print = "<div class='debug'>"; |
|
160 | + $print .= $exception; |
|
161 | + $print .= "</div>"; |
|
162 | + self::getInstance()->debug = $print; |
|
163 | + } |
|
164 | + |
|
165 | + public static function getDebug(){ |
|
166 | + echo self::getInstance()->debug; |
|
167 | + } |
|
168 | + |
|
169 | + /** |
|
170 | + * @param int $length |
|
171 | + * |
|
172 | + * @return string |
|
173 | + */ |
|
174 | + public static function generateToken($length = 20) { |
|
175 | + if(function_exists('openssl_random_pseudo_bytes')) { |
|
176 | + $token = base64_encode(openssl_random_pseudo_bytes($length, $strong)); |
|
177 | + if($strong == TRUE) |
|
178 | + return strtr(substr($token, 0, $length), '+/=', '-_,'); |
|
179 | + } |
|
180 | + |
|
181 | + $characters = '0123456789'; |
|
182 | + $characters .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; |
|
183 | + $charactersLength = strlen($characters)-1; |
|
184 | + $token = ''; |
|
185 | + |
|
186 | + for ($i = 0; $i < $length; $i++) { |
|
187 | + $token .= $characters[mt_rand(0, $charactersLength)]; |
|
188 | + } |
|
189 | + |
|
190 | + return $token; |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | 194 | * @param $data |
195 | 195 | * @param $key |
196 | 196 | * @param $iv |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | } |
236 | 236 | |
237 | 237 | |
238 | - /** |
|
238 | + /** |
|
239 | 239 | * @param $expires |
240 | 240 | * @param $secret |
241 | 241 | * |
@@ -5,138 +5,138 @@ |
||
5 | 5 | |
6 | 6 | class Paginate extends Controller |
7 | 7 | { |
8 | - public $perPage, $currentPage, $total , $maxPage , $items , $skip; |
|
9 | - |
|
10 | - /** |
|
11 | - * Paginate constructor. |
|
12 | - */ |
|
13 | - public function __construct() { |
|
14 | - parent::__construct(); |
|
15 | - $this->setCurrentPage((isset($_GET['page']))?$_GET['page']:1); |
|
16 | - } |
|
17 | - |
|
18 | - /** |
|
19 | - * @return mixed |
|
20 | - */ |
|
21 | - public function getItems() |
|
22 | - { |
|
23 | - return $this->items; |
|
24 | - } |
|
25 | - |
|
26 | - /** |
|
27 | - * @return mixed |
|
28 | - */ |
|
29 | - public function getSkip() |
|
30 | - { |
|
31 | - return $this->skip; |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * @return mixed |
|
36 | - */ |
|
37 | - public function getCurrentPage() |
|
38 | - { |
|
39 | - return $this->currentPage; |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * @return mixed |
|
44 | - */ |
|
45 | - public function getMaxPages() |
|
46 | - { |
|
47 | - return $this->maxPage; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * @return mixed |
|
52 | - */ |
|
53 | - public function getPerPage() |
|
54 | - { |
|
55 | - return $this->perPage; |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @return mixed |
|
60 | - */ |
|
61 | - public function getTotal() |
|
62 | - { |
|
63 | - return $this->total; |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * @param $skip |
|
68 | - */ |
|
69 | - public function setSkip($skip) |
|
70 | - { |
|
71 | - $this->skip = $skip; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @param $items |
|
76 | - */ |
|
77 | - public function setItems($items) |
|
78 | - { |
|
79 | - $count = ceil($items->count()/$this->getPerPage()); |
|
80 | - $maxPages = (!empty($this->getMaxPages()) && $count >$this->getMaxPages())?$this->getMaxPages():$count; |
|
81 | - $this->setTotal($maxPages); |
|
82 | - $this->setSkip(($this->getCurrentPage()*$this->getPerPage())-$this->getPerPage()); |
|
83 | - $this->items = $items->skip($this->getSkip())->limit($this->getPerPage())->get(); |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * @param $currentPage |
|
88 | - */ |
|
89 | - public function setCurrentPage($currentPage) |
|
90 | - { |
|
91 | - $this->currentPage = $currentPage; |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * @param $maxPage |
|
96 | - */ |
|
97 | - public function setMaxPages($maxPage) |
|
98 | - { |
|
99 | - $this->maxPage = $maxPage; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * @param $perPage |
|
104 | - */ |
|
105 | - public function setPerPage($perPage) |
|
106 | - { |
|
107 | - $this->perPage = $perPage; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * @param $total |
|
112 | - */ |
|
113 | - public function setTotal($total) |
|
114 | - { |
|
115 | - $this->total = $total; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - public function paginate(){ |
|
120 | - if($this->getTotal() != 1) { |
|
121 | - echo /** @lang text */ '<ul class="pagination">'; |
|
122 | - if($this->getCurrentPage() > 1){ |
|
123 | - echo /** @lang text */ '<li><a href="?page='.($this->getCurrentPage()-1).'" aria-label="Previous"><span aria-hidden="true">Anterior</span></a></li>'; |
|
124 | - }else{ |
|
125 | - echo /** @lang text */ '<li class="disabled"><a aria-label="Previous"><span aria-hidden="true">Anterior</span></a></li>'; |
|
126 | - } |
|
127 | - |
|
128 | - for ($i = 1; $i <= $this->getTotal(); $i++) { |
|
129 | - |
|
130 | - $active = ($this->getCurrentPage() == $i) ? 'class="active"' : ''; |
|
131 | - |
|
132 | - echo '<li ' . $active . '><a href="?page=' . $i . '">' . $i . '</a></li>'; |
|
133 | - } |
|
134 | - if($this->getCurrentPage() < $this->getTotal()){ |
|
135 | - echo /** @lang text */ '<li><a href="?page='.($this->getCurrentPage()+1).'" aria-label="Next"><span aria-hidden="true">Próxima</span></a></li>'; |
|
136 | - }else{ |
|
137 | - echo /** @lang text */ '<li class="disabled"><a aria-label="Next"><span aria-hidden="true">Próxima</span></a></li>'; |
|
138 | - } |
|
139 | - echo '</ul>'; |
|
140 | - } |
|
141 | - } |
|
8 | + public $perPage, $currentPage, $total , $maxPage , $items , $skip; |
|
9 | + |
|
10 | + /** |
|
11 | + * Paginate constructor. |
|
12 | + */ |
|
13 | + public function __construct() { |
|
14 | + parent::__construct(); |
|
15 | + $this->setCurrentPage((isset($_GET['page']))?$_GET['page']:1); |
|
16 | + } |
|
17 | + |
|
18 | + /** |
|
19 | + * @return mixed |
|
20 | + */ |
|
21 | + public function getItems() |
|
22 | + { |
|
23 | + return $this->items; |
|
24 | + } |
|
25 | + |
|
26 | + /** |
|
27 | + * @return mixed |
|
28 | + */ |
|
29 | + public function getSkip() |
|
30 | + { |
|
31 | + return $this->skip; |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * @return mixed |
|
36 | + */ |
|
37 | + public function getCurrentPage() |
|
38 | + { |
|
39 | + return $this->currentPage; |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * @return mixed |
|
44 | + */ |
|
45 | + public function getMaxPages() |
|
46 | + { |
|
47 | + return $this->maxPage; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * @return mixed |
|
52 | + */ |
|
53 | + public function getPerPage() |
|
54 | + { |
|
55 | + return $this->perPage; |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @return mixed |
|
60 | + */ |
|
61 | + public function getTotal() |
|
62 | + { |
|
63 | + return $this->total; |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * @param $skip |
|
68 | + */ |
|
69 | + public function setSkip($skip) |
|
70 | + { |
|
71 | + $this->skip = $skip; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @param $items |
|
76 | + */ |
|
77 | + public function setItems($items) |
|
78 | + { |
|
79 | + $count = ceil($items->count()/$this->getPerPage()); |
|
80 | + $maxPages = (!empty($this->getMaxPages()) && $count >$this->getMaxPages())?$this->getMaxPages():$count; |
|
81 | + $this->setTotal($maxPages); |
|
82 | + $this->setSkip(($this->getCurrentPage()*$this->getPerPage())-$this->getPerPage()); |
|
83 | + $this->items = $items->skip($this->getSkip())->limit($this->getPerPage())->get(); |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * @param $currentPage |
|
88 | + */ |
|
89 | + public function setCurrentPage($currentPage) |
|
90 | + { |
|
91 | + $this->currentPage = $currentPage; |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * @param $maxPage |
|
96 | + */ |
|
97 | + public function setMaxPages($maxPage) |
|
98 | + { |
|
99 | + $this->maxPage = $maxPage; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * @param $perPage |
|
104 | + */ |
|
105 | + public function setPerPage($perPage) |
|
106 | + { |
|
107 | + $this->perPage = $perPage; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * @param $total |
|
112 | + */ |
|
113 | + public function setTotal($total) |
|
114 | + { |
|
115 | + $this->total = $total; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + public function paginate(){ |
|
120 | + if($this->getTotal() != 1) { |
|
121 | + echo /** @lang text */ '<ul class="pagination">'; |
|
122 | + if($this->getCurrentPage() > 1){ |
|
123 | + echo /** @lang text */ '<li><a href="?page='.($this->getCurrentPage()-1).'" aria-label="Previous"><span aria-hidden="true">Anterior</span></a></li>'; |
|
124 | + }else{ |
|
125 | + echo /** @lang text */ '<li class="disabled"><a aria-label="Previous"><span aria-hidden="true">Anterior</span></a></li>'; |
|
126 | + } |
|
127 | + |
|
128 | + for ($i = 1; $i <= $this->getTotal(); $i++) { |
|
129 | + |
|
130 | + $active = ($this->getCurrentPage() == $i) ? 'class="active"' : ''; |
|
131 | + |
|
132 | + echo '<li ' . $active . '><a href="?page=' . $i . '">' . $i . '</a></li>'; |
|
133 | + } |
|
134 | + if($this->getCurrentPage() < $this->getTotal()){ |
|
135 | + echo /** @lang text */ '<li><a href="?page='.($this->getCurrentPage()+1).'" aria-label="Next"><span aria-hidden="true">Próxima</span></a></li>'; |
|
136 | + }else{ |
|
137 | + echo /** @lang text */ '<li class="disabled"><a aria-label="Next"><span aria-hidden="true">Próxima</span></a></li>'; |
|
138 | + } |
|
139 | + echo '</ul>'; |
|
140 | + } |
|
141 | + } |
|
142 | 142 | } |
143 | 143 | \ No newline at end of file |
@@ -20,20 +20,20 @@ discard block |
||
20 | 20 | |
21 | 21 | public function __construct() |
22 | 22 | { |
23 | - $di_builder = new ContainerBuilder(); |
|
24 | - $di_builder->useAutowiring(true); |
|
25 | - $this->di = $di_builder->build(); |
|
23 | + $di_builder = new ContainerBuilder(); |
|
24 | + $di_builder->useAutowiring(true); |
|
25 | + $this->di = $di_builder->build(); |
|
26 | 26 | $this->session = new Session(); |
27 | 27 | try{ |
28 | - $this->capsuleDb = new Capsule(); |
|
29 | - $this->capsuleDb->addConnection(Config::get('database.providers.pdo')); |
|
30 | - $this->capsuleDb->setEventDispatcher(new Dispatcher(new Container)); |
|
31 | - $this->capsuleDb->bootEloquent(); |
|
32 | - $this->capsuleDb->setAsGlobal(); |
|
33 | - $this->db = $this->capsuleDb->getConnection(); |
|
34 | - }catch (\PDOException $exc){ |
|
35 | - die("Database ".Config::get('database.providers.pdo.database')." not found"); |
|
36 | - } |
|
28 | + $this->capsuleDb = new Capsule(); |
|
29 | + $this->capsuleDb->addConnection(Config::get('database.providers.pdo')); |
|
30 | + $this->capsuleDb->setEventDispatcher(new Dispatcher(new Container)); |
|
31 | + $this->capsuleDb->bootEloquent(); |
|
32 | + $this->capsuleDb->setAsGlobal(); |
|
33 | + $this->db = $this->capsuleDb->getConnection(); |
|
34 | + }catch (\PDOException $exc){ |
|
35 | + die("Database ".Config::get('database.providers.pdo.database')." not found"); |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | return header('location: /' . $url); |
77 | 77 | } |
78 | 78 | |
79 | - /** |
|
80 | - * @return bool|mixed |
|
81 | - */ |
|
82 | - public function run() |
|
79 | + /** |
|
80 | + * @return bool|mixed |
|
81 | + */ |
|
82 | + public function run() |
|
83 | 83 | { |
84 | 84 | try { |
85 | 85 | |
@@ -107,12 +107,12 @@ discard block |
||
107 | 107 | $controllerParams[$paramName] = $paramValue; |
108 | 108 | } |
109 | 109 | } |
110 | - $controllerFullName = "\\App\\Controllers\\" . $routerParams["_controller"]; |
|
111 | - try{ |
|
112 | - return $this->di->call($controllerFullName."::".$routerParams["_method"], $controllerParams); |
|
113 | - }catch (Exception $e){ |
|
114 | - new ExceptionHandler($e); |
|
115 | - } |
|
110 | + $controllerFullName = "\\App\\Controllers\\" . $routerParams["_controller"]; |
|
111 | + try{ |
|
112 | + return $this->di->call($controllerFullName."::".$routerParams["_method"], $controllerParams); |
|
113 | + }catch (Exception $e){ |
|
114 | + new ExceptionHandler($e); |
|
115 | + } |
|
116 | 116 | |
117 | 117 | } catch (Exception $e) { |
118 | 118 | new ExceptionHandler($e); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return true; |
122 | 122 | } |
123 | 123 | |
124 | - /** |
|
124 | + /** |
|
125 | 125 | * @param $routerParams |
126 | 126 | */ |
127 | 127 | private function handleMiddlewares($routerParams) |
@@ -15,12 +15,12 @@ discard block |
||
15 | 15 | |
16 | 16 | protected $blade; |
17 | 17 | |
18 | - public $framework , $request , $response , $params; |
|
18 | + public $framework , $request , $response , $params; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Controller constructor. |
|
22 | - */ |
|
23 | - public function __construct() { |
|
20 | + /** |
|
21 | + * Controller constructor. |
|
22 | + */ |
|
23 | + public function __construct() { |
|
24 | 24 | parent::__construct(); |
25 | 25 | |
26 | 26 | $this->framework= (object) Config::get('framework'); |
@@ -29,126 +29,126 @@ discard block |
||
29 | 29 | } |
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @return View |
|
34 | - */ |
|
35 | - public function _404() { |
|
36 | - return $this->view("error.404"); |
|
37 | - } |
|
32 | + /** |
|
33 | + * @return View |
|
34 | + */ |
|
35 | + public function _404() { |
|
36 | + return $this->view("error.404"); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @param $view |
|
42 | + * @param null $params |
|
43 | + * |
|
44 | + * @return View |
|
45 | + */ |
|
46 | + public function view($view, $params = null) { |
|
47 | + $render = View::getInstance(); |
|
48 | + $render->render($view,$params); |
|
49 | + |
|
50 | + return $render; |
|
51 | + } |
|
38 | 52 | |
39 | 53 | |
40 | - /** |
|
41 | - * @param $view |
|
42 | - * @param null $params |
|
43 | - * |
|
44 | - * @return View |
|
45 | - */ |
|
46 | - public function view($view, $params = null) { |
|
47 | - $render = View::getInstance(); |
|
48 | - $render->render($view,$params); |
|
54 | + /** |
|
55 | + * Determine if the uploaded data contains a file. |
|
56 | + * |
|
57 | + * @param string $key |
|
58 | + * @param null $default |
|
59 | + * |
|
60 | + * @return bool |
|
61 | + */ |
|
62 | + public function getFile($key = null, $default = null) { |
|
63 | + return $this->request->capture()->file($key, $default); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Determine if the uploaded data contains a file. |
|
68 | + * |
|
69 | + * @param string $key |
|
70 | + * @return bool |
|
71 | + */ |
|
72 | + public function hasFile($key) { |
|
73 | + if($this->request->capture()->hasFile($key)){ |
|
74 | + return $this->request->capture()->file($key); |
|
75 | + }else{ |
|
76 | + return $this->request->capture()->hasFile($key); |
|
77 | + } |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Checks if the request method is of specified type. |
|
82 | + * |
|
83 | + * @param string $method Uppercase request method (GET, POST etc). |
|
84 | + * |
|
85 | + * @return bool |
|
86 | + */ |
|
87 | + public function isMethod($method){ |
|
88 | + return $this->request->capture()->isMethod($method); |
|
89 | + } |
|
49 | 90 | |
50 | - return $render; |
|
91 | + /** |
|
92 | + * Get the request method. |
|
93 | + * |
|
94 | + * @return string |
|
95 | + */ |
|
96 | + public function method(){ |
|
97 | + return $this->request->capture()->method(); |
|
51 | 98 | } |
52 | 99 | |
53 | 100 | |
54 | - /** |
|
55 | - * Determine if the uploaded data contains a file. |
|
56 | - * |
|
57 | - * @param string $key |
|
58 | - * @param null $default |
|
59 | - * |
|
60 | - * @return bool |
|
61 | - */ |
|
62 | - public function getFile($key = null, $default = null) { |
|
63 | - return $this->request->capture()->file($key, $default); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Determine if the uploaded data contains a file. |
|
68 | - * |
|
69 | - * @param string $key |
|
70 | - * @return bool |
|
71 | - */ |
|
72 | - public function hasFile($key) { |
|
73 | - if($this->request->capture()->hasFile($key)){ |
|
74 | - return $this->request->capture()->file($key); |
|
75 | - }else{ |
|
76 | - return $this->request->capture()->hasFile($key); |
|
77 | - } |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Checks if the request method is of specified type. |
|
82 | - * |
|
83 | - * @param string $method Uppercase request method (GET, POST etc). |
|
84 | - * |
|
85 | - * @return bool |
|
86 | - */ |
|
87 | - public function isMethod($method){ |
|
88 | - return $this->request->capture()->isMethod($method); |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Get the request method. |
|
93 | - * |
|
94 | - * @return string |
|
95 | - */ |
|
96 | - public function method(){ |
|
97 | - return $this->request->capture()->method(); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - /** |
|
102 | - * Retrieve an input item from the request. |
|
103 | - * |
|
104 | - * @param string $key |
|
105 | - * @param string|array|null $default |
|
106 | - * @return string|array |
|
107 | - */ |
|
108 | - public function input($key = null, $default = null) { |
|
109 | - return $this->request->capture()->input($key , $default); |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Determine if the request contains a given input item key. |
|
114 | - * |
|
115 | - * @param $string |
|
116 | - * |
|
117 | - * @return bool |
|
118 | - * @internal param array|string $key |
|
119 | - */ |
|
120 | - public function exists($string) { |
|
121 | - return $this->request->capture()->has($string); |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Get all of the input and files for the request. |
|
126 | - * |
|
127 | - * @return array |
|
128 | - */ |
|
129 | - public function all() { |
|
130 | - return $this->request->all(); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Get the JSON payload for the request. |
|
135 | - * |
|
136 | - * @param string $key |
|
137 | - * @param mixed $default |
|
138 | - * @return mixed |
|
139 | - */ |
|
140 | - public function json($key = null, $default = null){ |
|
141 | - return $this->request->json($key, $default); |
|
142 | - } |
|
143 | - |
|
144 | - /** |
|
145 | - * Determine if the request is the result of an AJAX call. |
|
146 | - * |
|
147 | - * @return bool |
|
148 | - */ |
|
149 | - public function ajax(){ |
|
150 | - return $this->request->json(); |
|
151 | - } |
|
101 | + /** |
|
102 | + * Retrieve an input item from the request. |
|
103 | + * |
|
104 | + * @param string $key |
|
105 | + * @param string|array|null $default |
|
106 | + * @return string|array |
|
107 | + */ |
|
108 | + public function input($key = null, $default = null) { |
|
109 | + return $this->request->capture()->input($key , $default); |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Determine if the request contains a given input item key. |
|
114 | + * |
|
115 | + * @param $string |
|
116 | + * |
|
117 | + * @return bool |
|
118 | + * @internal param array|string $key |
|
119 | + */ |
|
120 | + public function exists($string) { |
|
121 | + return $this->request->capture()->has($string); |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Get all of the input and files for the request. |
|
126 | + * |
|
127 | + * @return array |
|
128 | + */ |
|
129 | + public function all() { |
|
130 | + return $this->request->all(); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Get the JSON payload for the request. |
|
135 | + * |
|
136 | + * @param string $key |
|
137 | + * @param mixed $default |
|
138 | + * @return mixed |
|
139 | + */ |
|
140 | + public function json($key = null, $default = null){ |
|
141 | + return $this->request->json($key, $default); |
|
142 | + } |
|
143 | + |
|
144 | + /** |
|
145 | + * Determine if the request is the result of an AJAX call. |
|
146 | + * |
|
147 | + * @return bool |
|
148 | + */ |
|
149 | + public function ajax(){ |
|
150 | + return $this->request->json(); |
|
151 | + } |
|
152 | 152 | |
153 | 153 | |
154 | 154 | } |
155 | 155 | \ No newline at end of file |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | private $config_path; |
10 | 10 | |
11 | 11 | public function __construct() { |
12 | - $this->config_array = []; |
|
13 | - $this->config_path = ROOT_APP.'Config'.DS; |
|
14 | - $this->make(); |
|
12 | + $this->config_array = []; |
|
13 | + $this->config_path = ROOT_APP.'Config'.DS; |
|
14 | + $this->make(); |
|
15 | 15 | } |
16 | 16 | /** |
17 | 17 | * @return Config |
@@ -23,20 +23,20 @@ discard block |
||
23 | 23 | return self::$instance; |
24 | 24 | } |
25 | 25 | |
26 | - /** |
|
27 | - * @param $key |
|
28 | - * @param $value |
|
29 | - */ |
|
30 | - public function set($key, $value) { |
|
26 | + /** |
|
27 | + * @param $key |
|
28 | + * @param $value |
|
29 | + */ |
|
30 | + public function set($key, $value) { |
|
31 | 31 | $this->config_array[$key] = $value; |
32 | 32 | } |
33 | 33 | |
34 | - /** |
|
35 | - * @param $keys |
|
36 | - * |
|
37 | - * @return array|mixed|null |
|
38 | - */ |
|
39 | - public static function get($keys) { |
|
34 | + /** |
|
35 | + * @param $keys |
|
36 | + * |
|
37 | + * @return array|mixed|null |
|
38 | + */ |
|
39 | + public static function get($keys) { |
|
40 | 40 | $keys = explode('.', $keys); |
41 | 41 | $tmp = self::getInstance()->config_array; |
42 | 42 | foreach ($keys as $key) { |
@@ -45,19 +45,19 @@ discard block |
||
45 | 45 | return $tmp; |
46 | 46 | } |
47 | 47 | |
48 | - /** |
|
49 | - * @param $array |
|
50 | - */ |
|
51 | - public function addConfigs($array) { |
|
48 | + /** |
|
49 | + * @param $array |
|
50 | + */ |
|
51 | + public function addConfigs($array) { |
|
52 | 52 | foreach ($array as $key => $value) { |
53 | 53 | $this->config_array[$key] = $value; |
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | - /** |
|
58 | - * @return array |
|
59 | - */ |
|
60 | - public function make() { |
|
57 | + /** |
|
58 | + * @return array |
|
59 | + */ |
|
60 | + public function make() { |
|
61 | 61 | $view = include $this->config_path.'views.php'; |
62 | 62 | $app = include $this->config_path.'app.php'; |
63 | 63 | $database = include $this->config_path.'database.php'; |
@@ -66,6 +66,6 @@ discard block |
||
66 | 66 | $this->config_array['app'] = $app; |
67 | 67 | $this->config_array['database'] = $database; |
68 | 68 | $this->config_array['mail'] = $mail; |
69 | - return $this->config_array; |
|
69 | + return $this->config_array; |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | \ No newline at end of file |