Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

an issue with spatie/laravel-tags #2

Closed
ctf0 opened this issue Mar 22, 2018 · 2 comments
Closed

an issue with spatie/laravel-tags #2

ctf0 opened this issue Mar 22, 2018 · 2 comments

Comments

@ctf0
Copy link
Contributor

ctf0 commented Mar 22, 2018

am not sure if its an issue with the https://github.com/spatie/laravel-tags package or something is missing from the validation package,

but here is what i have

$request->validate([
    'name.*' => 'unique_translation:tags,name,' . $id
]);

the db name column i will update is

{"en": "black"}

and will be replaced with

{
  "en": "test",
  "fr": null
}

but i keep getting the error that the item already exists in the db, so maybe u can help me with this one

@ctf0 ctf0 changed the title an issue with https://github.com/spatie/laravel-tags an issue with spatie/laravel-tags Mar 22, 2018
@ivanvermeyen
Copy link
Contributor

Hi,

I can't seem to reproduce this in a test...
This test should cover what you are trying to do:

$rules = [
'slug.*' => "{$this->rule}:{$this->table},slug,{$this->model->id}",
'name.*' => UniqueTranslationRule::for($this->table)->ignore($this->model->id),
];
$this->createRoute('test-array', $rules);
$this->post('test-array', [
'slug' => ['nl' => 'slug-nl'],
'name' => ['nl' => 'name-nl'],
])->assertStatus(200);

I also tried to create a second dummy model which has a "duplicate" null translation, but that didn't throw any error either.

$this->model = Model::create([
    'slug' => [
        'en' => 'slug-en',
        'nl' => 'slug-nl',
    ],
    'name' => [
        'en' => 'name-en',
        'nl' => 'name-nl',
    ],
    'other_field' => 'foobar',
]);

Model::create([
    'slug' => [
        'en' => 'another-slug-en',
        'nl' => 'another-slug-nl',
    ],
    'name' => [
        'en' => 'another-name-en',
        'nl' => null,
    ],
]);

$rules = [
    'slug.*' => "{$this->rule}:{$this->table},slug,{$this->model->id}",
    'name.*' => UniqueTranslationRule::for($this->table)->ignore($this->model->id),
];

$this->createRoute('test-array', $rules);

$this->post('test-array', [
    'slug' => ['en' => 'slug-en', 'nl' => 'slug-nl'],
    'name' => ['en' => 'name-en', 'nl' => null],
])->assertStatus(200);

Can you give me some more info/code to investigate?

@ctf0
Copy link
Contributor Author

ctf0 commented Mar 22, 2018

thanx for the test 👍

Can you give me some more info/code to investigate?

its a package am building to facilitate working with the spatie/tags, once done i will ping u to test directly on it.

update

it seems that spatie/laravel-tags allow having duplicates because of types, so will close this for now, thanx again for ur help 🏆

@ctf0 ctf0 closed this as completed Mar 25, 2018
@pishguy pishguy mentioned this issue Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants