FantonioMotta
Group resource list without model ID
I'm trying to create a page that will bring the records of Student Certificates from the group grouped by Id_student, where I will have a second screen later on that will list the certificates of a specific student selected, but in this case, when I do the Group By, it will return this to me. error "SQLSTATE[42000]: Syntax error or access violation: 1055 'dash_unidesco.mc_certificado_aluno.id_aluno_certificado' isn't in GROUP BY", how can I do this group by?
In model "CertificadoAluno" the id would be id_certificado_aluno
in Group By I am using another field
class CertificadoAlunoResource extends Resource
{
protected static ?string $model = CertificadoAluno::class;
protected static ?string $navigationIcon = 'heroicon-o-collection';
protected static ?string $navigationGroup = 'Micro Certificado';
protected static ?string $navigationLabel = 'Certificado Alunos';
protected static ?string $label = 'Controle de Certificado Alunos';
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()->select('*')->groupBY('id_aluno');
}
...
}
If you need more information, just ask
1 replies
Bringing and Saving Previous Selections When Editing Page with 'Select' Field
Hello good afternoon,
I needed help
On one of my screens I have a Select field where your options are specific through a database query
Select::make('discipline')
->multiple()
->options(function (callable $get){
$disciplines = Curso::select('tb_disciplina.id_disciplina', 'tb_disciplina.descricao')
->join('tb_periodo', 'tb_curso.id_curso', 'tb_periodo.id_curso')
->join('tb_disciplina', 'tb_periodo.id_periodo', 'tb_disciplina.id_periodo')
->where('tb_curso.id_curso', $get('id_curso'))
->where('tb_curso.status', 'Ativo')
->orderBy('tb_periodo.nome');
return $disciplinas->pluck('tb_disciplina.descricao', 'tb_disciplina.id_disciplina');
})
When subjects are selected, it saves this information in another table in the bank.
What do I need to know and when I edit the page, how do I bring what was previously selected and save it in the other table
2 replies
Bringing and Saving Previous Selections When Editing Page with 'Select' Field
Hello good afternoon,
I needed help
On one of my screens I have a Select field where your options are specific through a database query
Select::make('discipline') ->multiple() ->options(function (callable $get){ $disciplines = Curso::select('tb_disciplina.id_disciplina', 'tb_disciplina.descricao') ->join('tb_periodo', 'tb_curso.id_curso', 'tb_periodo.id_curso') ->join('tb_disciplina', 'tb_periodo.id_periodo', 'tb_disciplina.id_periodo') ->where('tb_curso.id_curso', $get('id_curso')) ->where('tb_curso.status', 'Ativo') ->orderBy('tb_periodo.nome'); return $disciplinas->pluck('tb_disciplina.descricao', 'tb_disciplina.id_disciplina'); })When subjects are selected, it saves this information in another table in the bank. What do I need to know and when I edit the page, how do I bring what was previously selected and save it in the other table
1 replies
Query an item in a table in the Database and insert one in the front column
Hello good afternoon
I needed to know if there is any way in the Resources of FilamentPHP to query an item from a table in the Database in the case of Item Code in Stock (PAT), if you have this item in the table mark it as "OK" in the Status column
Att.
3 replies