- 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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console | 
public function connections()
{
	$relation = $this
		->belongsToMany(static::class, 'connections', 'requestor_id', 'requested_id')
		->withTimestamps();
	/// delete the already built inner join
	$relation
		->getQuery() // Eloquent\Builder
| Allow display images and youtube video: | |
| CSS class for links .htmllink and images .htmlimg | |
| public function linkify($showimg = 1, $value, $protocols = array('http', 'mail', 'https'), array $attributes = array('target' => '_blank')) | |
| { | |
| // Link attributes | |
| $attr = ''; | |
| foreach ($attributes as $key => $val) { | |
| $attr = ' ' . $key . '="' . htmlentities($val) . '"'; | |
| } | 
| /* | |
| <a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request | |
| - Or, request confirmation in the process - | |
| <a href="posts/2" data-method="delete" data-confirm="Are you sure?"> | |
| */ | |
| (function() { | 
| <?php | |
| // This can be found in the Symfony\Component\HttpFoundation\Response class | |
| const HTTP_CONTINUE = 100; | |
| const HTTP_SWITCHING_PROTOCOLS = 101; | |
| const HTTP_PROCESSING = 102; // RFC2518 | |
| const HTTP_OK = 200; | |
| const HTTP_CREATED = 201; | |
| const HTTP_ACCEPTED = 202; |