Yuvraj Timalsina
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
Call to a member function associate() on null
Student
EnglishExam
StudentResource
I get "Call to a member function associate() on null"
public function englishExams(): BelongsToMany
{
return $this->belongsToMany(EnglishExam::class, 'english_exam_student');
}
public function englishExams(): BelongsToMany
{
return $this->belongsToMany(EnglishExam::class, 'english_exam_student');
}
public function students(): BelongsToMany
{
return $this->belongsToMany(Student::class, 'english_exam_student');
}
public function students(): BelongsToMany
{
return $this->belongsToMany(Student::class, 'english_exam_student');
}
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'),
2 replies
How to pass parameter to custom middleware?
->authMiddleware([
Authenticate::class,
CheckRole::class,
]);
->authMiddleware([
Authenticate::class,
CheckRole::class,
]);
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
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