<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comentários sobre Cleber Santos</title>
	<atom:link href="http://binho.net/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://binho.net</link>
	<description>um blog sobre desenvolvimento mobile e web.</description>
	<lastBuildDate>Thu, 16 Feb 2012 15:43:35 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>Comentário sobre Validando campos de data e hora no model do Laravel. por Felipo Antonoff Araújo</title>
		<link>http://binho.net/validando-campos-de-data-e-hora-no-model-do-laravel/#comment-16</link>
		<dc:creator>Felipo Antonoff Araújo</dc:creator>
		<pubDate>Thu, 16 Feb 2012 15:43:35 +0000</pubDate>
		<guid isPermaLink="false">http://binho.net/?p=34#comment-16</guid>
		<description>Oi, deu certo o jeito que você fez, apenas modifiquei um pouco para meu uso. O legal que deixa o Controlador mais limpo e fica mais organizado, pois podemos por funções no modelo, no qual ela representa.
Por exemplo um CRUD de usuários, no Model usuário e o Controller foca mais em  chamar as Views e usar os métodos do Model.</description>
		<content:encoded><![CDATA[<p>Oi, deu certo o jeito que você fez, apenas modifiquei um pouco para meu uso. O legal que deixa o Controlador mais limpo e fica mais organizado, pois podemos por funções no modelo, no qual ela representa.<br />
Por exemplo um CRUD de usuários, no Model usuário e o Controller foca mais em  chamar as Views e usar os métodos do Model.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comentário sobre Validando campos de data e hora no model do Laravel. por Felipo Antonoff Araújo</title>
		<link>http://binho.net/validando-campos-de-data-e-hora-no-model-do-laravel/#comment-15</link>
		<dc:creator>Felipo Antonoff Araújo</dc:creator>
		<pubDate>Thu, 16 Feb 2012 14:43:53 +0000</pubDate>
		<guid isPermaLink="false">http://binho.net/?p=34#comment-15</guid>
		<description>Oi, agradeço a ajuda, eu já havia conseguido, estava com problema para receber os erros, só conseguia receber individualmente coloquei o  $validator -&gt; errors -&gt; all(); , igual você fez e tinha dado certo. As vezes acho que a documentação do Laravel tem alguns erros e algumas coisas deixo de usar, como o Compositor, pois perco tempo demais fazendo funcionar (se funcionar) e o uso é desnecessário, logo opto por não usar.
No meu caso estou colocando a validação junto com o método que cadastra o cliente, mas creio que do seu modo fica mais organizado.</description>
		<content:encoded><![CDATA[<p>Oi, agradeço a ajuda, eu já havia conseguido, estava com problema para receber os erros, só conseguia receber individualmente coloquei o  $validator -&gt; errors -&gt; all(); , igual você fez e tinha dado certo. As vezes acho que a documentação do Laravel tem alguns erros e algumas coisas deixo de usar, como o Compositor, pois perco tempo demais fazendo funcionar (se funcionar) e o uso é desnecessário, logo opto por não usar.<br />
No meu caso estou colocando a validação junto com o método que cadastra o cliente, mas creio que do seu modo fica mais organizado.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comentário sobre Validando campos de data e hora no model do Laravel. por binho</title>
		<link>http://binho.net/validando-campos-de-data-e-hora-no-model-do-laravel/#comment-14</link>
		<dc:creator>binho</dc:creator>
		<pubDate>Mon, 06 Feb 2012 22:27:35 +0000</pubDate>
		<guid isPermaLink="false">http://binho.net/?p=34#comment-14</guid>
		<description>Olá Felipo!
Geralmente eu faço um método validateAndSave() dentro do model e no retorno eu faço algo tipo assim:

&lt;pre lang=&quot;PHP&quot;&gt;
public static function validateAndSave($promo=null)
{
	$rules = array(
		// aqui as regras
	);

	$messages = array(
		// aqui vai as mensagens
	);

	$validator = Validator::make( Input::get(), $rules, $messages );
	if ( $validator-&gt;valid() )
	{
		if (empty($promo)) {
			$promo = new self;
			$promo-&gt;user_id = Auth::user()-&gt;id;
		}

		$promo-&gt;store_id    = Input::get(&#039;store&#039;);
		$promo-&gt;product_id  = Input::get(&#039;product&#039;);
		$promo-&gt;name        = Input::get(&#039;name&#039;);
		$promo-&gt;save();
	}

	return $validator-&gt;errors-&gt;all();
}
&lt;/pre&gt;

Na controller eu verifico:

&lt;pre lang=&quot;PHP&quot;&gt;
$errors = Promo::validateAndSave();
if ( count($errors) &gt; 0 )
{
	return Redirect::to(&#039;/promo/add&#039;)
				   -&gt;with(&#039;message.errors&#039;, $errors);
}
&lt;/pre&gt;

Isso ira redirecionar os dados para a view com a lista de erros encontrados, ai na view é só mostrar:

&lt;pre lang=&quot;PHP&quot;&gt;
&lt;?php if (Session::has(&#039;message.errors&#039;)): ?&gt;
	&lt;?php foreach (Session::get(&#039;message.errors&#039;) as $message): ?&gt;
		&lt;div class=&quot;alert-message error&quot;&gt;
			&lt;p&gt;&lt;?php echo $message; ?&gt;&lt;/p&gt;
		&lt;/div&gt;
	&lt;?php endforeach; ?&gt;
&lt;?php endif; ?&gt;
&lt;/pre&gt;

Espero que lhe ajude.
Qualquer dúvida só chamar.</description>
		<content:encoded><![CDATA[<p>Olá Felipo!<br />
Geralmente eu faço um método validateAndSave() dentro do model e no retorno eu faço algo tipo assim:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> validateAndSave<span style="color: #009900;">&#40;</span><span style="color: #000088;">$promo</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$rules</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #666666; font-style: italic;">// aqui as regras</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$messages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #666666; font-style: italic;">// aqui vai as mensagens</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$validator</span> <span style="color: #339933;">=</span> Validator<span style="color: #339933;">::</span><span style="color: #004000;">make</span><span style="color: #009900;">&#40;</span> Input<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$rules</span><span style="color: #339933;">,</span> <span style="color: #000088;">$messages</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$validator</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">valid</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$promo</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$promo</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$promo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_id</span> <span style="color: #339933;">=</span> Auth<span style="color: #339933;">::</span><span style="color: #004000;">user</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$promo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store_id</span>    <span style="color: #339933;">=</span> Input<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'store'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$promo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">product_id</span>  <span style="color: #339933;">=</span> Input<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'product'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$promo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span>        <span style="color: #339933;">=</span> Input<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$promo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$validator</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">errors</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">all</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Na controller eu verifico:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$errors</span> <span style="color: #339933;">=</span> Promo<span style="color: #339933;">::</span><span style="color: #004000;">validateAndSave</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$errors</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> Redirect<span style="color: #339933;">::</span><span style="color: #004000;">to</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/promo/add'</span><span style="color: #009900;">&#41;</span>
				   <span style="color: #339933;">-&gt;</span><span style="color: #004000;">with</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'message.errors'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$errors</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Isso ira redirecionar os dados para a view com a lista de erros encontrados, ai na view é só mostrar:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>Session<span style="color: #339933;">::</span><span style="color: #004000;">has</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'message.errors'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span>Session<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'message.errors'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
		&lt;div class=&quot;alert-message error&quot;&gt;
			&lt;p&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$message</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/p&gt;
		&lt;/div&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Espero que lhe ajude.<br />
Qualquer dúvida só chamar.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comentário sobre Validando campos de data e hora no model do Laravel. por Felipo Antonoff Araújo</title>
		<link>http://binho.net/validando-campos-de-data-e-hora-no-model-do-laravel/#comment-13</link>
		<dc:creator>Felipo Antonoff Araújo</dc:creator>
		<pubDate>Sat, 04 Feb 2012 02:58:10 +0000</pubDate>
		<guid isPermaLink="false">http://binho.net/?p=34#comment-13</guid>
		<description>Bem legal o tutorial, já desenvolvi um site de e-commerce de notícias para faculdade, mas foi apenas um protótipo e não usei muita coisa.
Aprendi muito coisa sobre o Laravel e gosto muito dele. Além dele, indico o FuelPHP. Sobre validação, o meu maior problema é mostrar os erros. Por exemplo: Em um controlador, eu verifico os dados e caso de erro, gostaria de redirecionar para outro controlador (até ai tudo bem), mas não consigo ver os erros.
E queria saber se tem como, retornar os dados que estiverem correto. Por exemplo: O formulário tem 3 dados Login, Nome e Senha e apenas o nome está errado, logo gostaria de fazer um redirecionamento novamente para o formulário, deixa preenchido o resto e do lado de nome, informar o erro.

Grato.</description>
		<content:encoded><![CDATA[<p>Bem legal o tutorial, já desenvolvi um site de e-commerce de notícias para faculdade, mas foi apenas um protótipo e não usei muita coisa.<br />
Aprendi muito coisa sobre o Laravel e gosto muito dele. Além dele, indico o FuelPHP. Sobre validação, o meu maior problema é mostrar os erros. Por exemplo: Em um controlador, eu verifico os dados e caso de erro, gostaria de redirecionar para outro controlador (até ai tudo bem), mas não consigo ver os erros.<br />
E queria saber se tem como, retornar os dados que estiverem correto. Por exemplo: O formulário tem 3 dados Login, Nome e Senha e apenas o nome está errado, logo gostaria de fazer um redirecionamento novamente para o formulário, deixa preenchido o resto e do lado de nome, informar o erro.</p>
<p>Grato.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comentário sobre Olá Mundo! por Rafael Maia</title>
		<link>http://binho.net/hello-world/#comment-3</link>
		<dc:creator>Rafael Maia</dc:creator>
		<pubDate>Mon, 16 Jan 2012 19:24:59 +0000</pubDate>
		<guid isPermaLink="false">http://binho.net/?p=1#comment-3</guid>
		<description>T amo cara! vc é o mestre da internet!
Abraço e suuuuuucesso!</description>
		<content:encoded><![CDATA[<p>T amo cara! vc é o mestre da internet!<br />
Abraço e suuuuuucesso!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comentário sobre Desabilitando temporariamente a checagem de Foreign keys no MySQL. por pererinha</title>
		<link>http://binho.net/desabilitando-temporariamente-a-checagem-de-foreign-keys-no-mysql/#comment-2</link>
		<dc:creator>pererinha</dc:creator>
		<pubDate>Wed, 04 Jan 2012 00:20:12 +0000</pubDate>
		<guid isPermaLink="false">http://binho.net/?p=22#comment-2</guid>
		<description>Obrigado, será muito útil no meu trabalho. :)</description>
		<content:encoded><![CDATA[<p>Obrigado, será muito útil no meu trabalho. :)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

