Soundmit
Soundmit
FFilament
Created by Soundmit on 11/29/2024 in #❓┊help
Form field
No description
5 replies
FFilament
Created by Soundmit on 10/16/2024 in #❓┊help
Avoid ID in edit page
I need to use the edit page of my plugin without the ID is it possible?
'edit' => Pages\EditSettings::route('/{record}/edit'),
should be
'edit' => Pages\EditSettings::route('/edit'),
'edit' => Pages\EditSettings::route('/{record}/edit'),
should be
'edit' => Pages\EditSettings::route('/edit'),
thanks
20 replies
FFilament
Created by Soundmit on 10/9/2024 in #❓┊help
translate routes in custom plugin
in my custom plugin, i have the web.php file for the routes
Route::group(['middleware' => ['web']], function () {
Route::get('/people', [TeamController::class, 'index'])->name('team.index');
Route::get('/people/{slug}', [MemberController::class, 'show'])->name('people.show');
Route::get('/people/c/{slug?}', [TeamController::class, 'index'])->name('team.show');
});
Route::group(['middleware' => ['web']], function () {
Route::get('/people', [TeamController::class, 'index'])->name('team.index');
Route::get('/people/{slug}', [MemberController::class, 'show'])->name('people.show');
Route::get('/people/c/{slug?}', [TeamController::class, 'index'])->name('team.show');
});
i would like to translate people when i choose another language, for example en: people it: persone i've tried
Route::get(__('polipeople::messages.team'), [TeamController::class, 'index'])->name('team.index');
Route::get(__('polipeople::messages.team'), [TeamController::class, 'index'])->name('team.index');
but i get
Target class [translator] does not exist.
Target class [translator] does not exist.
because Laravel is trying to resolve the __() function before the service container is fully initialized, causing the error 'Target class [translator] does not exist.' any solution or method for this? thanks
3 replies
FFilament
Created by Soundmit on 7/31/2024 in #❓┊help
Moving routes inside plugin break the app
Hi, i'm experiencing a strange behaviour in my app i have one custom plugin for the news mgmt i moved my routes from the app to the plugin
5 replies
FFilament
Created by Soundmit on 7/30/2024 in #❓┊help
Help with builder field and multilanguage
Can someone please explain me why a builder field saves the content in this way in a multilanguage context?
3 replies
FFilament
Created by Soundmit on 7/29/2024 in #❓┊help
Translatable menu builder
Hi, i'm using this plugin to generateing he website menu (frontend not filament) https://github.com/ryangjchandler/filament-navigation but my website il multilanguage and this plugin is not translatable out of the box. tried Tomatophp but i feel it too complicated. There is another solution (not paid) to try before i'm starting to make my own menu plugin? Thanks
3 replies
FFilament
Created by Soundmit on 7/17/2024 in #❓┊help
Best Practice when making new plugin
I'm building my first plugin! In my website i need it translatable, but if i want to release it should i add all the translation implementation in the plugin or leaving to the user the implementation? and for translate i mean use Spatie\Translatable\HasTranslations; use Filament\Resources\Concerns\Translatable; etc
3 replies
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'), ]; } } ```
4 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