Laravel validator: This field or that field is required, but not both

Recently, I needed to produce a check where one of two fields were required in a form submission, but not both. For example, say we had a house phone number field and a mobile phone number field but we only required one of those upon submission and not both, how can we do that?

I searched the web and found a few interesting articles however I opted to write my own validator, which you can see below.

Validator::extendImplicit('this_or_that', function ($attribute, $value, $parameters, $validator) {
    return (bool) (!empty($value) ^ (array_key_exists($parameters[0], $validator->getData()) && !empty($validator->getData()[$parameters[0]])));

To use this, place the above (more…)

Too much choice is bad

Skylake PC build

I put together a new PC recently (as shown above) and when I was choosing the parts I had a seemingly endless list of possible choices to make. Which graphics card? Are there any new graphics cards coming out soon? How is this graphics card different from this other one? Which one is the most appropriate for me considering cost and the performance I need? And that is just one component of about ten to go through. I honestly wish that hardware manufacturers (and all industries for that matter) would clearly describe who their products are for and how it differs from all of their other products. (more…)


If you'd like to contact me then simply leave a comment on this post below (don't worry it won't be published) and remember to leave your email if you want a reply.

Nothing is perfect

I can write my first post because nothing is perfect. I literally mean nothing is perfect as in, a blank sheet of paper before a writer writes, the silence before a musician plays or the blank canvas before an artist paints. Nothing really is perfect. It represents endless possibilities and purity. It contains everything.

Yet as soon as you write that first line, as soon as you make that first sound or as soon as you have painted that first stroke you have instantly limited yourself down to a finite thing that can be measured, scrutinized, and picked apart. Ideas such as 'good' or 'perfection' are subjective and differ depending upon who you ask. Therefore, to know what to write, what to play or what to paint you should always listen to yourself and do things by your own standards. Don't worry about others - it's not logical.