Laravel change validation constructor message

I came across an issue while doing Laravel 5, and that was the validation default message key in the validation response array “The Given data was invalid”.

I wanted to have that set in a language file instead of using a static English string.


Here’s the file you need to edit at line 57.



Set that to any language key you want, i chose ‘validation.message’ :


Have a good day.

PHP Class Customization trait

I’ve written a trait to help with customizing classes behaviors. For example if you have a class A with method getName() but in this method you want to check whether you want the full name to be returned or just the last or first name, the solution will be creating a new method or editing the code. This trait solves it


All you need to do is to add use HasOptions to the desired class




Note: In order to use traits and customize the $options array, the class where you’re adding your $options array needs to a child of the class where HasOptions is used, so the example i gave you will generate error related to $options = [];

[alert type=”warning”]If a trait defines a property then a class can not define a property with the same name unless it is compatible (same visibility and initial value), otherwise a fatal error is issued. Before PHP 7.0.0, defining a property in the class with the same visibility and initial value as in the trait, raised an E_STRICT notice. [/alert]


So keep that in mind.

PHP get Array Values from another Array Keys

Let’s say you have these two arrays :

And you want to grab two items of this array without using foreach and conditions, what would you do?

The solution is simple, we’re going to use array_intersect_key in conjunction with array_flip to get an array of what we picked, here how it works:

In that code we’re telling php that we want the Orange, and the Apple, the full php code will be:



PHP how to echo an Array

There are multiple ways to print/echo and array in php:


PHP: How to get the Max and Mix value in an Array

It is very simple to get the Max and Min value in an array, with a built in function .


PHP: How to get Current Date

There are multiple ways which can be used to get PHP Current Date, I’m going to start with the simplest way.

the date will return a string

According to PHP Manual, date() takes two parameters, the first one is format the second one is timestamp.

Continue reading PHP: How to get Current Date

PHP: CSS Merge & Compress

Ever wanted a class to merge your CSS files into one and compresses them as well? I wrote this class and it does the trick, these few lines of codes right there can add css files a queue and render them later, it has few options as well like compressing:



Easy enough?

Remember, if you have any comments, write them down below in the comments box!