Instant response for OctoberCMS Flash messages combined with Romanov.Flashmessage plugin (no page reload)

$validation = Validator::make($data, $rules);
 if ($validation->fails()) {
     throw new ValidationException($validation);
 try {
     $user = Auth::authenticate([
         'login' => array_get($data, 'login'),
         'password' => array_get($data, 'password')
     ], true);
 catch (Exception $ex) {
     if (preg_match('/user was not found with the given cred/i',$ex->getMessage())) {
     $flash_message = 'A registered user was not found with that email';
 elseif (preg_match('/hashed credential "password" did not match/i',$ex->getMessage())) {
     $flash_message = 'The password supplied for that user is incorrect';
 if ($flash_message) {
     return ['msgs' => [ 'danger' => $flash_message ], 'options' => [], 'settings' => [] ];


This will replace the error message ” user was found to match all plain text credentials however hashed credential “password” did not match.” that comes by default with Laravel.



OctoberCMS debugging – DUMP() debug function for templating and Debugbar plugin

This is a very handy function for debugging the template.



{{ dump(user) }}
{{ dump(user, categories) }}
{{ dump() }}

It’ll show you the variable type and its content, eg. if you have an object variable it’ll show you the member functions or if you have a collection variable, it’ll show you the keys and value types.

The following screenshot indicates the front-end output of an array variable:
octoberCMS dump function debug output screenshot for template front end

Here is another useful OctoberCMS plugin that’ll help debugging as it could show much more information in the backend.

OctoberCMS DebugBar plugin

OctoberCMS debugbar plugin on GitHub:

on OctoberCMS plugins page:

A laravel validation rules – Check user age with laravel validation rules

Here is the example code for checking the age of an user.

Validator::extend('olderThan', function($attribute, $value, $parameters)
    $minAge = ( ! empty($parameters)) ? (int) $parameters[0] : 13;
    return (new DateTime)->diff(new DateTime($value))->y >= $minAge;

    // or the same using Carbon:
    // return Carbon\Carbon::now()->diff(new Carbon\Carbon($value))->y >= $minAge;


$rules = ['dob' => 'olderThan']; // checks for 13 years as a default age
$rules = ['dob' => 'olderThan:15']; // checks for 15 years etc


Some of the jQuery / BootStrap Datepicker datetime input

Customizable Dropdown Birthday Picker Plugin with jQuery

This one’s with 3 input fields.

Customizable Dropdown Birthday Picker Plugin with jQuery

Datepicker for Bootstrap

The best part for this one is the start and end date / check in and check out date control

Datepicker for Bootstrap

DateTime Picker Bootstrap – form component to handle date and time data.

DateTime Picker Bootstrap - form component to handle date and time data.


Pikaday A refreshing JavaScript Datepicker JS Lib

This is a simple yet fully functional datetime picker

Pikaday A refreshing JavaScript Datepicker


PHP date function:

I’ve found an issue when the instance is not bound to the filed value, eg. I’d like to preload the field value value=”{{ __SELF__.userDob }}”, this will cause the picker not work.

In order to solve this, try to bind the instance to the field value:

change the onSelect line

onSelect: function()


picker = new Pikaday({
    onSelect: function(date) {
        field.value = picker.toString();

Then it should work.

Formatting Timestamps in Laravel and OctoberCMS

If you create a table with timestamp() via a migration, you’ll actually get a timestamp that is matching the one created by date(‘Y-m-d H:i:s’).

So in order to get the output correctly displayed with your local time format, or you’d like to format it and have an input to the database, then you’ll need to format it before the output:

Created on: {{ date('F d, Y', strtotime($list->created_at)) }}

For formatting the input, eg. format a DOB datetime input:

$data = post();

$data[‘dob’] = date(‘Y-m-d H:i:s’, post(‘dob’));