Anish
Anish
FFilament
Created by devpoolxx on 4/19/2024 in #❓┊help
How to close action confirmation modal after form validate fails?
Glad it worked
9 replies
FFilament
Created by devpoolxx on 4/19/2024 in #❓┊help
How to close action confirmation modal after form validate fails?
I found a way to close the modal window - after the confirmation button is clicked. Here is my action
public function myAction(): Action
{
return Action::make('my-action')
->label($this->actionButtonLabel)
->size(ActionSize::Large)
->icon($this->actionIcon)

->extraAttributes([
'title' => $this->actionButtonLabel,
])
->requiresConfirmation()
->modalIcon($this->actionIcon)
->modalHeading($this->actionButtonLabel)
->modalDescription($this->confirmationText)
->modalSubmitActionLabel($this->confirmationSubmitButton)
->action(function () {
$this->closeActionModal();
$this->action();
});
}
public function myAction(): Action
{
return Action::make('my-action')
->label($this->actionButtonLabel)
->size(ActionSize::Large)
->icon($this->actionIcon)

->extraAttributes([
'title' => $this->actionButtonLabel,
])
->requiresConfirmation()
->modalIcon($this->actionIcon)
->modalHeading($this->actionButtonLabel)
->modalDescription($this->confirmationText)
->modalSubmitActionLabel($this->confirmationSubmitButton)
->action(function () {
$this->closeActionModal();
$this->action();
});
}
This seems to work for me, if it passes validation, goes through the action. If it fails validation, the modal window is closed and shows validation window. Probably, naming could have been better! I guess that I should call it confirmedAction or something similar. I can put it in a trait and use it any place.
9 replies
FFilament
Created by Hemith on 10/25/2023 in #❓┊help
Opening a confirmation modal after validation.
Any updates on this?
6 replies
FFilament
Created by devpoolxx on 4/19/2024 in #❓┊help
How to close action confirmation modal after form validate fails?
Did you find a solution to this?
9 replies
FFilament
Created by Mis Tsu on 10/15/2023 in #❓┊help
Table in tab
OK! Got it
<div x-data="{ activeTab: 'tab1' }">

<x-filament::tabs x-data="{ activeTab: 'tab1' }">


<x-filament::tabs.item
alpine-active="activeTab === 'tab1'"
x-on:click="activeTab = 'tab1'"
>
Tab 1 Title
</x-filament::tabs.item>


<x-filament::tabs.item
alpine-active="activeTab === 'tab2'"
x-on:click="activeTab = 'tab2'"
>
Tab 2
</x-filament::tabs.item>


</x-filament::tabs>

<div>
<div x-show="activeTab === 'tab1'>Tab 1 Content</div>
<div x-show="activeTab === 'tab2'>Tab 2 Content</div>
</div>
</div>
</div>
<div x-data="{ activeTab: 'tab1' }">

<x-filament::tabs x-data="{ activeTab: 'tab1' }">


<x-filament::tabs.item
alpine-active="activeTab === 'tab1'"
x-on:click="activeTab = 'tab1'"
>
Tab 1 Title
</x-filament::tabs.item>


<x-filament::tabs.item
alpine-active="activeTab === 'tab2'"
x-on:click="activeTab = 'tab2'"
>
Tab 2
</x-filament::tabs.item>


</x-filament::tabs>

<div>
<div x-show="activeTab === 'tab1'>Tab 1 Content</div>
<div x-show="activeTab === 'tab2'>Tab 2 Content</div>
</div>
</div>
</div>
9 replies
FFilament
Created by Mis Tsu on 10/15/2023 in #❓┊help
Table in tab
Could you please give an example of where to include the tab contents for Livewire components. I am just trying out :
<x-filament::tabs x-data="{ activeTab: 'tab1' }">


<x-filament::tabs.item
alpine-active="activeTab === 'tab1'"
x-on:click="activeTab = 'tab1'"
>
Tab 1 Title
</x-filament::tabs.item>


<x-filament::tabs.item
alpine-active="activeTab === 'tab2'"
x-on:click="activeTab = 'tab2'"
>
Tab 2
</x-filament::tabs.item>


</x-filament::tabs>
<x-filament::tabs x-data="{ activeTab: 'tab1' }">


<x-filament::tabs.item
alpine-active="activeTab === 'tab1'"
x-on:click="activeTab = 'tab1'"
>
Tab 1 Title
</x-filament::tabs.item>


<x-filament::tabs.item
alpine-active="activeTab === 'tab2'"
x-on:click="activeTab = 'tab2'"
>
Tab 2
</x-filament::tabs.item>


</x-filament::tabs>
Thanks in advance.
9 replies
FFilament
Created by Anish on 3/5/2024 in #❓┊help
DateConstraint : Nullable Issue
Solved it by using custom operator.
DateConstraint::make('application_submitted_at')
->pushOperators([
Operator::make('submiited')
->label(fn (bool $isInverse): string => $isInverse ? 'Is NULL' : 'Is Not NULL')
->summary(fn (bool $isInverse): string => 'Application submitted at ' . ($isInverse ? ' is NULL' : 'is Not NULL') )

->baseQuery(
fn (Builder $query, bool $isInverse) =>
$query->{$isInverse ? 'whereNull' : 'whereNotNull'}('application_submitted_at')
)

])
DateConstraint::make('application_submitted_at')
->pushOperators([
Operator::make('submiited')
->label(fn (bool $isInverse): string => $isInverse ? 'Is NULL' : 'Is Not NULL')
->summary(fn (bool $isInverse): string => 'Application submitted at ' . ($isInverse ? ' is NULL' : 'is Not NULL') )

->baseQuery(
fn (Builder $query, bool $isInverse) =>
$query->{$isInverse ? 'whereNull' : 'whereNotNull'}('application_submitted_at')
)

])
3 replies
FFilament
Created by Anish on 3/4/2024 in #❓┊help
DateConstraint
Thanks. But that's not using the DateConstraint. This is creating each filter separately. Then we can only use the "and" operations. I find the query builder is much more flexible. Of course, if I am unable to find a solution I will probably go back to a similar solution.
5 replies
FFilament
Created by Anish on 2/19/2024 in #❓┊help
Delete exported file
After checking the documentation, I found that there is a model
Filament\Actions\Exports\Models\Export;
Filament\Actions\Exports\Models\Export;
which holds the information about the export. One can define a hasMany relation on the User model to get the exports done by the User. What I now need if there is any event that is dispatched when one clears the notifications. Then I can write a listener which will delete the file and also the corresponding database entry. I think this may be a Laravel Event, so I need to dig up the details on clearing database notifications.
9 replies
FFilament
Created by Anish on 2/19/2024 in #❓┊help
Delete exported file
Exported to csv, downloaded it and cleared from the notification. Now I have no way to access the file from the interface and I don't need it anymore. I would like the file to be removed.
9 replies
FFilament
Created by Anish on 2/5/2024 in #❓┊help
CSS & JS
I tried it out. I uploaded the global css files to S3 and then loaded via AppServiceProvider, as mentioned in the documentation. But it is loading both css, local as well as from s3. I now need to find a solution to stop it from loading it from the local server. Any suggestions?
7 replies
FFilament
Created by lazywaterpark on 10/17/2023 in #❓┊help
How can I render a PDF using a Livewire component that implements HasInfolists?
I have tested it out, with proper css. It works quite well.
6 replies
FFilament
Created by lazywaterpark on 10/17/2023 in #❓┊help
How can I render a PDF using a Livewire component that implements HasInfolists?
This is what works for me. I am developing a student application system, where student fill up the application, make payment for application fee and finally submit the application form. Once an application is submitted, we need to generate the pdf version of the application, save it to the disk and send it by email as attachment. So that is the context. I made liveware component - this is only to generate the application pdf (not for showing to the student)
class ApplicantForm extends Component
{

protected Application $application;


public function __construct(public int $applicationNo)
{
$this->mount();
}

public function mount(): void
{

$this->application = Application::firstWhere(
'application_no',
$this->applicationNo
)
->loadApplicationViewRelation();
}

public function applicationFormInfolist(Infolist $infolist): Infolist
{

return $infolist
->record($this->application)
->schema([ (new ApplicationFormPrintViewInfolist)() ]);
}

public function toHtml() : string
{
$infolist = Infolist::make($this);
return $this->applicationFormInfolist($infolist)
->toHtml();
}

public function printPDF()
{
Pdf::view('print-pdf', ['html' => $this->toHtml()])
->save( $this->application->getPDFFormPath() );
}

}
class ApplicantForm extends Component
{

protected Application $application;


public function __construct(public int $applicationNo)
{
$this->mount();
}

public function mount(): void
{

$this->application = Application::firstWhere(
'application_no',
$this->applicationNo
)
->loadApplicationViewRelation();
}

public function applicationFormInfolist(Infolist $infolist): Infolist
{

return $infolist
->record($this->application)
->schema([ (new ApplicationFormPrintViewInfolist)() ]);
}

public function toHtml() : string
{
$infolist = Infolist::make($this);
return $this->applicationFormInfolist($infolist)
->toHtml();
}

public function printPDF()
{
Pdf::view('print-pdf', ['html' => $this->toHtml()])
->save( $this->application->getPDFFormPath() );
}

}
I am using Spatie's PDF facade. This seems to work quite well with the CSS. The blade file is at this moment
<div>
{!! $html !!}
</div>
<div>
{!! $html !!}
</div>
I can use tinker to open a session and use
$appNo = 20240000001;
$pdf = new ApplicantForm($appNo);
$pdf->printPDF();
$appNo = 20240000001;
$pdf = new ApplicantForm($appNo);
$pdf->printPDF();
I have not yet taken the CSS, but this gets the data and creates a PDF file with correct data. This should be good enough for me. I hope that this helps.
6 replies
FFilament
Created by Anish on 2/5/2024 in #❓┊help
CSS & JS
Thanks for the help. If I understand correctly once I have compiled these css and js files for each panel, I should name it suitably, say app-{panel}.css and app-{panel}.js and then copy them to my external server (to a s3 server actually) and then I register them in the AppServiceProvider. But then won't all of them would be loaded when I load different panels? The color themes are different for different panels, how would they work? I suppose global css / js can be loaded via this, but I still would need a way to load panel specific css /js for different panel. Anyway I will try it out.
7 replies
FFilament
Created by lazywaterpark on 10/17/2023 in #❓┊help
How can I render a PDF using a Livewire component that implements HasInfolists?
Did you solve the problem? I am also trying a similar process but so far no luck
6 replies
FFilament
Created by Anish on 1/29/2024 in #❓┊help
Terms and Policy
In Laravel Jetstream, there is a feature called Terms and privacy policy. You have to create two markdown files and name them as policy.md and terms.md and keep them in your resources directory under markdown sub-directory and enable the feature in the Jetstream config file by uncommenting the corresponding line. Once it is done, Laravel will take the user after registration and email verification to that terms and policy page. Unless the user agrees to the terms it will not let the user continue to the dashboard. The email verification is already available in Filament. Is there a way to do the terms and policy page also?
4 replies
FFilament
Created by Anish on 1/27/2024 in #❓┊help
Middleware in Panel Route
Found a hacky solution - don't like it but it works. I created a middleware, which I name as StudentPanelCheckMiddleware. In that I run a try catch block. In the try block -
try {
$routeName = $request->route()->getName();

if ($routeName === RouteHelper:: getRouteName( 'student', 'form-submit') )
{

// Now run checks
throw_if ( GlobalConfig::afterPaymentDate (), 'Payment Date is over.');
// More checks ...
}
catch ($e)
{

Notification::make()
->label($e->getMessage ())
->danger()
->send();

return redirect()->route( RouteHelper::getDashboardRouteName ('student'));

}
try {
$routeName = $request->route()->getName();

if ($routeName === RouteHelper:: getRouteName( 'student', 'form-submit') )
{

// Now run checks
throw_if ( GlobalConfig::afterPaymentDate (), 'Payment Date is over.');
// More checks ...
}
catch ($e)
{

Notification::make()
->label($e->getMessage ())
->danger()
->send();

return redirect()->route( RouteHelper::getDashboardRouteName ('student'));

}
You will also need to add it to the list of middlewares in the panel.
4 replies
FFilament
Created by Anish on 1/21/2024 in #❓┊help
Registration Event
Not sure I follow. Where should I keep this group_id, and how do I even get the group id? Please note that once the student is in this group, they can't change it and only given forms which are applicable to the group.
7 replies
FFilament
Created by Anish on 1/21/2024 in #❓┊help
Registration Event
The user created event will have the data of the user. But I want to pass extra data which may not be part of the user. Let me give context in my case: I am working on the application portal for students. There are 3 groups of students and the application forms are very different for different groups. So I am planning to put an extra field in the registration form which will identify the group. After registration, depending on the group, I want to create the model in the corresponding student in that group. But the user will not have information about the group. So if there is an event triggered with this data, a listener can act on it
7 replies
FFilament
Created by Anish on 1/23/2024 in #❓┊help
Disable Submit Button
Thanks for your response. I will try it out
5 replies