This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$curl -O http://laravel.com/laravel.phar | |
$ chmod 755 laravel.phar | |
$ mv laravel.phar /usr/local/bin/ | |
$ sudo laravel new myl4site | |
Crafting application... | |
Application ready! Build something amazing. | |
$ ls myl4site | |
Permissions for laravel storage folder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Event::listen('illuminate.query), function($slq) | |
{ | |
var_dump($sql); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example: | |
$user= User::find(1); | |
var_dump($user->projects); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Controller Create | |
$ciudades_opciones = \Ciudad::orderBy('nombre', 'asc')->lists('nombre','id'); | |
View of create | |
{{ Form::select('ciudad_id', array('default' => 'Seleccione') + $ciudades_opciones, null, array('class' => 'form-control select2me')) }} | |
Note: the null options is the default value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@foreach ($posts->slice(0, 5) as $post) | |
<h1>{{ $post['title'] }}</h1> | |
@endforeach |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `paises` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`nombre` varchar(50) DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; | |
CREATE TABLE `ciudades` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`pais_id` int(11) DEFAULT NULL, | |
`nombre` varchar(50) DEFAULT NULL, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteRule ^(.*)$ public/$1 [L] | |
</IfModule> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$parts = explode('-', '2068-06-15'); | |
echo $parts[0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Route::get('/year',function() | |
{ | |
$year= '2013'; | |
return Post::whereRaw('YEAR(`posted_date`) = ?', array($year))->get(); | |
}); | |
Auto: | |
http://albertokempis.com/content/filter-records-according-year-using-laravel-eloquent-orm |
OlderNewer