Comments (7)
Hi @martinschenk. Could you possibly provide some more details as it's difficult to work out what's going on?
from nova-enum-field.
from nova-enum-field.
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,
- the index (list) view of the BACKOFFICE field shows up empty = "----" like in the first screenshot above.
- the edit field of the record shows: "choose an option" with the dropdown and the possibilities S and N. (But as you remember, in the database, there is set S.
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
from nova-enum-field.
Thanks for the further details. I will see if I can replicate the problem this weekend.
from nova-enum-field.
from nova-enum-field.
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
from nova-enum-field.
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.
from nova-enum-field.
Related Issues (20)
- Laravel 7 support
- Nullable field HOT 3
- Convert to GitHub Actions
- Support non int values HOT 1
- Laravel 8 Support Please HOT 3
- Can we apply the enum resolution on the index? HOT 10
- Screenshot link results in 404
- Flagged enum HOT 1
- Field declaring field is required even with selected value HOT 4
- Default filter value HOT 1
- Is there any way to translate enumeration in field HOT 1
- EnumBooleanFilter and EnumFilter not working properly HOT 6
- nullable() not respected by Enum::make HOT 8
- Support 4 version of bensampo/laravel-enum HOT 3
- Support 5 version of bensampo/laravel-enum HOT 2
- Nova V4 support HOT 8
- Filter shows selected enum option even when all enum options are unchecked HOT 4
- Attribute Casting Assumption HOT 2
- Add Filter HOT 1
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 nova-enum-field.