Skip to content

Instantly share code, notes, and snippets.

View rdgutierrez's full-sized avatar

Ruben Dario Gutierrez Sanchez rdgutierrez

View GitHub Profile
function allow_my_post_types($allowed_post_types) {
$allowed_post_types[] = 'my_post_type';
return $allowed_post_types;
}
add_filter( 'rest_api_allowed_post_types', 'allow_my_post_types');
@rdgutierrez
rdgutierrez / gist:418173f9f3300077471f
Last active August 29, 2015 14:19
Error "FatalErrorException: Error: Call to undefined method Illuminate\Database\Eloquent\Collection::paginate()"
Según lo que dice este post https://github.com/laravel/framework/issues/213
Si estas obteniendo el siguiente error
FatalErrorException: Error: Call to undefined method
Illuminate\Database\Eloquent\Collection::paginate()
El error se da por querer usar ::all()->paginate(15); la idea es usar por ejemplo si estamos leyendo la tabla users:
User::paginate(15);
Lo que si es aceptable es meter condiciones a la busqueda, como esto:
@rdgutierrez
rdgutierrez / gist:7ddf1c97157ed5baf1fd
Created April 15, 2015 15:12
Pasando variables a la vista de un email y al closure en Laravel 5
Metes la data en un array $data
$data = array(
'name'=>$contactName,
'email'=>$contactEmail,
'message'=>$contactMessage
);
En tu plantilla "view" podras usar estas variables
@rdgutierrez
rdgutierrez / gist:b06fae22348cd0376836
Last active February 14, 2024 20:30
Fechas en español con Carbon en Laravel 5
Using a library as Laravel-Date you will just need to set the language of the app in the Laravel app config file and use its functions to format the date as you want.
Set the language in /app/config/app.php
...
'locale' => 'es',
...
I've found this library pretty useful and clean. To use it, you can write something like the example in the library readme file. I leave the results in spanish.
...
echo Date::now()->format('l j F Y H:i:s'); // domingo 28 abril 2013 21:58:16
echo Date::parse('-1 day')->diffForHumans(); // 1 día atrás
@rdgutierrez
rdgutierrez / gist:8cfae5b4fb3f2bb5dab1a807c2df7867
Created May 3, 2017 06:25
Código de Twitter Card para Wordpress - Añadir antes de la etiqueta </head> en el archivo header.php de tu tema activo
<?php
#twitter cards hack
if(is_single() || is_page()) {
$twitter_url = get_permalink();
$twitter_title = get_the_title();
$twitter_desc = get_the_excerpt();
$twitter_thumbs = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), full );
$twitter_thumb = $twitter_thumbs[0];
if(!$twitter_thumb) {
$twitter_thumb = 'http://www.gravatar.com/avatar/8eb9ee80d39f13cbbad56da88ef3a6ee?rating=PG&size=75';
@rdgutierrez
rdgutierrez / gist:4c7b4cb5881c555c628bc3824608aa55
Created June 27, 2017 17:30
Ceating Roles in Laravel 5.4 with httpoz/roles
Route::get('roles', function(){
\HttpOz\Roles\Models\Role::create([
'name' => 'Admin',
'slug' => 'admin',
'description' => 'Custodians of the system.'
]);
\HttpOz\Roles\Models\Role::create([
'name' => 'Dealer',
'slug' => 'dealer',
@rdgutierrez
rdgutierrez / countrydropdown.html
Last active November 7, 2020 17:11 — forked from danrovito/countrydropdown.html
HTML Country Select Dropdown List
<label for="country">Country</label><span style="color: red !important; display: inline; float: none;">*</span>
<select id="country" name="country" class="form-control">
<option value="Afganistán">Afganistán</option>
<option value="Åland Islands">Åland Islands</option>
<option value="Albania">Albania</option>
<option value="Argelia">Argelia</option>
<option value="Samoa Americana">Samoa Americana</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>