Laravel “At Least One” Field Required Validation

Try checking out required_without_all:foo,bar,…, it looks like that should do it for you. To quote their documentation: The field under validation must be present only when the all of the other specified fields are not present. Example: $rules = array( ‘facebook_id’ => ‘required_without_all:twitter_id,instagram_id’, ‘twitter_id’ => ‘required_without_all:facebook_id,instagram_id’, ‘instagram_id’ => ‘required_without_all:facebook_id,twitter_id’, ); $validator = Validator::make(Input::all(), $rules);

Using ng-if as a switch inside ng-repeat?

Try to surround strings (hoot, story, article) with quotes ‘: <div ng-repeat = “data in comments”> <div ng-if=”data.type == ‘hoot’ “> //different template with hoot data </div> <div ng-if=”data.type == ‘story’ “> //different template with story data </div> <div ng-if=”data.type == ‘article’ “> //different template with article data </div> </div>

Laravel 4 db seed specific seeder file

You can call individual seed classes by their class name. From the docs. By default, the db:seed command runs the DatabaseSeeder class, which may be used to call other seed classes. However, you may use the –class option to specify a specific seeder class to run individually: php artisan db:seed –class=ProductTableSeeder In the example above, … Read more

Using Carbon to return a human readable datetime difference

By default, Eloquent will convert the created_at, updated_at, and deleted_at columns to instances of Carbon. So, your code should be just like this: $comment->created_at->diffForHumans(); It’s very cool. It’ll produce string like 2 minutes ago or 1 day ago. Plurar or singular, seconds, minutes, hours, days, weeks, or years, it runs automatically. I’ve tested it on … Read more

‘Malformed UTF-8 characters, possibly incorrectly encoded’ in Laravel

I wrote this method to handle UTF8 arrays and JSON problems. It works fine with array (simple and multidimensional). /** * Encode array from latin1 to utf8 recursively * @param $dat * @return array|string */ public static function convert_from_latin1_to_utf8_recursively($dat) { if (is_string($dat)) { return utf8_encode($dat); } elseif (is_array($dat)) { $ret = []; foreach ($dat as … Read more