View IncrementMonths.php
This file contains 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
$nextMonthDate = $date->copy(); | |
$nextMonthDate->addMonths($addMonths); | |
// j - Day of the month without leading zeros | |
if ($nextMonthDate->format('j') != $date->format('j')) | |
{ | |
$date->modify('last day of +'.$addMonths.' months'); | |
} | |
else | |
{ |
View gist:de0af1bfb34666e887d6
This file contains 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
Regex search and replace for form helpers as follows: | |
Search: | |
\{\{ (Form\:\:.+) \}\} | |
Replace: | |
{!! $1 !!} |
View gist:6917686
This file contains 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
var response = { 'whatever' }; | |
var items = ['item1', 'Item2', 'Item3']; | |
$.each(items, function(key, value) { | |
$.each(response.value, function(k, v) { | |
}); | |
}); |
View gist:6637861
This file contains 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
<?php namespace Tmb; | |
use Illuminate\Database\Eloquent\Model as Eloquent; | |
use Illuminate\Validation\Validator; | |
class BaseModel extends Eloquent | |
{ | |
/** | |
* Error message bag |
View eager-load-relations-repository
This file contains 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
// If we have a model that has a lot of relationships, we need a method to be able to dynamically | |
// eager-load those relationships in an easy way | |
// For example, some controller methods may only require one relationship to be loaded | |
// Others may require all relationships to be eager loaded | |
// Repository | |
class UserRepository implements UserInterface | |
{ | |
public function find($id, $relations = array()) |