Validator::register('unique_element_page', function ($attribute, $value, $parameters) {
    //CHECK UNIQUENESS OF ELEMENT NAME IN A PAGE
    $page_id = $parameters[0];
    $element_id = $parameters[1];
    if (isset($parameters[2])) {
        $attribute = $parameters[2];
    }
    $elements = CmsPage::find($page_id)->elements()->where('cmselement_id', '<>', $element_id)->where($attribute, '=', $value)->count();
    return $elements == 0;
});
Validator::register('unique_file', function ($attribute, $value, $parameters) {
    //CHECK UNIQUENESS OF FILE NAME ON DISK
    $file_name = $parameters[0];
    $path = $parameters[1];
    // CHECK DB NAME
    $query = CmsFile::where_name($file_name);
    return !file_exists(path('public') . $path . $file_name) and $query->count() == 0;
});
Validator::register('unique_filename', function ($attribute, $value, $parameters) {
    //CHECK UNIQUENESS OF FILE NAME
    $ext = $parameters[0];
    if (isset($parameters[1])) {
        $attribute = $parameters[1];
    }
    $query = DB::table('files')->where($attribute, '=', $value . '.' . $ext);
    return $query->count() == 0;
});
Validator::register('valid_datetime', function ($attribute, $value, $parameters) {
    //match the format of the date
    if (!empty($value)) {
        $d = DateTime::createFromFormat(GET_DATETIME(), $value);