Skip to content

Instantly share code, notes, and snippets.

View sabid's full-sized avatar
🏠
Working from home

Sabid Barahona sabid

🏠
Working from home
View GitHub Profile
@sabid
sabid / laravel_instalation_laravel.phar
Last active August 29, 2015 14:03
Laravel New Instaltion from laravel.phar
$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
@sabid
sabid / Laravel Query Listenen
Created July 8, 2014 17:54
Laravel Even::listenen Query
Event::listen('illuminate.query), function($slq)
{
var_dump($sql);
}
@sabid
sabid / 0_reuse_code.js
Created July 8, 2014 17:59
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
@sabid
sabid / Laravel Artisan tinker
Created July 8, 2014 18:02
Laravel Artisan tinker
Example:
$user= User::find(1);
var_dump($user->projects);
@sabid
sabid / Laravel Form select populate.php
Last active August 29, 2015 14:03
Laravel Form::select() Populate fron data base
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
@sabid
sabid / Laravel: Blade: Limit foreach loop
Created July 21, 2014 06:35
Laravel: Blade: Limit foreach loop
@foreach ($posts->slice(0, 5) as $post)
<h1>{{ $post['title'] }}</h1>
@endforeach
@sabid
sabid / Database
Last active March 29, 2023 00:55
Laravel + Jquery Ajax Country and City
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,
@sabid
sabid / .htaccess
Created August 4, 2014 19:15
Laravel Remove public folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
@sabid
sabid / part_of_date
Created August 4, 2014 20:41
PHP Part of a date
$parts = explode('-', '2068-06-15');
echo $parts[0];
@sabid
sabid / Filter records by year
Created August 4, 2014 20:42
Filter records according to year using Laravel Eloquent ORM
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