Sanchit Patil
Sanchit Patil
FFilament
Created by Sanchit Patil on 10/8/2024 in #❓┊help
Persist current tab while using Tabs Blade component
Hello, I am using Tabs Blade component inside the filament panel page,
<x-filament::tabs>
<x-filament::tabs.item
:active="$activeTab === 'tab1'"
wire:click="$set('activeTab', 'tab1')"
>
Tab 1
</x-filament::tabs.item>

{{-- Other tabs --}}
</x-filament::tabs>
<x-filament::tabs>
<x-filament::tabs.item
:active="$activeTab === 'tab1'"
wire:click="$set('activeTab', 'tab1')"
>
Tab 1
</x-filament::tabs.item>

{{-- Other tabs --}}
</x-filament::tabs>
Is there any way i can Persist the current tab in the URL's query string? Thank you 🙂
4 replies
FFilament
Created by Sanchit Patil on 8/28/2024 in #❓┊help
Is there any way to get tenant information on login page?
Hello, I want to get tenant (team) information on login / registration page. i am currently using filament's multi tenancy for single team per user and invitations. Invited users are using team's subdomain for logging in,
->tenant(Team::class, slugAttribute: 'slug')
->tenantDomain('{tenant:slug}.example.test');
->tenant(Team::class, slugAttribute: 'slug')
->tenantDomain('{tenant:slug}.example.test');
I want to get the Team's infomation on login page, and i tried this but it is returning null.
$tenant = Filament::getTenant();
$tenant = Filament::getTenant();
Is there any way i can get this?
3 replies
FFilament
Created by Sanchit Patil on 8/8/2024 in #❓┊help
Custom Filter for Date in Relationship not working properly
No description
2 replies
FFilament
Created by Sanchit Patil on 4/4/2024 in #❓┊help
Hide Navigation (top) on certain custom pages
Hello, Would it be possible to hide top navigation on certain custom pages? I want to change login process by adding one custom page after user logged in, but i want that page to be Filament Page without Navigation. I am using this solution by LaravelDaily to change the login process & want to hide the navigation on SwitchAccountPage custom filament page. Aslo, how can i check on every page / resource of candidate panel for a candidate_id cookie if the cookie is not set then it should redirect user to SwitchAccountPage. ? Thank you in advanced. 🙂
class LoginResponse extends \Filament\Http\Responses\Auth\LoginResponse
{
public function toResponse($request): RedirectResponse|Redirector
{
if (Filament::getCurrentPanel()->getId() === 'admin') {
return redirect()->to(Dashboard::getUrl());
}

if (Filament::getCurrentPanel()->getId() === 'candidate') {
$thisuser = Auth::user();
$candidateCount = Candidate::where('email', $thisuser->email)->count();
if ($candidateCount > 1) {
// Redirect to custom page to select specific account
return redirect()->to(SwitchAccountPage::getUrl());
} else {
$candidate = Candidate::where('email', $thisuser->email)->first();
// Set candidate_id cookie
return redirect()->to(Dashboard::getUrl())->withCookie('candidate_id', $candidate->candidate_id);
}
}

return parent::toResponse($request);
}
}
class LoginResponse extends \Filament\Http\Responses\Auth\LoginResponse
{
public function toResponse($request): RedirectResponse|Redirector
{
if (Filament::getCurrentPanel()->getId() === 'admin') {
return redirect()->to(Dashboard::getUrl());
}

if (Filament::getCurrentPanel()->getId() === 'candidate') {
$thisuser = Auth::user();
$candidateCount = Candidate::where('email', $thisuser->email)->count();
if ($candidateCount > 1) {
// Redirect to custom page to select specific account
return redirect()->to(SwitchAccountPage::getUrl());
} else {
$candidate = Candidate::where('email', $thisuser->email)->first();
// Set candidate_id cookie
return redirect()->to(Dashboard::getUrl())->withCookie('candidate_id', $candidate->candidate_id);
}
}

return parent::toResponse($request);
}
}
2 replies
FFilament
Created by Sanchit Patil on 3/22/2024 in #❓┊help
Error with FileUpload in Livewire nested component
Hello All, I am using Filament forms in one of the Livewire components which is nested in another full-page Livewire component. filpond field is throwing the bellow error in the console when I upload the file the first time, Uncaught (in promise) TypeError: Cannot read properties of null (reading 'insertBefore') But it works perfectly when I try to upload the file a second time (without page reload). FileUpload in my form schema:
FileUpload::make('pmva_2')->label('Certificate')->required()
->acceptedFileTypes(['application/pdf','image/jpeg','image/png'])
->disk('public')->directory('pmva_certs'),
FileUpload::make('pmva_2')->label('Certificate')->required()
->acceptedFileTypes(['application/pdf','image/jpeg','image/png'])
->disk('public')->directory('pmva_certs'),
Form in view file:
<form>
{{ $this->form }}
@if($this->showCreateCheckout)
<x-filament::button color="info" class="mt-2" wire:click="createCheckout">
@if($this->training->course_id === 6) Request Booking @else Confirm Booking @endif
</x-filament::button>
@endif
</form>
<x-filament-actions::modals />
<form>
{{ $this->form }}
@if($this->showCreateCheckout)
<x-filament::button color="info" class="mt-2" wire:click="createCheckout">
@if($this->training->course_id === 6) Request Booking @else Confirm Booking @endif
</x-filament::button>
@endif
</form>
<x-filament-actions::modals />
Could anyone please help with this? Thank you 🙂
5 replies
FFilament
Created by Sanchit Patil on 3/5/2024 in #❓┊help
Font used in Filament
No description
6 replies
FFilament
Created by Sanchit Patil on 12/6/2023 in #❓┊help
Max Selectable Options in Checkbox List
Hello, Is there any way I can limit the Checkbox list with Max selectable options? I have around 50+ options to select from and I want users to only select any 5 options. After 5 options it should not let the user check any checkbox. currently, I am just preventing this by using rules.
CheckboxList::make('courses')
->label('Select Courses')
->options(ShopProduct::all()->whereNotNull('single_course')->pluck('product_name','single_course'))
->required()
->reactive()
->searchable()
->columns(3)
->gridDirection('row')
->extraAttributes(['class'=>'overflow-y-auto h-96 p-2'])
->rules([
fn (Get $get): Closure => function (string $attribute, $value, Closure $fail) use ($get) {
if (isset($this->product->automation->shop_trigger_automation['action']) && ($this->product->automation->shop_trigger_automation['action'] === 'select_learning_courses')) {
if($this->product->automation->shop_trigger_automation['quantity'] != count($value)) {
$fail("Please select any {$this->product->automation->shop_trigger_automation['quantity']} courses.");
}
}
},
])
CheckboxList::make('courses')
->label('Select Courses')
->options(ShopProduct::all()->whereNotNull('single_course')->pluck('product_name','single_course'))
->required()
->reactive()
->searchable()
->columns(3)
->gridDirection('row')
->extraAttributes(['class'=>'overflow-y-auto h-96 p-2'])
->rules([
fn (Get $get): Closure => function (string $attribute, $value, Closure $fail) use ($get) {
if (isset($this->product->automation->shop_trigger_automation['action']) && ($this->product->automation->shop_trigger_automation['action'] === 'select_learning_courses')) {
if($this->product->automation->shop_trigger_automation['quantity'] != count($value)) {
$fail("Please select any {$this->product->automation->shop_trigger_automation['quantity']} courses.");
}
}
},
])
Could anyone please suggest anything? 🙂 Thank you.
10 replies
FFilament
Created by Sanchit Patil on 12/5/2023 in #❓┊help
Ngnix not loading dynamic assets in production
#offtopic Does anyone have any idea about the issue of ngnix not loading assets (image files) in production (nginx) these files are from the phone-input plugin
// routes from the plugin code
Route::get('/phone-input-flags.png', function () {
return response()->file(__DIR__.'/../images/vendor/intl-tel-input/build/flags.png');
});

Route::get('/[email protected]', function () {
return response()->file(__DIR__.'/../images/vendor/intl-tel-input/build/[email protected]');
});
// routes from the plugin code
Route::get('/phone-input-flags.png', function () {
return response()->file(__DIR__.'/../images/vendor/intl-tel-input/build/flags.png');
});

Route::get('/[email protected]', function () {
return response()->file(__DIR__.'/../images/vendor/intl-tel-input/build/[email protected]');
});
I have even manually added it to the vhost file
location = /phone-input-flags.png {
try_files $uri /index.php?$query_string;
}
location = /phone-input-flags.png {
try_files $uri /index.php?$query_string;
}
still, it is being considered as a static PNG file and the call is not going to Laravel route. On the other end livewire.js is working perfectly though. Could you please help with this if you have any ideas? thank you, 🙂
2 replies
FFilament
Created by Sanchit Patil on 10/19/2023 in #❓┊help
How to handle formWizard with random fields in LiveWire component?
Hello, This might be off topic, but I really struggling with this. I am generating a form Wizard with 10 random questions, but the questions (fields) got changed each time when i click next step. I am generating Form Schema with this,
public static function getTestFormSchema($randomQuestions){
$testquestionsschema = [];
foreach ($randomQuestions as $question) {
$testquestionsschema[] = Wizard\Step::make($question->id)->hiddenLabel()->schema([self::getQuestionFieldFor($question)]);
}
return Wizard::make($testquestionsschema)->skippable()->extraAttributes(['class' => 'test']);
}

public static function getQuestionFieldFor($field){
$fieldName = "field_" . $field->id;
switch($field->question_type) {
case 'MC':
case 'TF':
$options = array_column($field->choices,'choice_text');
$options = array_combine($options, $options);
$ffield = Radio::make($fieldName)->label($field->question_text)->options($options);
break;
}
return $ffield;
}
public static function getTestFormSchema($randomQuestions){
$testquestionsschema = [];
foreach ($randomQuestions as $question) {
$testquestionsschema[] = Wizard\Step::make($question->id)->hiddenLabel()->schema([self::getQuestionFieldFor($question)]);
}
return Wizard::make($testquestionsschema)->skippable()->extraAttributes(['class' => 'test']);
}

public static function getQuestionFieldFor($field){
$fieldName = "field_" . $field->id;
switch($field->question_type) {
case 'MC':
case 'TF':
$options = array_column($field->choices,'choice_text');
$options = array_combine($options, $options);
$ffield = Radio::make($fieldName)->label($field->question_text)->options($options);
break;
}
return $ffield;
}
and loading that in my Livewire component
public function mount()
{
$this->questions = $this->test->questions()->inRandomOrder()->limit(10)->get();
$this->form->fill();
}

public function form(Form $form): Form
{
return $form
->schema([BasicHelper::getTestFormSchema($this->questions)])
->statePath('data');
}
public function mount()
{
$this->questions = $this->test->questions()->inRandomOrder()->limit(10)->get();
$this->form->fill();
}

public function form(Form $form): Form
{
return $form
->schema([BasicHelper::getTestFormSchema($this->questions)])
->statePath('data');
}
Livewire loading random records from the model with each next action request. Could anyone please help me with this? is there any better way to avoid this or load random entries with first load or page refresh only? Thank you. 🙂
2 replies
FFilament
Created by Sanchit Patil on 9/28/2023 in #❓┊help
Passing parameters to a custom page
Hello all, could anyone please help me with passing parameters to a custom page (not associated with any resource)? I am doing something wrong here?
Route::get('/trainer/attendee-sheet/{id}', \App\Filament\Trainer\Pages\AttendeeSheet::class)
->name('filament.trainer.pages.attendee-sheet');
Route::get('/trainer/attendee-sheet/{id}', \App\Filament\Trainer\Pages\AttendeeSheet::class)
->name('filament.trainer.pages.attendee-sheet');
This works when I accept the parameter in livewire style but the filament shows the Admin panel's menu when I send the parameter. /trainer/attendee-sheet/12 -> This page shows the admin panel's navigation. /trainer/attendee-sheet -> This page shows correct navigation.
8 replies
FFilament
Created by Sanchit Patil on 9/19/2023 in #❓┊help
Specific Relation Manager in Custom View
Hello, How to display individual relation managers in custom view? Is there any way to show a specific relation manager using this code snippet?
<x-filament-panels::resources.relation-managers
:active-manager="$activeRelationManager"
:managers="$this->getRelationManagers()"
:owner-record="$record"
:page-class="static::class"
/>
<x-filament-panels::resources.relation-managers
:active-manager="$activeRelationManager"
:managers="$this->getRelationManagers()"
:owner-record="$record"
:page-class="static::class"
/>
Also, would it be possible to enable CRUD operations for relation managers in the custom view page? Thank You. 🙂
9 replies
FFilament
Created by Sanchit Patil on 9/14/2023 in #❓┊help
viteTheme not working on Production
Hello All, I am using a custom theme with filament, and it is working perfectly locally. (both with npm run dev & build) but not working on production. Vite is still using this syntax to load the custom theme files on the production <script type="module" src="http://[::1]:5173/@vite/client" data-navigate-track="reload"></script><link rel="stylesheet" href="http://[::1]:5173/resources/css/filament/admin/theme.css" data-navigate-track="reload" /> my env file is set to production, i have cleared all the cache, remove node_modules and install it again on production site build on production, but still, it is not working. provider: ->viteTheme('resources/css/filament/admin/theme.css') vite.config.js
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js', 'resources/css/filament/admin/theme.css'],
refresh: true,
}),
],
});
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js', 'resources/css/filament/admin/theme.css'],
refresh: true,
}),
],
});
theme.css
@import '../../../../vendor/filament/filament/resources/css/theme.css';

@config './tailwind.config.js';

:root {
--filament-progressbar-color: #22c55e;
}
@import '../../../../vendor/filament/filament/resources/css/theme.css';

@config './tailwind.config.js';

:root {
--filament-progressbar-color: #22c55e;
}
tailwind.config.js
import preset from '../../../../vendor/filament/filament/tailwind.config.preset'

export default {
presets: [preset],
content: [
'./app/Filament/**/*.php',
'./resources/views/filament/**/*.blade.php',
'./resources/views/*.blade.php',
'./vendor/filament/**/*.blade.php',
],
plugins: [require("daisyui")]
}
import preset from '../../../../vendor/filament/filament/tailwind.config.preset'

export default {
presets: [preset],
content: [
'./app/Filament/**/*.php',
'./resources/views/filament/**/*.blade.php',
'./resources/views/*.blade.php',
'./vendor/filament/**/*.blade.php',
],
plugins: [require("daisyui")]
}
Could anyone please help me? Thank you. 🙂
10 replies
FFilament
Created by Sanchit Patil on 9/14/2023 in #❓┊help
use SideNavigation for lg breakpoint
Hello, Is there any way I can use Sidebar navigation for the screens below lg? By default, I am using TopNavigation but it is not looking that great for the screens below lg (because of the number of menu items). Thank you. 🙂
2 replies
FFilament
Created by Sanchit Patil on 9/12/2023 in #❓┊help
CreateAction not doing anything after click
Hello, I am trying to add CreateAction to a custom page but when I click on the button it doesn't do anything, not even producing any js error.
public function createNewTrainingEvent(): Action{
return CreateAction::make()
->label('New Training Event')
->model(TrainingEvent::class)
->form(TrainingEventResource::getFormSchema());
}
public function createNewTrainingEvent(): Action{
return CreateAction::make()
->label('New Training Event')
->model(TrainingEvent::class)
->form(TrainingEventResource::getFormSchema());
}
View File:
<x-filament-panels::page>
<div id='calendar-container'>
<div class="grid md:grid-cols-12 sm:grid-cols-1">
<div class="md:col-span-4 col-span-12">
{{ $this->createNewTrainingEvent }}
<x-filament-actions::modals />
</div>
<div class="md:col-span-8 col-span-12 tdta_back_calendar" wire:ignore>
<div id='calendar'></div>
</div>
</div>
</div>
</x-filament-panels::page>

@push('scripts')
<script src='https://cdn.jsdelivr.net/npm/[email protected]/index.global.min.js'></script>
<script type="module">
// full calendar scripts here
</script>
@endpush
<x-filament-panels::page>
<div id='calendar-container'>
<div class="grid md:grid-cols-12 sm:grid-cols-1">
<div class="md:col-span-4 col-span-12">
{{ $this->createNewTrainingEvent }}
<x-filament-actions::modals />
</div>
<div class="md:col-span-8 col-span-12 tdta_back_calendar" wire:ignore>
<div id='calendar'></div>
</div>
</div>
</div>
</x-filament-panels::page>

@push('scripts')
<script src='https://cdn.jsdelivr.net/npm/[email protected]/index.global.min.js'></script>
<script type="module">
// full calendar scripts here
</script>
@endpush
the same works when I call this action from header actions.
protected function getHeaderActions(): array
{
return [
CreateAThe ction::make()
->label('New Training Event')
->model(TrainingEvent::class)
->form(TrainingEventResource::getFormSchema())
];
}
protected function getHeaderActions(): array
{
return [
CreateAThe ction::make()
->label('New Training Event')
->model(TrainingEvent::class)
->form(TrainingEventResource::getFormSchema())
];
}
could anyone please help me with this? Am I doing anything wrong here? Thank You. 🙂
6 replies
FFilament
Created by Sanchit Patil on 7/26/2023 in #❓┊help
Load Schema / Reuse Schema
Hello All, Is there any better / official way to load or reuse schema to avoid code duplication? currently, I am doing it by storing it in a class inside App\Filament\Schema namespace. <?php namespace App\Filament\Schema; use Closure; use Filament\Forms\Components\DatePicker; use Filament\Forms\Components\Grid; use Filament\Forms\Components\Hidden; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Toggle; use Squire\Models\Timezone; class EventTypeScheduleSchema { function getSchema() : array { return [ //schema ]; } } and in actual form method ->createOptionForm($etschema->getSchema()) Could you please help with this? 🙂 Thank you.
19 replies
FFilament
Created by Sanchit Patil on 7/25/2023 in #❓┊help
Make field not to be saved into the database
Hello, I do not want one field to be saved into the database. just want it to enable other fields. ButtonGroup::make('event_availability') ->label('How do you want to offer your availability for this event type?') ->options([ 'stored' => 'Use an existing schedule', 'custom' => 'Set custom hours', ]) ->gridDirection('column') ->reactive(), is there any way to achieve this? as I am getting a Laravel error while saving the data: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'event_availability' in 'field list' Could you please help me with this?
5 replies
FFilament
Created by Sanchit Patil on 7/24/2023 in #❓┊help
How to use custom rule with other field's data?
Hello All, Could you please help me with this custom rule here? i want to compare multiple field's data here to validate this field. In custom_duration text field i want to check if custom_duration_select is hrs or min as per the value selected, i want to validate the custom_duration number i tried with a request post, but it is not getting validated. Sorry, I am completely new to Livewire. Thank you in advanced. 🙂 TextInput::make('custom_duration')->label('') ->placeholder('Custom Duration') ->default(30)->numeric() ->requiredIf('event_duration','custom') ->rules([ function () { return function (string $attribute, $value, Closure $fail) { $c_d_select = Request::post('custom_duration_select'); if (($c_d_select === 'hrs' && $value > 12) || ($c_d_select === 'min' && $value > 720)) { $fail("less than or equal to 12 hrs."); } }; }, ]), ButtonGroup::make('custom_duration_select') ->label('') ->options([ 'min' => 'min', 'hrs' => 'hrs', ]) ->default('min'),
2 replies