F
Filament14mo 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
LeandroFerreira14mo ago
read #✅┊rules before posting please
myster
mysterOP14mo ago
Leandro, I attached a printout of the code.
LeandroFerreira
LeandroFerreira14mo ago
No description
myster
mysterOP14mo 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
LeandroFerreira14mo 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
mysterOP14mo 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
LeandroFerreira14mo ago
sim
myster
mysterOP14mo ago
If you could show me how to format it, please, next time I won't make the same mistake 😅
LeandroFerreira
LeandroFerreira14mo ago
copia exatamente como está no item 4
myster
mysterOP14mo 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
LeandroFerreira14mo ago
qual o nome da sua coluna no banco de dados?
myster
mysterOP14mo ago
top_product It's for JSON
LeandroFerreira
LeandroFerreira14mo ago
fillable também né?
myster
mysterOP14mo 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 Koch14mo ago
Hey guys, it's nice that you get personal help, but not everybody speaks your language.
myster
mysterOP14mo ago
Hey friend, you're right! I will put my lines in English!!
LeandroFerreira
LeandroFerreira14mo ago
#pt-br

Did you find this page helpful?