Code Monkey home page Code Monkey logo

Comments (6)

felixkiss avatar felixkiss commented on August 28, 2024

@webysther Please help test out #73 and give feedback if possible. It is based on version 3.0.0, so you need to upgrade (Usually only thing necessary is to update the service provider class in your config/app.php, which has been renamed)

from uniquewith-validator.

webysther avatar webysther commented on August 28, 2024

Hi @felixkiss works partially, the problem of SQL is fine, but now search works but dont check all columns, example:

For rule:

unique_with:search_filters,search.name = name, search.user_id = user_id

Return the message:

This combination of search.name, search.user id already exists.

And the SQL executed is by validation:

select count(*) as aggregate from `search_filters` where `name` = 'teste'

My create statment:

CREATE TABLE `search_filters` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `name` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
  `filter` varchar(500) COLLATE utf8_unicode_ci NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  `deleted_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `created_by` int(10) unsigned DEFAULT NULL,
  `updated_by` int(10) unsigned DEFAULT NULL,
  `deleted_by` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_search_filters` (`user_id`,`name`,`deleted_at`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Rows in table:

# id, user_id, name, filter, created_at, updated_at, deleted_at, created_by, updated_by, deleted_by
'2', '20', 'teste', 'action-search=&period=&product_id=&requester_auto_complete=&requester_id=&search_term=&status=pending', '2017-02-22 17:55:10', '2017-02-22 17:55:19', '2017-02-22 17:55:19', '20', '20', NULL
'3', '20', 'teste', 'action-search=&period=&product_id=&requester_auto_complete=&requester_id=&search_term=&status=pending', '2017-02-22 18:05:41', '2017-02-22 18:05:41', '0000-00-00 00:00:00', '20', '20', NULL

from uniquewith-validator.

webysther avatar webysther commented on August 28, 2024

@felixkiss maybe is related to laravel/framework#1820
On my case check null not work, i need set value '0000-00-00 00:00:00'

from uniquewith-validator.

felixkiss avatar felixkiss commented on August 28, 2024

I just tried it myself. I had the exact same problem as you until I noticed that I wasn't using the dot-validation branch. What does your composer.json look like? Should be something like

{
    "require": {
        "felixkiss/uniquewith-validator": "dev-dot-validation"
    }
}

from uniquewith-validator.

felixkiss avatar felixkiss commented on August 28, 2024

As for the deleted_at problem: Just set the value to ignore (in your case 0000-00-00 00:00:00) in the validator data array like so:

$data = [
    'search' => [
        'name' => 'foo',
        'user_id' => 2,
    ],
    'deleted_at' => '0000-00-00 00:00:00',
];

$rules = [
    'search.name' => 'required|unique_with:search_filters, search.name = name, search.user_id = user_id, deleted_at',
    'search.user_id' => 'required',
];

$validator = Validator::make($data, $rules);

from uniquewith-validator.

webysther avatar webysther commented on August 28, 2024

Now works! 👍

from uniquewith-validator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.