Comments (5)
Hello,
Can you try if #13 fixes your problem (solution at the end)?
If not, can you give some more context on the issue?
from laravel-unique-translation.
My DB column
and this is how i save translations
$model->$field = $data[$field];
$model->save();
My Saved Value
{"ar":"\u062a\u062c\u0631\u0628\u0647","en":"test"}
i have reviewed your fix but didn't work for me @ivanvermeyen
from laravel-unique-translation.
Arabic is working with search but not with validation
from laravel-unique-translation.
Hello,
I've been looking into this and the following test indeed fails when using another database column type than json
.
Validation should fail because there is a duplicate value, but it doesn't.
/** @test */
public function it_handles_arabic_language()
{
Model::create([
'slug' => ['ar' => 'جديد'],
]);
$rules = [
'slug.*' => "{$this->rule}:{$this->table}",
];
$validation = Validator::make([
'slug' => ['ar' => 'جديد'],
], $rules);
$this->assertTrue($validation->fails());
}
The only way to make it pass is to change the database column type to json
(text and longtext doesn't seem to work).
I don't know if this problem can be handled in the code. I'll do some research about it.
from laravel-unique-translation.
This is probably the culprit:
https://stackoverflow.com/questions/18616682/searching-arabic-words-that-have-diacritics-in-mysql
Their solution is to add a FULLTEXT
index to the column, specify the correct charset
and collation
and use BOOLEAN MODE
in the query:
CREATE TABLE articles (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
title VARCHAR(200),
body TEXT,
FULLTEXT (title,body)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO articles (title,body) VALUES
('الْجِنَّةِ DCKIEW', 'DAVADV الْجِنَّةِ AVADV')
SELECT * FROM articles
WHERE MATCH (title,body)
AGAINST ('الجنة' IN BOOLEAN MODE);
Now, I have tried to use fulltext
search, but Laravel has no built-in option to specify the BOOLEAN MODE
in the query.
return DB::connection($connection)->table($table)
->where(function ($query) use ($column, $locale, $value) {
$query->whereFullText($column, "\"{$locale}\": \"{$value}\"")
->orWhereFullText($column, "\"{$locale}\":\"{$value}\"");
//$query->where($column, 'LIKE', "%\"{$locale}\": \"{$value}\"%")
// ->orWhere($column, 'LIKE', "%\"{$locale}\":\"{$value}\"%");
});
So it didn't work.
Also, it tripped a few other tests, so I'm not sure if fulltext is even a possible solution.
The easiest way would be to use a json
column.
from laravel-unique-translation.
Related Issues (20)
- unique validation error while updating using form request HOT 4
- JSON_EXTRACT() function not exist issue with MySQL lower versions (to 5.6) HOT 5
- Unique validation with ar. HOT 17
- ErrorException
- UniqueTranslationRule is ignored - Laravel 8 HOT 2
- an issue with spatie/laravel-tags HOT 2
- MariaDB / PostgreSQL compatibility HOT 1
- Error during test Undefined array key "collation" HOT 6
- Does not work for PostgreSQL v15 HOT 6
- Filament support HOT 6
- ErrorException: Array to string conversion HOT 2
- Is compatible with Astrotomic/laravel-translatable? HOT 1
- getFilamentAttributeNameAndLocale Returns an array incorrectly HOT 1
- Ignore deleted_at soft deteled field HOT 6
- Too many messages HOT 5
- Support for laravel 6.x HOT 1
- Support spatie/nova-translatable HOT 11
- Unique comparison is case sensitive HOT 3
- How to validate a single value? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-unique-translation.