ROOT-LEE
ROOT-LEE
FFilament
Created by ROOT-LEE on 12/16/2023 in #❓┊help
Redirecting to URL from selected option
I'm working on a custom page where users can select a project from a dropdown list. When a project is selected, I need to redirect the user to a to the project selected;but for some reason it's not working. Here is my code:
class Board extends Page implements HasForms
{

use InteractsWithForms;
.....
public function mount(): void
{
$this->form->fill();
}

protected function getFormSchema(): array
{
return [
Card::make()
->schema([
Grid::make()
->columns(1)
->schema([
Select::make('project')
->label(__('project.title'))
->required()
->searchable()
->live()

->options(fn() => Project::pluck('title', 'id')->toArray())
->afterStateUpdated(fn() => $this->search())

,

]),
]),
];
}

public function search(): void
{
$data = $this->form->getState();
$project = Project::find($data['project']);

$this->redirect(route('filament.pages.RoadMap/{project}', ['project' => $project]));

}
class Board extends Page implements HasForms
{

use InteractsWithForms;
.....
public function mount(): void
{
$this->form->fill();
}

protected function getFormSchema(): array
{
return [
Card::make()
->schema([
Grid::make()
->columns(1)
->schema([
Select::make('project')
->label(__('project.title'))
->required()
->searchable()
->live()

->options(fn() => Project::pluck('title', 'id')->toArray())
->afterStateUpdated(fn() => $this->search())

,

]),
]),
];
}

public function search(): void
{
$data = $this->form->getState();
$project = Project::find($data['project']);

$this->redirect(route('filament.pages.RoadMap/{project}', ['project' => $project]));

}
Thanks
3 replies
FFilament
Created by ROOT-LEE on 8/27/2023 in #❓┊help
Unable to save hidden() fields to database !!
Hi,
Step::make('Etap 7')
->description("Montant Octroyé")
->schema([
Fieldset::make('Montant Octroyé')
->relationship('granted_amount')
->schema([

TextInput::make('granted_amount')
->label('Montant Octroyé'),


TextInput::make('current_year')
->label('current_year'),


TextInput::make('annee_inscription')
->label("Année d'inscription")->hiddenn()
->default(date("Y") . "/" . date("Y") + 1),

]),
]),
Step::make('Etap 7')
->description("Montant Octroyé")
->schema([
Fieldset::make('Montant Octroyé')
->relationship('granted_amount')
->schema([

TextInput::make('granted_amount')
->label('Montant Octroyé'),


TextInput::make('current_year')
->label('current_year'),


TextInput::make('annee_inscription')
->label("Année d'inscription")->hiddenn()
->default(date("Y") . "/" . date("Y") + 1),

]),
]),
And when I debug
protected function afterCreate(): void
{
dd("After", $this->data);

}
protected function afterCreate(): void
{
dd("After", $this->data);

}
The data is displayed
"granted_amount" => array:3 [
"granted_amount" => null
"current_year" => null
"annee_inscription" => "2023/2024"
]
"granted_amount" => array:3 [
"granted_amount" => null
"current_year" => null
"annee_inscription" => "2023/2024"
]
Do you have any idea? Thanks.
10 replies
FFilament
Created by ROOT-LEE on 8/26/2023 in #❓┊help
[afterStateUpdated with Form Wizard]Change a dependent field value that is present in another step
Hello , Is there a way to change a value that is present in a different Step? Create page(Form Wizard) :
Step::make('Etape 2')
->description('IDENTIFICTION DU SUJET DE THESE')
->schema([
Fieldset::make('IDENTIFICTION DU SUJET DE THESE')
->relationship('these')
->schema([

Select::make('domaine_id')
->label('Domaine')
->reactive()
->options(Domaine::all()->pluck('acronyme', 'id'))
->required()
->afterStateUpdated(function (Closure $set, $state, callable) {

$set('granted_amount', $state);
})
->searchable(),

]),

Step::make('Etap 7')
->description("Montant Octroyé")
->schema([
Fieldset::make('Montant Octroyé')
->relationship('granted_amount')
->schema([
TextInput::make('granted_amount') ->label('Montant Octroyé')
->reactive(),

]),
]),
Step::make('Etape 2')
->description('IDENTIFICTION DU SUJET DE THESE')
->schema([
Fieldset::make('IDENTIFICTION DU SUJET DE THESE')
->relationship('these')
->schema([

Select::make('domaine_id')
->label('Domaine')
->reactive()
->options(Domaine::all()->pluck('acronyme', 'id'))
->required()
->afterStateUpdated(function (Closure $set, $state, callable) {

$set('granted_amount', $state);
})
->searchable(),

]),

Step::make('Etap 7')
->description("Montant Octroyé")
->schema([
Fieldset::make('Montant Octroyé')
->relationship('granted_amount')
->schema([
TextInput::make('granted_amount') ->label('Montant Octroyé')
->reactive(),

]),
]),
Thanks 🙂
1 replies
FFilament
Created by ROOT-LEE on 4/28/2023 in #❓┊help
Storing repeater data in a pivot table
Hi ,ho to save data from repeater into pivot table? Here's the Models and the table I have. ---- Tables: expert :id, first_name,last_name,... diplome :id name,... diplome_experts : id,diplome_id,expert_id,year,... Expert Model :
public function diplome_expert(): BelongsToMany
{
return $this->belongsToMany(Diplome::class)
->withPivot('year', 'specialite_id', 'etablissement_id')
->withTimestamps();
}
public function diplome_expert(): BelongsToMany
{
return $this->belongsToMany(Diplome::class)
->withPivot('year', 'specialite_id', 'etablissement_id')
->withTimestamps();
}
Expert (Livewire)
Forms\Components\Section::make('Diplômes universitaires obtenus') ->schema([ Forms\Components\Repeater::make('diplome_expert')->label('Diplômes universitaires obtenus')
->relationship()
->schema([ Forms\Components\Select::make('diplome_id')->options(fn() => Diplome::pluck('name_fr', 'id')->toArray())->searchable()->label('Diplome'),
Forms\Components\TextInput::make('year')->label('Année'),

Forms\Components\Select::make('specialite_id')->options(fn() => Specialite::pluck('name_fr', 'id')->toArray())->searchable()->label('Spécialité'),
Forms\Components\Select::make('etablissement_id')->options(fn() => Etablissement::pluck('libelle_fr', 'id')->toArray())->searchable()->label('Etablissement'),

])->defaultItems(1)->createItemButtonLabel('Ajouter un autre dilpome universitaitre')->columns(2)->collapsible()->required(),
])->collapsed(),

]),
Forms\Components\Section::make('Diplômes universitaires obtenus') ->schema([ Forms\Components\Repeater::make('diplome_expert')->label('Diplômes universitaires obtenus')
->relationship()
->schema([ Forms\Components\Select::make('diplome_id')->options(fn() => Diplome::pluck('name_fr', 'id')->toArray())->searchable()->label('Diplome'),
Forms\Components\TextInput::make('year')->label('Année'),

Forms\Components\Select::make('specialite_id')->options(fn() => Specialite::pluck('name_fr', 'id')->toArray())->searchable()->label('Spécialité'),
Forms\Components\Select::make('etablissement_id')->options(fn() => Etablissement::pluck('libelle_fr', 'id')->toArray())->searchable()->label('Etablissement'),

])->defaultItems(1)->createItemButtonLabel('Ajouter un autre dilpome universitaitre')->columns(2)->collapsible()->required(),
])->collapsed(),

]),
Error captured : SQLSTATE[42S22]: Column not found: 1054 Unknown column 'diplome_id' in 'field list' (Connection: mysql, SQL: insert into **diplomes** (diplome_id, year, specialite_id, etablissement_id, updated_at, created_at) ------------ The data going to be stored in the 'diplome' table and not in the 'diplome_ experts' pivot table? Any help , Thanks
11 replies
FFilament
Created by ROOT-LEE on 4/11/2023 in #❓┊help
Research of null value in relation (belongs to many)
Hi✋ I have a list of users(personnes) who have a location. personnel table : id ,id_corp,.... lieu_affectation_histories: id , personnel_id,lieu_affectation_id,... lieu_affectaion : id , name_fr,name_ar,.... Model Personnel :
public function lieuAffectation()
{
return $this->belongsToMany(LieuAffectation::class, LieuAffectationHitories::class);
}
public function lieuAffectation()
{
return $this->belongsToMany(LieuAffectation::class, LieuAffectationHitories::class);
}
Personnel Ressource :
Tables\Filters\SelectFilter::make('id')
->relationship('lastLieuAffectation', 'name_fr')
->multiple()
->label("Lieu d'affectaion")
->options(
LieuAffectation::all()->pluck('name_fr', 'id')->toArray()
// LieuAffectation::all()->pluck('name_fr', 'id')->prepand('null','')->toArray()

),
Tables\Filters\SelectFilter::make('id')
->relationship('lastLieuAffectation', 'name_fr')
->multiple()
->label("Lieu d'affectaion")
->options(
LieuAffectation::all()->pluck('name_fr', 'id')->toArray()
// LieuAffectation::all()->pluck('name_fr', 'id')->prepand('null','')->toArray()

),
**What I'm looking for, is a search of all personnel who don't have a location. Thanks.
5 replies