Closed martinschenk closed 3 years ago
Hi @martinschenk. Could you possibly provide some more details as it's difficult to work out what's going on?
Hi Matthew
Sorry for not explaining well. The problem seems to be the database column name of the enum field. If it’s written in capitalised letters like f.e. “COLUMN”, the nova enum field shows empty. And if the name of the column is f.e. “_column” it works everything perfect. Laravel 8. Php 7.4 MySQL 5.7 nova latest version
Regards, Martin
Matthew Poulter @.***> schrieb am Do. 22. Apr. 2021 um 16:04:
Hi @martinschenk https://github.com/martinschenk. Could you possibly provide some more details as it's difficult to work out what's going on?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/simplesquid/nova-enum-field/issues/34#issuecomment-824871071, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE3HM3VLSGCUVVVZWJR5G3TKAUG7ANCNFSM43MQ4W7Q .
here a more detailed explication:
the mysql database table has an enum column named "BACKOFFICE". The ENUM definition is: 'S','N', Allow NULL, Default N
Record 1 of the table has set the ENUM field to 'S'
I created the class SiNo:
final class SiNo extends Enum
{
const S = 'S';
const N = 'N';
}
My Model:
class Perfil extends Model
{
use CastsEnums;
protected $casts = [
'BACKOFFICE' => SiNo::class
];
My Nova Model:
Enum::make('BACKOFFICE')->attach(SiNo::class),
If i call now the nova page,
No i make just some very small changes to get it working: 1.) i change the name of the table from BACKOFFICE to _backoffice 2.) i change in the model
'_backoffice' => SiNo::class
3.) i change in the nova model
Enum::make('_backoffice')->attach(SiNo::class),
Now it works all perfect!
In the list view i get the real database values and in the edit view he show also the correct values.
My problem: As the database is used also by other services, i can not rename the column name from BACKOFFICE to _backoffice.
So how can i get it to work please?
mysql Ver 14.14 Distrib 5.7.32, for osx10.15 PHP 7.4.16 (cli) Laravel 8
Thanks for the further details. I will see if I can replicate the problem this weekend.
Great Matthew, thank you very much!
El vie, 23 abr 2021 a las 10:25, Matthew Poulter @.***>) escribió:
Thanks for the further details. I will see if I can replicate the problem this weekend.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/simplesquid/nova-enum-field/issues/34#issuecomment-825490706, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE3HM3XO45C4B5H7JOYH3DTKEVIRANCNFSM43MQ4W7Q .
Resolved.
I added in config/datababese.php
PDO::ATTR_CASE => PDO::CASE_LOWER
'mysql' => [
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
PDO::ATTR_CASE => PDO::CASE_LOWER
]) : [],
],
then i had to change all field names in the code to lowercase.
Now works, fine. Thanks
Okay great! Glad to hear it. This sounds like quite an edge case scenario, so I'll close the issue for now unless someone else runs into it.
I cant change the database column name because its used by others. When the column name of the enum field is "_backoffice" the nove enum filed works perfect. But when the column name is "BACKOFFICE" the nova enum column and filed shows empty.