Tuto's Laravel Corner

TLC

Tuto's Laravel Corner

Join the community to ask questions about Tuto's Laravel Corner and get answers from other members.

Join

🚀laravel

💡filament

How to use custom Admin UI with Filament

Hello guys. II've been with Laravel for a year or so and I love it so far. So is with Livewire which surprised me with it's simplicity in many occasions in terms of dynamics and code easiness to digest. I've came across Filament in a few months so I am still learning my way through this incredible ecosystem but I feel comfortable now thanks to tuto and many other contributors to build a semi-complex project on my own. The one thing that I would like to know and I've done some research on it already is how can we build a fully customized admin theme still using Filament under the hood. And by fully customized theme I am not meaning to change colors, backgrounds, icons etc. that Filament already allow with the custom theme, but what I mean is to use the incredible power to build quickly with Filament but use a custom ADMIN UI like AdminLTE, CoreUI or any other admin design that a project requires us to use....
Solution:
Another alternative I was reading about was to have custom PAGES which we can design and if allowed to use the functionality of Filament, can have our content attached. Not sure yet of all the bits and pieces, but there has to be an easy and elegant way to implement your custom theme to Filament panel. I can imagine someone requesting you to work on a project and providing frontend/backend design so that we can attach the functionality required and we tell that our panel does not support the custom GUI 🙂 I am sure it does, I just did not yet find it as I really love to use Filament and just need to invest some extra time in finding which template is where by design. I think that once I am done with the Vet clinic (or when the class is done with it) I can start by login/register form etc. and go slowly finding all the others, documenting their locations and think of a way or replacement that can be independent of the web framework. Maybe I am a dreamer but I am pretty sure if there is not a simple way to achieve the needed, there is a smart way to do so and the simple way is already in the DEV team minds....

how to set a value of an input field using values in a repeater

I have this input fields inside a repeater, product name, price and quantity, and I have an input field total disabled by default outside of the repeater, I want to populate the result of foreach(price * quantity) inside the total field
Solution:
myabe you can add the afterStateUpdated directly to the repeater instead of the input fields. Try using ->afterStateUpdated(fn ($state) => dd($state)) on the repeater and examine the results. It should be an array with all the items in the repeater. This will fire when you click the add action of the repeater and when you update items in the repeater. New empty items have a uuid key. But I imagine you can easily traverse the array, make calculatioins and set the value to the total. Let me kn...

Working on a Laravel Filament project using remote Shared Hosting

Hello guys. As part of my "training punishment" I decided to try to install a fresh Laravel + Filament project on my shared cPanel hosting and edit the files locally with a remote sync. Why am I trying this - simple, I switch PCs often as part of my IT work related day so having a centralized project space would allow me to edit from wherever whenever. So far, I've discovered a package provided from Micro$oft named RemoteSSH which allows you to connect to a shared host, lists all your files in the editor and you update directly. The issue with this approach is that when you need to transfer some files to the host, you can't copy/paste the folder or multiple files at once in VSCode (or at least it did not work with me to transfer 20Mb of assets). Besides that, the connection is reset quite often and it is almost impossible to reconnect without restarting the PC or else....
Solution:
Hmm, adding up to the need, when a dev works on a project and need to demonstrate/prove the progress to a client, eventually you would: 1. Want to have your website with the latest functionality UP-2-DATE 2. Not want to re-import DB, files etc. every time when a client need it. ...

is there a way to mutate data on createOptionForm in Select input.

i want to attach the creator_id before saving the form instead of having the a readonly field. ` Forms\Components\Select::make('payment_method_id') ->label('Payment Method') ->relationship(name: 'paymentMethod', titleAttribute: 'name')...

is there a way to make tabs filter optional according to roles

i have a teacher role and admin role, i want a tab filter only when i login as an admin, if i login as a teacher tab filter on the resource is not showing, is there a way to do that? thanks.
Solution:
Given that the getTabs() method returns the tabs you need as an array, You can easily customize the return value based on the user role. ```php public function getTabs(): array {...

Render data from two resources

Is there a way to render data in a form from two different resources (tables or models) without a relationship between them? Thanks

Need Help wrapping my mind around Filament implementation

Hello! I recently stumbled across this channel and love the content. Thank you for providing such great videos. Hoping this group can help me get a better understanding of how Filament might help me with a hobby project I am working on. Fair warning, I am not that great with Laravel, still learning. I am just here to get understanding and learn more. I want to create an application that let's different departments manage tasks, schedules, notes, etc. ...
Solution:
1) Users should be able to sign in and only see their tasks and other activities. I would imagine this happens outside of Filament? Does this mean there would be an admin login page but then also a user login page that pulls up their 'work page'? Yes, that seems to be more fitting than having only one panel (login page) and showing/hiding stuff based on roles. 2) Is Filament just a layer on top of Laravel to give admins access to their 'teams' but the bulk of the app should be handled outside, just in Laravel?...

how to share resources on both panels

i have 2 panel, teacher and stundet, i want to create a resource that accessible for both roles, thnaks.
Solution:
Panels need to have their own resource classes. But once you create them, the records of those resources are the same on both panels unless you scope them in some way, like a scope to the logged in user.

Custom setting page with filamentphp

I'm attempting to set up the edit page as the primary view for a filamentphp resource, specifically for managing page settings. These settings will consist of a single data row, and I want to restrict it to only being editable, with no option to create new rows or delete the existing one. Despite my efforts to find a solution, I haven't been able to. I'm open to any pointers, workarounds, or alternative approaches that could help me achieve this. Thanks for your assistance!

Validation doesn't work on form created with createOptionForm

Folks, I used the createOptionForm function to enable a new record creation form in a select field. Unfortunately, on this form, the unique() validation is not working. I followed a tip from Povilas in the code below, also without success: ```php // Document comes from a Leandro Ferreira package for document fields in pt_BR Document::make('cpf')
->label('CPF')...
Solution:
I implemented something similar, but without using any third party packages (Document) and the validation works as expected. Here's an example of a dropdown with the option to create a new user. The unique validation is added to the email field ```php Forms\Components\Select::make('owner_id') ->relationship('owner', 'name')...

TinyMce in filamentphp as a customField

I want to use TinyMCE in my form builder, but I can't. When I use the script inside my custom view, TinyMCE loads, but it disappears when I use a reactive() or any real-time functionality like a wizard. Additionally, when I hit "create", it won't send the data and I get the error "title cannot be null". I also tried registering the TinyMCE script file as the Filament documentation suggests (https://filamentphp.com/docs/3.x/support/assets#registering-javascript-files). I can see the script file when I inspect the page, but TinyMCE won't load. Here's my custom-textarea.blade.php file: ```<textarea{{ $applyStateBindingModifiers('wire:model') }}="{{ $getStatePath() }}"></textarea> <script src="https://cdn.tiny.cloud/1/cet2a3k5g1bxun5sp9vc8cka2nxji3ts1xrt1sz4h1oazm1g/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>...
No description

Making tabs for edit page

There used to be a package for version 2: https://github.com/aymanalhattami/filament-page-with-sidebar Unfortunately doesn't support V3 yet (there's a push for it, but in testing, it doesn't work). I see issues reported for that, but for now, is there a Filament way to do some kinda tabs like that plugin does?...

can you explain how to send a email invitation when you add a new doctor ?

How we can send an email when you create another doctor , and also how to use the verification email for every new admin

Example UserResource with Password reset button

```php public static function table(Table $table): Table { return $table ->columns([...

Problem with relationmanager

I've a bit of a struggle with table list/form. I've made a table list with customers, within the edit of the customer I've integrated two relation managers. - One: With customer contact persons. - Two: With notes of the customer....

How to set company_id in role_user table

I'm able to assign roles and everything works great, but the currently logged in company_id (multi-tenancy) doesn't get saved to the pivot table (remains null) Is there a way to set the pivot table with the currently logged in company_id when assigning roles to a user? I'm using a UserResource to do this, and I just add the roles selector component using:...

Hide column in table conditionally

I checked the documentation and all they give is the attached image example... What I need to do is hide a column if another column has a value In this specific example:...
No description

Pivot table issue

When creating a new Company Litter, I have a pivot table called company_litter that gets filled automatically by Filament But for some reason it's still requiring a company_id field in the litters table Filament fills in the company_id in the litters table, as well as the company_litter table...

How to customize Table/List view

I'm trying to get rid of the table completely inside of the resource, and replace the results with cards Is this possible?...