Skip to content

Instantly share code, notes, and snippets.

View juniorb2ss's full-sized avatar
🎯
Focusing

Carlos E. Oliveira juniorb2ss

🎯
Focusing
View GitHub Profile
public function postAtendimentos()
{
// Regras de validação do formulário
$validator = \Validator::make(\Input::all(),
array(
'assunto' => 'required|min:5',
'cliente' => 'required|min:1',
'categoria' => 'required|min:1',
'descricao' => 'required|min:20',
'status' => 'required|min:5'
<?php
$current_date = new DateTime( '2014-10-24 21:37:00' ); // 2011-12-04 20:13:35
$current_date->add( new DateInterval( 'PT22H' ) );
echo $current_date->format( 'Y-m-d H:i:s' ); // 2011-12-07 20:13:35
class Veiculo extends Eloquent{
protected $table = 'veiculo';
protected $primaryKey = 'nr_veiculo';
public $with = [ 'Marca' ]; // related relationship
public function marca(){
return $this->hasOne('marca','nr_marca_veiculo','nr_marca_veiculo');
}
// controller
@juniorb2ss
juniorb2ss / gist:04efdd58fb0a3350bbc0
Created November 11, 2014 21:25
Eager Loading Laravel
return $this->where('cnpj', '=', $cnpj)
->whereHas('licencas', function($q) use($chaveInstalacao){
$q->where('chaveInstalacao', '=', $chaveInstalacao ); // Where category name
})->with(['licencas' => function($q) use($chaveInstalacao) {
$q->where('chaveInstalacao', '=', $chaveInstalacao );
}])->limit(1)->first();
<?php
namespace App\Modules\News\Models;
use Carbon\Carbon, Model\Category, Model\Tags, Model\Categorys, Debugbar;
class News extends \Eloquent {
public $with = [ 'tags', 'category' ]; // related relationship
@juniorb2ss
juniorb2ss / 0_reuse_code.js
Last active August 29, 2015 14:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@juniorb2ss
juniorb2ss / css_resources.md
Last active August 29, 2015 14:10 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

#!/bin/bash
#your db settings
USER="db_root"
PASS="db_pass"
OUTPUT="/path/to/backup/folder"
HOST="mysql_host"
DATE=`date +%d%m%y%H%M`
databases=`mysql --host=$HOST --user=$USER --password=$PASS -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
App::error(function(Exception $exception, $code)
{
if (!Config::get('app.debug')) {
Log::error($exception);
return App::make('App\Modules\Home\Controllers\HomeController')->ErrorPage($code);
}
});
$variavel = $questInstance->getReqInfo("npc",0);
if(array_key_exists('stringStore', $variavel))
{
# code...
}