{"action":"created","issue":{"url":"https://api.github.com/repos/brunosantoshx/treinamento-php-activerecord/issues/2","repository_url":"https://api.github.com/repos/brunosantoshx/treinamento-php-activerecord","labels_url":"https://api.github.com/repos/brunosantoshx/treinamento-php-activerecord/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/brunosantoshx/treinamento-php-activerecord/issues/2/comments","events_url":"https://api.github.com/repos/brunosantoshx/treinamento-php-activerecord/issues/2/events","html_url":"https://github.com/brunosantoshx/treinamento-php-activerecord/issues/2","id":171072003,"number":2,"title":"CRUD - read and searchbar","user":{"login":"Japy88","id":19801482,"avatar_url":"https://avatars.githubusercontent.com/u/19801482?v=3","gravatar_id":"","url":"https://api.github.com/users/Japy88","html_url":"https://github.com/Japy88","followers_url":"https://api.github.com/users/Japy88/followers","following_url":"https://api.github.com/users/Japy88/following{/other_user}","gists_url":"https://api.github.com/users/Japy88/gists{/gist_id}","starred_url":"https://api.github.com/users/Japy88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Japy88/subscriptions","organizations_url":"https://api.github.com/users/Japy88/orgs","repos_url":"https://api.github.com/users/Japy88/repos","events_url":"https://api.github.com/users/Japy88/events{/privacy}","received_events_url":"https://api.github.com/users/Japy88/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-14T18:36:47Z","updated_at":"2016-08-18T03:05:43Z","closed_at":"2016-08-16T20:17:09Z","body":"Boas Bruno,\r\nDesde já deixa-me dizer que o programa de cadastramento está brutal, desde as tuas explicações ao próprio conteúdo.\r\nNo entanto, faz um ano desde que fizeste a rubrica do php-activerecord e a estrutura não é a mesma. Consegui introduzir dados no phpmyadmin através de formulário, mas não sei como visualizá-los nem como associar à barra de pesquisa.\r\nAbraço e continua com o bom trabalho."},"comment":{"url":"https://api.github.com/repos/brunosantoshx/treinamento-php-activerecord/issues/comments/240611926","html_url":"https://github.com/brunosantoshx/treinamento-php-activerecord/issues/2#issuecomment-240611926","issue_url":"https://api.github.com/repos/brunosantoshx/treinamento-php-activerecord/issues/2","id":240611926,"user":{"login":"Japy88","id":19801482,"avatar_url":"https://avatars.githubusercontent.com/u/19801482?v=3","gravatar_id":"","url":"https://api.github.com/users/Japy88","html_url":"https://github.com/Japy88","followers_url":"https://api.github.com/users/Japy88/followers","following_url":"https://api.github.com/users/Japy88/following{/other_user}","gists_url":"https://api.github.com/users/Japy88/gists{/gist_id}","starred_url":"https://api.github.com/users/Japy88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Japy88/subscriptions","organizations_url":"https://api.github.com/users/Japy88/orgs","repos_url":"https://api.github.com/users/Japy88/repos","events_url":"https://api.github.com/users/Japy88/events{/privacy}","received_events_url":"https://api.github.com/users/Japy88/received_events","type":"User","site_admin":false},"created_at":"2016-08-18T03:05:42Z","updated_at":"2016-08-18T03:05:42Z","body":"Boas Bruno,\n\n\nTentei fazer o que me disseste mas aparece um erro:\n\n\nFatal error: Uncaught exception 'ActiveRecord\\ActiveRecordException' with message 'Call to undefined method: procurarCliente' in C:\\xampp\\htdocs\\Iurisdb\\vendor\\php-activerecord\\php-activerecord\\lib\\Model.php:1401 Stack trace: #0 C:\\xampp\\htdocs\\Iurisdb\\app\\controllers\\VisualizarController.php(43): ActiveRecord\\Model::__callStatic('procurarCliente', Array) #1 C:\\xampp\\htdocs\\Iurisdb\\app\\controllers\\VisualizarController.php(43): Client::procurarCliente(NULL) #2 [internal function]: VisualizarController->lerAction() #3 C:\\xampp\\htdocs\\Iurisdb\\src\\HXPHP\\System\\App.php(103): call_user_func_array(Array, Array) #4 C:\\xampp\\htdocs\\Iurisdb\\index.php(36): HXPHP\\System\\App->run() #5 {main} thrown in C:\\xampp\\htdocs\\Iurisdb\\vendor\\php-activerecord\\php-activerecord\\lib\\Model.php on line 1401.\n\n\nCriei este model:\n\n\n<?php\n\nclass Require extends \\HXPHP\\System\\Model\n{\n        public static function todosClientes()\n    {\n        return self::all();\n    }\n\n    public static function procurarCliente($stringPesquisa)\n    {\n        // Uso do LIKE %...%\n        $search = self::all([\n            'conditions' => [\n                'name LIKE ? OR description LIKE ?',\n                '%' . $stringPesquisa . '%',\n                '%' . $stringPesquisa . '%'\n            ]\n        ]);\n\n        return $search;\n    }\n}\n\n\n// Controller\n\n\n<?php\n\nclass VisualizarController extends \\HXPHP\\System\\Controller\n{\n    public function __construct($configs)\n    {\n        parent::__construct($configs);\n\n        $this->load(\n            'Services\\Auth',\n            $configs->auth->after_login,\n            $configs->auth->after_logout,\n            true\n        );\n\n        $this->auth->redirectCheck();\n\n        $this->load(\n            'Helpers\\Menu',\n            $this->request,\n            $this->configs,\n            $this->auth->getUserRole()\n        );\n\n        $user_id = $this->auth->getUserId();\n\n        $this->view->setTitle('Iurisdb - Home')\n                    ->setVar('user', User::find($user_id));\n    }\n\n    public function bloqueadaAction()\n    {\n        $this->auth->roleCheck([\n            'administrator',\n            'user'\n        ]);\n    }\n\n    public function lerAction()\n    {\n        $this->view->setFile('index');\n\n        $search_results = Client::procurarCliente($this->request->get('search'));\n        $this->view->setVar('search_results', $search_results);\n\n        if ($view_search_results) :\n          foreach ($view_search_results as $product) :\n        echo $product->title;\n          endforeach;\n        endif;\n      }\n}\n\n\n// View\n\n<head>\n<?php\n    echo isset($this->menu) ? $this->menu->getMenu() : '';\n?>\n</head>\n\n\n<script>\nfunction showResult(str) {\n  if (str.length==0) {\n    document.getElementById(\"livesearch\").innerHTML=\"\";\n    document.getElementById(\"livesearch\").style.border=\"0px\";\n    return;\n  }\n  if (window.XMLHttpRequest) {\n    // code for IE7+, Firefox, Chrome, Opera, Safari\n    xmlhttp=new XMLHttpRequest();\n  } else {  // code for IE6, IE5\n    xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n  }\n  xmlhttp.onreadystatechange=function() {\n    if (xmlhttp.readyState==4 && xmlhttp.status==200) {\n      document.getElementById(\"livesearch\").innerHTML=xmlhttp.responseText;\n      document.getElementById(\"livesearch\").style.border=\"1px solid #A5ACB2\";\n    }\n  }\n  xmlhttp.open(\"GET\",\"livesearch.php?q=\"+str,true);\n  xmlhttp.send();\n}\n</script>\n</head>\n<body>\n\n<form>\n<input type=\"text\" class=\"form-control\" onkeyup=\"showResult(this.value)\">\n<div id=\"livesearch\"></div>\n</form>\n\n\nNão faço ideia de qual possa ser o erro... E já agora, o método GET pode ser criado no mesmo ficheiro que o POST? É que o objetivo é mostrar uma ficha de clientes e queria saber se o model de ligação à base de dados pode ser o mesmo para o POST e GET ou se preciso criar dois independentes.\n\nAbraço\n\n\n\n________________________________\nDe: Bruno Campos Santos <notifications@github.com>\nEnviado: terça-feira, 16 de agosto de 2016 21:20\nPara: brunosantoshx/treinamento-php-activerecord\nCc: Japy88; Mention\nAssunto: Re: [brunosantoshx/treinamento-php-activerecord] CRUD - read and searchbar (#2)\n\n\nE para exibir estes dados na view:\n\n  *   No controller você vai resgatar os dados do model e enviar para a view:\n\n$search_results = Product::buscarProduto($this->request->get('search'));\n$this->view->setVar('search_results', $search_results);\n\n  *   Na view você vai percorrer e exibir os dados:\n\nif ($view_search_results) :\n  foreach ($view_search_results as $product) :\n    echo $product->title;\n  endforeach;\nendif;\n\n-\nYou are receiving this because you were mentioned.\nReply to this email directly, view it on GitHub<https://github.com/brunosantoshx/treinamento-php-activerecord/issues/2#issuecomment-240225242>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AS4ligyI8xcxHKlxfkAwcu1on2pVnGP8ks5qghuIgaJpZM4Jj9NB>.\n"}}
{"actor":{"display_login":"Japy88"}}