hosmar27
hosmar27
FFilament
Created by hosmar27 on 9/27/2024 in #❓┊help
How to switch/invert toggle in Filament
Basically what I want to do is, whenever a toggle is true, the other has to be false. I couldn't find my latest code so I only have this code to show:
Toggle::make('pergunta'),
Toggle::make('requisito'),
Toggle::make('pergunta'),
Toggle::make('requisito'),
6 replies
FFilament
Created by hosmar27 on 8/22/2024 in #❓┊help
Dynamically change Form component in Repeater
Just want to say that I'm not an expert in php or laravel or filament. Basically I'm doing a quiz, and I'm facing this issue where I want some of the questions to be toggle or just a textInput, this is my current code inside repeater (only the schema):
->schema(function ($record) {

$userCargoFormulario = DB::table('user_cargo_formulario as ucf')
->join('cargo_formulario as cf','ucf.cargo_formulario_id','=','cf.id')
->where('ucf.user_id', auth()->id())->get('tipo_id')->toArray();

// dd($userCargoFormulario);

if($userCargoFormulario[0]->tipo_id == 3){
return TextInput::make('resposta');
}
})
->schema(function ($record) {

$userCargoFormulario = DB::table('user_cargo_formulario as ucf')
->join('cargo_formulario as cf','ucf.cargo_formulario_id','=','cf.id')
->where('ucf.user_id', auth()->id())->get('tipo_id')->toArray();

// dd($userCargoFormulario);

if($userCargoFormulario[0]->tipo_id == 3){
return TextInput::make('resposta');
}
})


another example is that if(tipo_id == 3) should return toggle::make('resposta') but this is the error returned:
5 replies
FFilament
Created by hosmar27 on 7/25/2024 in #❓┊help
Pass array as parameter in Resource::getUrl
Is it possible? I need to pass the $record that has an Id and the $formulario has other Ids, they'ew connected by a pivot table since they have a many to many relationship. Just want to add that I'm a begginer in php . my code:
return CargoResource::getUrl('form', ['record' => $cargo->id, 'formulario' => $formulario]);
return CargoResource::getUrl('form', ['record' => $cargo->id, 'formulario' => $formulario]);
error returned: Missing required parameters for [Route: filament.admin.resources.cargos.form] [URI: admin/cargos/{record}/mount/{formulario}] [Missing parameters: "id":4, "id":9, "id":33, "id":34].
7 replies
FFilament
Created by hosmar27 on 7/24/2024 in #❓┊help
Eloquent query inside foreach
Is it possible?
12 replies
FFilament
Created by hosmar27 on 7/18/2024 in #❓┊help
Repeater relationship returns null
So, I have an issue where my relationship can't be found by repeater in my custom page, I want it to display every 'pergunta' inside the table formulario but I can't find the solution , this is the error returned: Call to a member function cargoFormulario() on null here's the code:
class Perguntas extends Page implements HasForms
{
use InteractsWithForms;

protected static ?string $model = Pergunta::class;
class Perguntas extends Page implements HasForms
{
use InteractsWithForms;

protected static ?string $model = Pergunta::class;
now the forms:
return $form
->schema([
Repeater::make('cargoFormulario')

->relationship()
->schema([
TextInput::make('texto')
])
]);
return $form
->schema([
Repeater::make('cargoFormulario')

->relationship()
->schema([
TextInput::make('texto')
])
]);
my model:
class Pergunta extends Model
{
protected $table = 'formularios';
protected $guarded = ['id'];
use HasFactory;

public function cargoFormulario()
{
$this->hasMany(CargoFormulario::class, 'id', 'formulario_id');
}
}
class Pergunta extends Model
{
protected $table = 'formularios';
protected $guarded = ['id'];
use HasFactory;

public function cargoFormulario()
{
$this->hasMany(CargoFormulario::class, 'id', 'formulario_id');
}
}
Only to give you guys more context about what I'm doing, a 'cargo' has many 'formulario' and a 'formulario' has many 'cargo'.
74 replies
FFilament
Created by hosmar27 on 6/13/2024 in #❓┊help
Is there any problem if I delete a relation manager just by deleting the created file? Could this co
After seeing that a relation was wrong, I deleted the file and redid another one, and in this one I did it correctly and it was working well, however when using forms and saving data in my pivo table I saw that I can save the same id more than once, Could the problem be related to me having deleted the file manually?
11 replies