F
Filament13mo ago
myster

Problems using JSON from Repeater and saving in mysql

I followed the documentation to use Repeater but was unsuccessful. Below is a printout of the code snippet! In mysql the columns are in JSON.
No description
No description
No description
18 Replies
LeandroFerreira
LeandroFerreira13mo ago
read #✅┊rules before posting please
myster
mysterOP13mo ago
Leandro, I attached a printout of the code.
LeandroFerreira
LeandroFerreira13mo ago
No description
myster
mysterOP13mo ago
It's very disorganized if you send it here. Look:
Section::make('Top produtos Vendidos')
->icon('heroicon-m-fire')
->description('A Vistune.ai quer priorizar a venda dos seus produtos mais vendidos!')
->schema([
Repeater::make('')
->schema([
TextInput::make('top_produto')
->hintIcon('heroicon-m-question-mark-circle', tooltip: 'Need some more information?')
->placeholder('Jon, Mary, Tom, Léo...')
->required()
->prefixIcon('heroicon-o-fire')
->label('Nome do Produto:'),
TextInput::make('link_top_produto')
->hintIcon('heroicon-m-question-mark-circle', tooltip: 'Need some more information?')
->placeholder('Jon, Mary, Tom, Léo...')
->url()
->prefixIcon('heroicon-o-fire')
->label('Link do Produto:')
->required(),
])->columns(2)
->addActionLabel('Adicionar Produto')
])
->collapsed(),
Section::make('Top produtos Vendidos')
->icon('heroicon-m-fire')
->description('A Vistune.ai quer priorizar a venda dos seus produtos mais vendidos!')
->schema([
Repeater::make('')
->schema([
TextInput::make('top_produto')
->hintIcon('heroicon-m-question-mark-circle', tooltip: 'Need some more information?')
->placeholder('Jon, Mary, Tom, Léo...')
->required()
->prefixIcon('heroicon-o-fire')
->label('Nome do Produto:'),
TextInput::make('link_top_produto')
->hintIcon('heroicon-m-question-mark-circle', tooltip: 'Need some more information?')
->placeholder('Jon, Mary, Tom, Léo...')
->url()
->prefixIcon('heroicon-o-fire')
->label('Link do Produto:')
->required(),
])->columns(2)
->addActionLabel('Adicionar Produto')
])
->collapsed(),
protected $casts = [
'top_produto' => 'array',
'link_top_produto' => 'array'
];
protected $casts = [
'top_produto' => 'array',
'link_top_produto' => 'array'
];
I believe the error is not in the code. Maybe there's something missing that I missed. In the database, the column is already formatted for JSON.
LeandroFerreira
LeandroFerreira13mo ago
não é que fica desorganizado, é que vc nao formatou o código pra inserir aqui, e nem adicionou a tag php no markdown O nome do seu repeater na verdade tem que ser a sua coluna... vc está declarando um repeater sem nome
myster
mysterOP13mo ago
putsss So in the repeater I add the column name and in TextInput the name of my json variable? Column: 'Product' {"variable":"value"} Something like?
LeandroFerreira
LeandroFerreira13mo ago
sim
myster
mysterOP13mo ago
If you could show me how to format it, please, next time I won't make the same mistake 😅
LeandroFerreira
LeandroFerreira13mo ago
copia exatamente como está no item 4
myster
mysterOP13mo ago
Beauty, thanks I put the name of the column in the Repeater and any names in the textinput. But it did not work. Do these names need to be real in the database?
Section::make('Top products sold')
->icon('heroicon-m-fire')
->description('Vistune.ai wants to prioritize the sale of its best-selling products!')
->schema([
Repeater::make('top_produto')
->schema([
TextInput::make('product')
->hintIcon('heroicon-m-question-mark-circle', tooltip: 'Need some more information?')
->placeholder('Jon, Mary, Tom, Léo...')
->required()
->prefixIcon('heroicon-o-fire')
->label('Product Name:'),
TextInput::make('link')
->hintIcon('heroicon-m-question-mark-circle', tooltip: 'Need some more information?')
->placeholder('Jon, Mary, Tom, Léo...')
->url()
->prefixIcon('heroicon-o-fire')
->label('Product Link:')
->required(),
])->columns(2)
->addActionLabel('Add Product')
])
->collapsed(),
Section::make('Top products sold')
->icon('heroicon-m-fire')
->description('Vistune.ai wants to prioritize the sale of its best-selling products!')
->schema([
Repeater::make('top_produto')
->schema([
TextInput::make('product')
->hintIcon('heroicon-m-question-mark-circle', tooltip: 'Need some more information?')
->placeholder('Jon, Mary, Tom, Léo...')
->required()
->prefixIcon('heroicon-o-fire')
->label('Product Name:'),
TextInput::make('link')
->hintIcon('heroicon-m-question-mark-circle', tooltip: 'Need some more information?')
->placeholder('Jon, Mary, Tom, Léo...')
->url()
->prefixIcon('heroicon-o-fire')
->label('Product Link:')
->required(),
])->columns(2)
->addActionLabel('Add Product')
])
->collapsed(),
LeandroFerreira
LeandroFerreira13mo ago
qual o nome da sua coluna no banco de dados?
myster
mysterOP13mo ago
top_product It's for JSON
LeandroFerreira
LeandroFerreira13mo ago
fillable também né?
myster
mysterOP13mo ago
yess I found the error, thanks for the help. The mount() function was not configured to show json columns. Add the mount() function to convert to array and it worked.
Dennis Koch
Dennis Koch13mo ago
Hey guys, it's nice that you get personal help, but not everybody speaks your language.
myster
mysterOP13mo ago
Hey friend, you're right! I will put my lines in English!!
LeandroFerreira
LeandroFerreira13mo ago
#pt-br
Want results from more Discord servers?
Add your server