- https://speakerdeck.com/willroth/50-laravel-tricks-in-50-minutes
- https://www.reddit.com/r/laravel/comments/3to60i/50_laravel_tricks/
- 1. Automatic Model Validation
/** | |
* A very simple autocomplete component | |
* | |
* This is to replace the OOTB Gutenberg Autocomplete component because it is | |
* currently broken as of v4.5.1. | |
* | |
* See Github issue: https://github.com/WordPress/gutenberg/issues/10542 | |
* | |
* Note: The options array should be an array of objects containing labels and values; i.e.: | |
* [ |
<?php | |
namespace App\Http; | |
class HttpCode | |
{ | |
/* | |
* HTTP Status Codes & their meaning | |
* Source: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes | |
* By: Yentel Hollebeke - https://github.com/yentel |
<?php | |
namespace Drupal\my_module\Form; | |
use Drupal\Core\Form\FormBase; | |
use Drupal\Core\Form\FormStateInterface; | |
/** | |
* Class TestAjaxFormSelect. | |
*/ |
<?php | |
// How to create horizontal tabs programmatically in Drupal 8, requires Field Group module | |
$form = array(); | |
$form['my_field'] = array( | |
'#type' => 'horizontal_tabs', | |
'#tree' => TRUE, | |
'#prefix' => '<div id="unique-wrapper">', | |
'#suffix' => '</div>', | |
); | |
$items = array( |
<?php | |
/** | |
* Validates a given latitude $lat | |
* | |
* @param float|int|string $lat Latitude | |
* @return bool `true` if $lat is valid, `false` if not | |
*/ | |
function validateLatitude($lat) { | |
return preg_match('/^(\+|-)?(?:90(?:(?:\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\.[0-9]{1,6})?))$/', $lat); |
$ cd ~ | |
$ sudo curl -sS https://getcomposer.org/installer | sudo php | |
$ sudo mv composer.phar /usr/local/bin/composer | |
$ sudo ln -s /usr/local/bin/composer /usr/bin/composer | |
then you can run | |
$ sudo composer install |
Most of programs will not accept an email using just @localhost as domain.
So, edit /etc/hosts
file to make the domain localhost.com point to your machine, including this content to the file:
127.0.0.1 localhost.com