Homd
Homd
Explore posts from servers
FFilament
Created by Homd on 10/25/2023 in #❓┊help
401 Unauthorized When Uploading File
Just want to post for future references. After installing SSL, I have this problem where I could not upload any file over livewire. Upon console inspection, turn out for some reason the request got 401 Unauthorized error. I tried to check my middleware, http setting and htaccess with no avail. For those of you who encounter same problem, you can easily fix it by commenting:
abort_unless(request()->hasValidSignature(), 401)
abort_unless(request()->hasValidSignature(), 401)
in
vendor/livewire/livewire/src/Controllers/FileUploadHandler
.php
vendor/livewire/livewire/src/Controllers/FileUploadHandler
.php
or following this fix: https://github.com/livewire/livewire/issues/1216
2 replies
FFilament
Created by Homd on 10/15/2023 in #❓┊help
Sortable() and getStateUsing
I created a custom text column to display a calculated value (display user scores). The database itself actually doesn't have this column. All things work perfectly except when I try to make it sortable, which return "Column Score not Found". Is there anyway for me to sort it based on current state rather than database value?
5 replies
FFilament
Created by Homd on 10/14/2023 in #❓┊help
Understanding how time works.
Let say I live in Indonesia (UTC+7). My server time is UTC. My laravel setting is untouched. Then I create a date picker for attribute
start_time
start_time
in
event model
event model
. The event will be start in 14 October 2023 - 20:00 (8PM) INDONESIA TIME So the user input 14 October 2023 - 20:00 (8PM) . 1. Should I modify data before saving to convet those time into UTC? or does laravel/filament/mysql detect this and automatically and convert it to UTC for me? 2. What if there's multiple user with different timezone?
5 replies
FFilament
Created by Homd on 9/19/2023 in #❓┊help
Dynamically Hidden Repeater Is Not Working
I have a repeater which visibility is dependent to another select field.
return $form
->columns(3)
->schema([
Forms\Components\Select::make('unit_id')->label("Unit") ->options(fn ($livewire) => Exercise::where('id', $livewire->ownerRecord->id)->pluck("name","id")) ->default(fn ($livewire) => Exercise::find($livewire->ownerRecord->id)->id)
->disabled(true)
->required(),
Forms\Components\TextInput::make('score')->label("Score")->required()

->disabled(false),
Forms\Components\Select::make('exercise_type_id')->label("Question Type")
->relationship('exerciseType', 'name')
->default(1)
->required(),
Forms\Components\RichEditor::make("question")->columnSpan(3)->required(),
Repeater::make('answerlist')
->defaultItems(4)
->relationship('multipleChoiceAnswers')
->label("Multiple Choice Answer Option")
->grid(2)

->schema([
Forms\Components\TextInput::make('text')->label("Text Answer"),
Forms\Components\FileUpload::make('img')->label("Image Answer")
->directory('module-images')
->storeFileNamesIn("original_filename"),
Forms\Components\Checkbox::make('is_correct_option')->label("Mark Answer As Correct")->default(false),


])->columnSpan(3)->required()->hidden(fn(Callable $get) => ($get('exercise_type_id') !== 1)),
]);
return $form
->columns(3)
->schema([
Forms\Components\Select::make('unit_id')->label("Unit") ->options(fn ($livewire) => Exercise::where('id', $livewire->ownerRecord->id)->pluck("name","id")) ->default(fn ($livewire) => Exercise::find($livewire->ownerRecord->id)->id)
->disabled(true)
->required(),
Forms\Components\TextInput::make('score')->label("Score")->required()

->disabled(false),
Forms\Components\Select::make('exercise_type_id')->label("Question Type")
->relationship('exerciseType', 'name')
->default(1)
->required(),
Forms\Components\RichEditor::make("question")->columnSpan(3)->required(),
Repeater::make('answerlist')
->defaultItems(4)
->relationship('multipleChoiceAnswers')
->label("Multiple Choice Answer Option")
->grid(2)

->schema([
Forms\Components\TextInput::make('text')->label("Text Answer"),
Forms\Components\FileUpload::make('img')->label("Image Answer")
->directory('module-images')
->storeFileNamesIn("original_filename"),
Forms\Components\Checkbox::make('is_correct_option')->label("Mark Answer As Correct")->default(false),


])->columnSpan(3)->required()->hidden(fn(Callable $get) => ($get('exercise_type_id') !== 1)),
]);
This is the specific code
->hidden(fn(Callable $get) => ($get('exercise_type_id') !== 1)),
]);
->hidden(fn(Callable $get) => ($get('exercise_type_id') !== 1)),
]);
This is my select field
Forms\Components\Select::make('exercise_type_id')->label("Question Type")
->relationship('exerciseType', 'name')
->default(1)
->required(),
Forms\Components\Select::make('exercise_type_id')->label("Question Type")
->relationship('exerciseType', 'name')
->default(1)
->required(),
I've tried using
closure
closure
instead of
callable
callable
11 replies
TSDThe Swift Den
Created by Homd on 9/17/2023 in #swift-development
OnChange() doesn't trigger inside picker navigation view
For some reason the on change that I put on textfield only triggered after I close the selection view.
Picker("Game", selection: $selectedGame) {
Text("No Game Selected").tag(0 as Int?)
Section{
TextField("Search Here", text: $gv.searchTerm).onChange(of: gv.searchTerm) { newValue in
print("On Change Triggered")
searchTimer?.invalidate()
searchTimer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: false) { _ in
Task{

try await gv.fetchGames(searchQuery: newValue)

}
}
}
}


ForEach(gv.games, id: \.self) { game in
Text(game.name).tag(game.id as Int?)
}
}
.pickerStyle(.navigationLink)

}
Picker("Game", selection: $selectedGame) {
Text("No Game Selected").tag(0 as Int?)
Section{
TextField("Search Here", text: $gv.searchTerm).onChange(of: gv.searchTerm) { newValue in
print("On Change Triggered")
searchTimer?.invalidate()
searchTimer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: false) { _ in
Task{

try await gv.fetchGames(searchQuery: newValue)

}
}
}
}


ForEach(gv.games, id: \.self) { game in
Text(game.name).tag(game.id as Int?)
}
}
.pickerStyle(.navigationLink)

}
5 replies
FFilament
Created by Homd on 9/10/2023 in #❓┊help
Is it possible to get the future id of item in repeater?
I have: Question Model: - id - name - correct_answer -> references id on Question_Answers Question_Answer Model: - id - answer - question_id I want to use repeater to create question and its answer in single modal. Is there anyway I could access to-be-created Question_Asnwer and assign in to my Question's correct_answer? What's the best approach here? Thanks!
14 replies
FFilament
Created by Homd on 9/6/2023 in #❓┊help
Possible to use filament login for normal user? (non-admin)
I want to use filament login page for 2 user. User with is_admin == 1 will be directed to panel, while others will be directed to another route. Is this possible and easy to achieve? Thanks
4 replies
FFilament
Created by Homd on 8/31/2023 in #❓┊help
How to enable relation manager create, edit, delete while on View Page?
No description
8 replies
FFilament
Created by Homd on 8/18/2023 in #❓┊help
Pass data into custom pages?
Hi I want to pass this $record data to my custom pages. How do I do it? This is my code
Tables\Actions\Action::make("See Student Progress")->label("See Student Progress")
->url(fn (Module $record) => ClassroomResource::getUrl('progress')),
])
Tables\Actions\Action::make("See Student Progress")->label("See Student Progress")
->url(fn (Module $record) => ClassroomResource::getUrl('progress')),
])
class ProgressControl extends Page
{
protected static string $resource = ClassroomResource::class;
public Module $record;
protected static string $view = 'filament.resources.classroom-resource.pages.progress-control';
}
class ProgressControl extends Page
{
protected static string $resource = ClassroomResource::class;
public Module $record;
protected static string $view = 'filament.resources.classroom-resource.pages.progress-control';
}
5 replies
FFilament
Created by Homd on 8/16/2023 in #❓┊help
Toggle Allow Edit On and Off?
3 replies
FFilament
Created by Homd on 8/16/2023 in #❓┊help
Show Parent Relationship.
Hi guys, I need a little help figuring this out. The title might be a bit misleading, I just cannot word it better. I have 3 Model Model Level -> hasmany Model Project Model Level -> hasmany Model Classroom Now in the classroom edit page, I want to show all the project that the classroom inherit from its level. How should I approach this? Thanks!
4 replies
FFilament
Created by Homd on 8/11/2023 in #❓┊help
Modify Query Used in A Resource Page
I am a noob. I think this question already exist somehwere else but I couldn't find it. I have a User model that has 2 resource page The first resource page should only list user that has "admin" object The second resource page should only list user that has "student" object As for now, both the resource page is listing User::all() I want to be able to change the query used in each page, is there a way?
5 replies