Yuvraj Timalsina
Yuvraj Timalsina
FFilament
Created by Yuvraj Timalsina on 8/21/2024 in #❓┊help
Problem using Wizard in Custom Filament Page
Typed property Filament\Forms\Components\Component::$container must not be accessed before initialization
<?php

namespace App\Filament\Advisor\Pages;

use App\Models\Advisor;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Wizard;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Pages\Page;

class ProfileInformation extends Page
{
use InteractsWithForms;

public ?array $data = [];

public Advisor $record;

protected static ?string $navigationIcon = 'heroicon-o-credit-card';

protected static string $view = 'filament.advisor.pages.profile-information';

public function mount(): void
{
$this->record = Advisor::findorFail(auth()->id());

$this->form->fill($this->record->attributesToArray());
}

public function form(Form $form): Form
{
return $form
->schema([
Wizard::make([
Wizard\Step::make('Info')
->schema([
TextInput::make('name'),
]),
]),
])
->statePath('data')
->model(Advisor::class);
}

public function save(): void
{
$data = $this->form->getState();

$this->record->update($data);

Notification::make()->success()->title('Saved')->send();
}
}
<?php

namespace App\Filament\Advisor\Pages;

use App\Models\Advisor;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Wizard;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Pages\Page;

class ProfileInformation extends Page
{
use InteractsWithForms;

public ?array $data = [];

public Advisor $record;

protected static ?string $navigationIcon = 'heroicon-o-credit-card';

protected static string $view = 'filament.advisor.pages.profile-information';

public function mount(): void
{
$this->record = Advisor::findorFail(auth()->id());

$this->form->fill($this->record->attributesToArray());
}

public function form(Form $form): Form
{
return $form
->schema([
Wizard::make([
Wizard\Step::make('Info')
->schema([
TextInput::make('name'),
]),
]),
])
->statePath('data')
->model(Advisor::class);
}

public function save(): void
{
$data = $this->form->getState();

$this->record->update($data);

Notification::make()->success()->title('Saved')->send();
}
}
1 replies
FFilament
Created by Yuvraj Timalsina on 6/13/2024 in #❓┊help
Wizard Step did not auto scroll to reveal heading only its active state and form changed.
No description
3 replies
FFilament
Created by Yuvraj Timalsina on 6/12/2024 in #❓┊help
Call to a member function associate() on null
Student
public function englishExams(): BelongsToMany
{
return $this->belongsToMany(EnglishExam::class, 'english_exam_student');
}
public function englishExams(): BelongsToMany
{
return $this->belongsToMany(EnglishExam::class, 'english_exam_student');
}
EnglishExam
public function students(): BelongsToMany
{
return $this->belongsToMany(Student::class, 'english_exam_student');
}
public function students(): BelongsToMany
{
return $this->belongsToMany(Student::class, 'english_exam_student');
}
StudentResource
Repeater::make('englishExams')
->relationship()
->schema([
Select::make('english_exam_id')
->label('English Exam')
->options(EnglishExam::all()->pluck('title', 'id'))
->required(),
TextInput::make('speaking_score')
->label('Speaking Score')
->numeric()
->required(),
TextInput::make('reading_score')
->label('Reading Score')
->numeric()
->required(),
TextInput::make('writing_score')
->label('Writing Score')
->numeric()
->required(),
])
->columns(4)
->label('English Exams'),
Repeater::make('englishExams')
->relationship()
->schema([
Select::make('english_exam_id')
->label('English Exam')
->options(EnglishExam::all()->pluck('title', 'id'))
->required(),
TextInput::make('speaking_score')
->label('Speaking Score')
->numeric()
->required(),
TextInput::make('reading_score')
->label('Reading Score')
->numeric()
->required(),
TextInput::make('writing_score')
->label('Writing Score')
->numeric()
->required(),
])
->columns(4)
->label('English Exams'),
I get "Call to a member function associate() on null"
2 replies
FFilament
Created by Yuvraj Timalsina on 4/7/2024 in #❓┊help
How to pass parameter to custom middleware?
->authMiddleware([
Authenticate::class,
CheckRole::class,
]);
->authMiddleware([
Authenticate::class,
CheckRole::class,
]);
How do i pass parameter to CheckRole::class in AdminPanelProvider filamentphp?
public function handle(Request $request, Closure $next, Role $requiredRole): Response
{
$userRole = $request->user()->role;

if ($userRole !== $requiredRole) {
$selfPanelRoute = Filament::getPanel($userRole->value)->getId();

return redirect($selfPanelRoute);
}

return $next($request);
}
public function handle(Request $request, Closure $next, Role $requiredRole): Response
{
$userRole = $request->user()->role;

if ($userRole !== $requiredRole) {
$selfPanelRoute = Filament::getPanel($userRole->value)->getId();

return redirect($selfPanelRoute);
}

return $next($request);
}
2 replies
FFilament
Created by Yuvraj Timalsina on 9/24/2023 in #❓┊help
How do I add requiresConfirmation to ToggleColumn and SelectColumn in Table?
Is there a way to add requiresConfirmation modal in these columns?
Tables\Columns\ToggleColumn::make('status'),
Tables\Columns\SelectColumn::make('category_id')
Tables\Columns\ToggleColumn::make('status'),
Tables\Columns\SelectColumn::make('category_id')
8 replies