Soundmit
Soundmit
FFilament
Created by Soundmit on 6/28/2024 in #❓┊help
Add Printjs to infolist action
Hi, in my app i have an infolist with a button 'print'
 
#PRINT INVOICE
Action::make(__('repair.print'))
->action(fn ($data, Repair $record) => redirect()->to(
route('repair.pdf.'.$data['type'], $record)
))

->icon('heroicon-s-printer')
->form([
Forms\Components\Radio::make('type')
->label('')
->default('receipt')
->options(PrintOptions::class)
->disableOptionWhen(function (string $value, Model $record) {
return $value === 'aggregate' && $record->parts === null || $value === 'regular' && $record->parts === null;
})
])
 
#PRINT INVOICE
Action::make(__('repair.print'))
->action(fn ($data, Repair $record) => redirect()->to(
route('repair.pdf.'.$data['type'], $record)
))

->icon('heroicon-s-printer')
->form([
Forms\Components\Radio::make('type')
->label('')
->default('receipt')
->options(PrintOptions::class)
->disableOptionWhen(function (string $value, Model $record) {
return $value === 'aggregate' && $record->parts === null || $value === 'regular' && $record->parts === null;
})
])
this action all a route that generate and show a pdf in the browser (same tab) now i want to add printerjs in order to print it directly i've added print js with npm import in app.js compiled with npm run build and inspecting the code, the library seems to be loaded right now
16 replies
FFilament
Created by Soundmit on 6/24/2024 in #❓┊help
Custom widget, passing variables to blade
I'm trying to make a custom widget (all other widgets works) class
<?php
namespace App\Filament\Resources\RepairResource\Widgets;

use Filament\Widgets\Widget;
use Illuminate\Database\Eloquent\Model;

class RepairOverview2 extends Widget
{
protected static string $view = 'filament.resources.repair-resource.widgets.repair-overview2';
public ?Model $record = null;
protected int|string|array $columnSpan = 'full';


}
<?php
namespace App\Filament\Resources\RepairResource\Widgets;

use Filament\Widgets\Widget;
use Illuminate\Database\Eloquent\Model;

class RepairOverview2 extends Widget
{
protected static string $view = 'filament.resources.repair-resource.widgets.repair-overview2';
public ?Model $record = null;
protected int|string|array $columnSpan = 'full';


}
blade
<x-filament-widgets::widget>
<x-filament::section>
{{-- Widget content --}}

{{ $record->quote }} this works <---
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-5 dark:bg-inherit">
<div class="p-4 rounded-lg shadow">
<h3 class="text-lg font-semibold">Quote</h3>
<p class="text-2xl">{{ $quote }} €</p>
</div>
</div>
</x-filament::section>
</x-filament-widgets::widget>
<x-filament-widgets::widget>
<x-filament::section>
{{-- Widget content --}}

{{ $record->quote }} this works <---
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-5 dark:bg-inherit">
<div class="p-4 rounded-lg shadow">
<h3 class="text-lg font-semibold">Quote</h3>
<p class="text-2xl">{{ $quote }} €</p>
</div>
</div>
</x-filament::section>
</x-filament-widgets::widget>
$record in template works but i want to prepare the variable in my class and then send it to the tpl but i tried several options, like mount, getData... no one works.
4 replies
FFilament
Created by Soundmit on 6/24/2024 in #❓┊help
getHEaderWidgetColumns not works in resource view
In my resource view, i have a stats widget wit 5 boxes divided in 2 rows 3 and 2 i want 5 block in a row, so i added getHeaderWidgetsColumns() to my widget but it doens't works i want 5 columns only for this widget not for the otherd `` <?php namespace App\Filament\Resources\RepairResource\Widgets; use Filament\Widgets\StatsOverviewWidget as BaseWidget; use Filament\Widgets\StatsOverviewWidget\Stat; class RepairOverview extends BaseWidget { public function getHeaderWidgetsColumns(): int | array { return 5; } protected function getStats(): array { $quote = 165; $paid = 175; $costs = 120; $profit = $quote - $costs; $finalProfit = $paid - $costs; return [ Stat::make('Preventivo', $quote) , Stat::make('Incasso', $paid), Stat::make('Costi', $costs), Stat::make('Utile previsto', $profit), Stat::make('Utile effettivo', $finalProfit) ->description('7% decrease'), ]; } } ```
3 replies
FFilament
Created by Soundmit on 6/24/2024 in #❓┊help
Custom browser tab title
No description
9 replies
FFilament
Created by Soundmit on 6/19/2024 in #❓┊help
Kernel.php in V3 t oregister middleware
I'm trying to use https://github.com/mcamara/laravel-localization in filamentphp. At some point, i need t oregeister the middleware in the Kernel.php file but there is no Kernel.php file in v3 i need this middleware outside of the panel, in my frontend. Do i need to override the Kernel.php cby creating a new file in App\Http or there is another way to register middleware? https://github.com/mcamara/laravel-localization#register-middleware You may register the package middleware in the app/Http/Kernel.php file: <?php namespace App\Http; use Illuminate\Foundation\Http\Kernel as HttpKernel; class Kernel extends HttpKernel { / * The application's route middleware. * * @var array */ protected $middlewareAliases = [ /** OTHER MIDDLEWARE **/ 'localize' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes::class, 'localizationRedirect' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter::class, 'localeSessionRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect::class, 'localeCookieRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleCookieRedirect::class, 'localeViewPath' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationViewPath::class ]; }
3 replies
FFilament
Created by Soundmit on 6/17/2024 in #❓┊help
Please help with frontend translation
I've decided to quit my 17 years job as developer because i can't find a way to translate a laravel frontend 🙂 Joke aside, I'm able (80%) to set the language in the session with a language switcher but i can't redirect to the translated page... i use spatie/translatable and i have a page with en slug: test-en it slug: test-it When in the english page i try to translate in italian but the slug doesn't change the language switcher
@foreach (config('app.supported_locales') as $locale => $language)
<a href="{{ route('locale', ['locale' => $locale, 'slug' => request()->path()]) }}">
{{ $language['name'] }}&nbsp;
</a>
@endforeach
@foreach (config('app.supported_locales') as $locale => $language)
<a href="{{ route('locale', ['locale' => $locale, 'slug' => request()->path()]) }}">
{{ $language['name'] }}&nbsp;
</a>
@endforeach
the link produced https://test.ddev.site/language/en/test-en https://test.ddev.site/language/it/test-en i think that the links need to be https://test.ddev.site/test-en https://test.ddev.site/test-it
5 replies
FFilament
Created by Soundmit on 6/11/2024 in #❓┊help
Which media plugin manage also local video?
I need to upload mp4 videos, it's ok with the fileupload field but i want to reuse this video to avoid upload it many times.
2 replies
FFilament
Created by Soundmit on 6/1/2024 in #❓┊help
Use ENUMS in controller
I have a controller that print a pdf now i need to use an ENUM, but i always get errors My code is
WarrantyDurationSpan::class)->getLabel($record->repairWarranty->duration_span)
WarrantyDurationSpan::class)->getLabel($record->repairWarranty->duration_span)
the error Non-static method App\Enums\WarrantyDurationSpan::getLabel() cannot be called statically
8 replies
FFilament
Created by Soundmit on 5/31/2024 in #❓┊help
Concatenate 2 fields in infoList
Need to formatStateUsing of a textEntry in my infolist by concatenate his value + the value of another field
->formatStateUsing(function ($state, Repair $record) {
$state = PaymentStatus::getLabel($state);
$dep = $record->dep_payment_status; //value in euro
return $state . ' ' . $dep; // Partial paid 30€
})
->formatStateUsing(function ($state, Repair $record) {
$state = PaymentStatus::getLabel($state);
$dep = $record->dep_payment_status; //value in euro
return $state . ' ' . $dep; // Partial paid 30€
})
but i get this error Non-static method App\Enums\PaymentStatus::getLabel() cannot be called statically
2 replies
FFilament
Created by Soundmit on 5/28/2024 in #❓┊help
Best Practices for Websites with FilamentPHP
Now that I understand how to use FilamentPHP for creating apps and backends, I need to create the frontend. I would use Filament as if it were a CMS. The typical website has static content pages, a blog or news section, plus some custom content. Developing this part shouldn't be a problem. As for the frontend, I would use the TALL stack, and this shouldn't be an issue either. However, I'm wondering how to implement the following: Content visible to everyone and restricted content (should I create a panel for users?) Menus: how do you manage menus that have links to pages which can be created by users? I've never done frontend with Laravel, but it seems that working with routes and views is sufficient. Can you give me some advice?
12 replies
FFilament
Created by Soundmit on 5/27/2024 in #❓┊help
translate notifications
i send notification to user with this code

Notification::make()
->title(__('repair.status_change'))
->body(__('repair.status_change_body_customer', [
'originalStatus' => str($repair->getOriginal('repair_status')->getLabel()),
'newStatus' => str($repair->repair_status->getLabel()),
'item' => $repair->brand->name.' '.$repair->item->name,
'link' => '<a class="underline" href="/customer/my-repairs/">'.__('repair.open_for_more_details').'</a>'
]))
->sendToDatabase($repair->customer->user);

Notification::make()
->title(__('repair.status_change'))
->body(__('repair.status_change_body_customer', [
'originalStatus' => str($repair->getOriginal('repair_status')->getLabel()),
'newStatus' => str($repair->repair_status->getLabel()),
'item' => $repair->brand->name.' '.$repair->item->name,
'link' => '<a class="underline" href="/customer/my-repairs/">'.__('repair.open_for_more_details').'</a>'
]))
->sendToDatabase($repair->customer->user);
app language is italian user language is english, his ui is all translated in english but notification are sent in italian... if admin UI is set to english, notification are sent in english any suggestion? thanks
11 replies
FFilament
Created by Soundmit on 5/27/2024 in #❓┊help
Route and livewire pages display error
In my app i have a page with a livewire component
<x-filament-panels::page>
@livewire('list-my-repairs')
</x-filament-panels::page>
<x-filament-panels::page>
@livewire('list-my-repairs')
</x-filament-panels::page>
without a route, i simply call the page /customer/my-repairs but now i need to add the route in my web.php route file
Route::get('/customer/my-repairs', ListMyRepairs::class)->name('customer.repairs');
Route::get('/customer/my-repairs', ListMyRepairs::class)->name('customer.repairs');
ListMyRepairs is the livewire component at the end of the file i call the view
public function render(): view
{
return view('livewire.list-my-repairs');
}
public function render(): view
{
return view('livewire.list-my-repairs');
}
list-my-repairs.blade.php

<div>
{{ $this->table }}
</div>

<div>
{{ $this->table }}
</div>
but i get this error
Livewire page component layout view not found: [components.layouts.app]
Livewire page component layout view not found: [components.layouts.app]
15 replies
FFilament
Created by Soundmit on 5/14/2024 in #❓┊help
Argument: Web Routes
I'm in the final step of my app, then i would make a proper demo test for you! I need to tweak the web routes, more in depth I have 2 panels - Admin (for admin and technicians) - Customer (for client) When i create a customer (and related local user) i send an invitation email with a link to a 'choose your password' form The same when i create the Technician. The difference are that customer goes to Customer Panel and Technician to the Admin Panel Here i have the first problem, sometimes the customer goes to the admin panel, with error... Problems is in the route
/* Invitation */
Route::middleware('signed')->get('customer/invitation/{invitation}/accept', UserAcceptInvitation::class)->name('invitation.accept');
Route::middleware('signed')->get('admin/invitation/{invitation}/accept', TechnicianAcceptInvitation::class)->name('tech.invitation.accept');

Route::get('/', function () {
return view('welcome');
});

Route::get('/login', function () {
return redirect('/admin');
})->name('login');
/* Invitation */
Route::middleware('signed')->get('customer/invitation/{invitation}/accept', UserAcceptInvitation::class)->name('invitation.accept');
Route::middleware('signed')->get('admin/invitation/{invitation}/accept', TechnicianAcceptInvitation::class)->name('tech.invitation.accept');

Route::get('/', function () {
return view('welcome');
});

Route::get('/login', function () {
return redirect('/admin');
})->name('login');
Which is the best practice for this use case?
2 replies
FFilament
Created by Soundmit on 5/14/2024 in #❓┊help
Foreach error with repeater field
Hi, i have strange behaviour with a repeater field (never encountered before) i have a simple repeater
Forms\Components\Repeater::make('links')
->label('Links')
->maxItems(1)
->addActionLabel('Add button')
->schema([
Forms\Components\TextInput::make('url')
->required()->url(),
Forms\Components\TextInput::make('text')
->required(),
]),
Forms\Components\Repeater::make('links')
->label('Links')
->maxItems(1)
->addActionLabel('Add button')
->schema([
Forms\Components\TextInput::make('url')
->required()->url(),
Forms\Components\TextInput::make('text')
->required(),
]),
when i create a new item, it works when i try to edit an exhisting item, populated with a seeder i have the error 'foreach() argument must be of type array|object, string given' the field is a longtext field, with cast as array (but if i change cast to json is the same) in the database, it saved like this (new from form)
[{"url":"https:\/\/www.google.com","text":"test"}]
[{"url":"https:\/\/www.google.com","text":"test"}]
while the seeder save like this

"[{\"url\":\"https:\\\/\\\/www.google.com\",\"text\":\"test\"}]"

"[{\"url\":\"https:\\\/\\\/www.google.com\",\"text\":\"test\"}]"
6 replies
FFilament
Created by Soundmit on 5/13/2024 in #❓┊help
Brainstorming about CMS
Hi! after several months of Filament, my app is almost done the next chapter will be: made a CMS or use third part CMS? I have a lot of experience with WinterCMS (laravel cms) but i'm feel confident that it's better to build a CMS my self. The purpouse is making n basic websites with: news, static pages, blog posts, galleries, user roles etc.. on top of this, customization if needed. what do you suggests?
12 replies
FFilament
Created by Soundmit on 5/13/2024 in #❓┊help
Trix v2 update bug
after the 3.2.77 update, i'm facing the same problem of some weeks ago https://discord.com/channels/883083792112300104/1218180234512302101/1218192873644753050 I think is the exact problem
15 replies
FFilament
Created by Soundmit on 5/10/2024 in #❓┊help
Multi line text in modalDescription
hi, i have a modal with this code
->modalDescription(fn (Repair $record) => __('customer.quote_description',['quote' => $record->calculateQuote($record).app(InvoiceSettings::class)->currency. ($record->customer->customer_type == 'Business' ? __('invoice.vat') : ''), 'item' => $record->item->name, 'brand' => $record->brand->name, 'model' => $record->item->model, 'serial_number' => $record->serial_number, 'repair_note' => $record->repair_note, 'diagnosis' => $record->diagnosis]))
->modalDescription(fn (Repair $record) => __('customer.quote_description',['quote' => $record->calculateQuote($record).app(InvoiceSettings::class)->currency. ($record->customer->customer_type == 'Business' ? __('invoice.vat') : ''), 'item' => $record->item->name, 'brand' => $record->brand->name, 'model' => $record->item->model, 'serial_number' => $record->serial_number, 'repair_note' => $record->repair_note, 'diagnosis' => $record->diagnosis]))
it works but i need repair_note and diagnosis in new lines. is it possible? html tags are not converted.
4 replies
FFilament
Created by Soundmit on 5/6/2024 in #❓┊help
Form tab with red *
No description
2 replies
FFilament
Created by Soundmit on 5/4/2024 in #❓┊help
Translatable notification
hi, need to translate this
$body = __('Your <b>brands</b> export has completed and :count :row exported.', [
'count' => number_format($export->successful_rows),
'row' => str(__('brand.rows'))->plural($export->successful_rows),
]);
$body = __('Your <b>brands</b> export has completed and :count :row exported.', [
'count' => number_format($export->successful_rows),
'row' => str(__('brand.rows'))->plural($export->successful_rows),
]);
i have problem with plurals brand in italian is marchio plural for brands is marchi but the translation in this case add an S at the end and become MARCHIS i also need to translate 'your brands etc...'
4 replies
FFilament
Created by Soundmit on 5/3/2024 in #❓┊help
Hidden field works only while create and not edit
Hi, i have 2 dependant fields

Section::make('Customer type and company')
->schema([
Radio::make('customer_type')
->label('Customer type')
->options(CustomerType::class)
->default(CustomerType::PRIVATE)
->inline()
->live()
->columnSpan(1),
Select::make('company_id')
->visible(fn ( Get $get) => $get('customer_type') === CustomerType::BUSINESS)
->relationship(name: 'companies', titleAttribute: 'name')
->preload()
->multiple()
->native(false)
->searchable()
->columnSpan(2),
])->columns(2),

Section::make('Customer type and company')
->schema([
Radio::make('customer_type')
->label('Customer type')
->options(CustomerType::class)
->default(CustomerType::PRIVATE)
->inline()
->live()
->columnSpan(1),
Select::make('company_id')
->visible(fn ( Get $get) => $get('customer_type') === CustomerType::BUSINESS)
->relationship(name: 'companies', titleAttribute: 'name')
->preload()
->multiple()
->native(false)
->searchable()
->columnSpan(2),
])->columns(2),
when i select the BUSINESS option, a select is visible but it works only when i create a new customer in edit mode, doesn't works.
11 replies