karim charfaoui
karim charfaoui
FFilament
Created by karim charfaoui on 6/26/2024 in #❓┊help
How to import form schema
No description
9 replies
FFilament
Created by karim charfaoui on 6/22/2024 in #❓┊help
Repeater
how can we fill repeater with prebuild data on create page ex:
protected static string $resource = InvoiceResource::class;
//order hasMany OrderItems => relation name orderItems
//invoice hasMany OrderItems => relation name orderItems
$order = Order::get()->first();
$items= $order->orderItems(); // relation order hasMany orderItems
public function mount(): void
{
parent::mount();
if($order){
//fill my repeater with items here
}
}
protected static string $resource = InvoiceResource::class;
//order hasMany OrderItems => relation name orderItems
//invoice hasMany OrderItems => relation name orderItems
$order = Order::get()->first();
$items= $order->orderItems(); // relation order hasMany orderItems
public function mount(): void
{
parent::mount();
if($order){
//fill my repeater with items here
}
}
my process is 1- create an order with order_items=> (id_order, id_article, quantity, unit_price, invoice_id) then send it to our supplier invoice_id =>null 2-when we get a supplier invoice we generate this one from order and we we each orderItems with updating invoice_id, and unit_price
2 replies
FFilament
Created by karim charfaoui on 6/22/2024 in #❓┊help
Fill repeater on createView
I'm facing an issue while implementing an invoice creation . I'm using the Repeater component to display order items (commandeItems) Here's a summary of what I have set up: I have a Commande model with a hasMany relationship to CommandeItem. I have an Invoice model with a hasMany relationship to CommandeItem I'm using CreateInvoice, which extends Filament's CreateRecord to create a new invoice. In CreateInvoice, I fetch a specific order with its associated articles (commandeItems) and attempt to pre-fill them in the form using mapCommandeItemsForForm(). Despite this, the Repeater for commandeItems stays empty when I open the form.
class CreateInvoice extends CreateRecord
{
protected static string $resource = InvoiceResource::class;

public $commande;

public function mount(): void
{
parent::mount();

$commandeId = request()->query('commande');
if ($commandeId) {
$this->commande = Commande::with('fournisseur', 'commandeItems')
->find($commandeId);
$this->fillFormWithCommandeData();
} else {
$this->commande = null;
}
}
class CreateInvoice extends CreateRecord
{
protected static string $resource = InvoiceResource::class;

public $commande;

public function mount(): void
{
parent::mount();

$commandeId = request()->query('commande');
if ($commandeId) {
$this->commande = Commande::with('fournisseur', 'commandeItems')
->find($commandeId);
$this->fillFormWithCommandeData();
} else {
$this->commande = null;
}
}
then i fill my form
protected function fillFormWithCommandeData(): void
{
if ($this->commande) {
$this->form->fill([
'commande_id' => $this->commande->id,
'fournisseur_id' => $this->commande->fournisseur->id,
'commandeItems' => $this->mapCommandeItemsForForm(),// return empty
]);
}
}
protected function fillFormWithCommandeData(): void
{
if ($this->commande) {
$this->form->fill([
'commande_id' => $this->commande->id,
'fournisseur_id' => $this->commande->fournisseur->id,
'commandeItems' => $this->mapCommandeItemsForForm(),// return empty
]);
}
}
10 replies
FFilament
Created by karim charfaoui on 1/14/2024 in #❓┊help
Move Tenant Selector
Hello can we move the tenant selector to top navigation
7 replies
FFilament
Created by karim charfaoui on 1/7/2024 in #❓┊help
How to set badge color from relation
No description
37 replies
FFilament
Created by karim charfaoui on 1/3/2024 in #❓┊help
CheckboxList make true some options
CheckboxList : in my CheckboxList I would like to set the value of this checkbox to true and disabled it where name=admin here is my code :

Forms\Components\CheckboxList::make('roles')
->relationship(titleAttribute: 'name')
->required()

Forms\Components\CheckboxList::make('roles')
->relationship(titleAttribute: 'name')
->required()
thanks a lot
3 replies
FFilament
Created by karim charfaoui on 12/26/2023 in #❓┊help
unique multiple columns
how can i do unique multiple colums exemple :` ->unique('user_job',ignoreRecord: true,modifyRuleUsing: function (Unique $rule,callable $get) { return $rule $table->unique('user_id','job_id','start_date') }) thanks
2 replies
FFilament
Created by karim charfaoui on 12/24/2023 in #❓┊help
multiple unique column
good evening, I have 3 tables users, jobs and finally the pivot table user_job with the pivot fields "start_date" and "end_date" and also $table->unique('user_id','job_id','start_date') , in my UserResource I have the following repeater: Repeater::make('userJobs') ->label('') ->relationship() ->schema([ Select::make('job_id') ->options(Job::all()->pluck('name', 'id')) ->required() ->unique('user_job',ignoreRecord: true), DatePicker::make('date_start') ->required() ->format('d/m/Y'), DatePicker::make('date_end') ->format('d/m/Y'), ]), If possible, I would like some help to respect $table->unique('user_id','job_id','start_date') thank you in advance for your help
7 replies
FFilament
Created by karim charfaoui on 12/23/2023 in #❓┊help
profile layout
hello, how to display profile in my panel and not as a page without menu or header
3 replies
FFilament
Created by karim charfaoui on 12/5/2023 in #❓┊help
Create Options Forms on a Select
Hello how can i create an option Forms on my non-relationship Select : Forms\Components\Repeater::make('userFonctions') ->relationship() ->schema([ Forms\Components\Select::make('fonction_id') ->label('Fonction') ->options(Fonction::query()->pluck('name', 'id')) ->required() ->columnSpan([ 'md' => 5, ]) ->searchable() ->createOptionForm([ Forms\Components\TextInput::make('name') ->label('nom') ->unique(ignoreRecord: true) ->maxLength(255) ->required(), Forms\Components\TextInput::make('diminutif') ->label('Abréviation') ->unique(ignoreRecord: true) ->maxLength(255) ->required(), ]),
11 replies
FFilament
Created by karim charfaoui on 12/3/2023 in #❓┊help
Get Filament id Panel
hello I would like to registerRenderHook only if the id of my panel is different from admin, how can I retrieve the id of my current panel. Filament::getCurrentPanel()->getId(); always return admin
9 replies
FFilament
Created by karim charfaoui on 12/2/2023 in #❓┊help
Update my query on my Resource
hello, in my application I have the users, schools and school_user tables which is a pivot table with the is_owner field. now in my SchoolResource I would like to retrieve just the schools with the pivot fields of the authenticated user for this I created a method public function ownedByUser(User $user): Collection { return $this->belongsToMany(User::class, 'school_user') ->wherePivot('is_owner', true) ->wherePivot('user_id', $user->id) ->get(); } or i can create another method in my User model public function ownedSchools(): Collection { return $this->schools() ->wherePivot('is_owner', true) ->get(); } also i'm using force-deletes my question and how can I call it at my SchoolResource thank you
7 replies
FFilament
Created by karim charfaoui on 6/2/2023 in #❓┊help
Reactive select => visible Card
3 replies
FFilament
Created by karim charfaoui on 6/2/2023 in #❓┊help
max_content_width
in my filament config file my 'max_content_width' => 'full', want to change this variable in my resource with "protected ?string $maxContentWidth = '7xl';" but it doesn't work could you help thanks
5 replies
FFilament
Created by karim charfaoui on 6/2/2023 in #❓┊help
ToDo plugins
hello, does anyone know if there is a ToDo plugin ??? tks
3 replies
FFilament
Created by karim charfaoui on 5/31/2023 in #❓┊help
Add year switcher
Hello, for my school management application I would like to add a switcher which contains the list of school years which is a vital variable to display the data I would like to add it next to the search field thank you in advance for your help
8 replies
FFilament
Created by karim charfaoui on 5/16/2023 in #❓┊help
Set 'filament-users' context to my route
7 replies
FFilament
Created by karim charfaoui on 5/11/2023 in #❓┊help
Add User from CompanyRessource
hello can add or edit user owner from CompanyResource without using relation manager because i wan to use a wizard component
6 replies
FFilament
Created by karim charfaoui on 5/11/2023 in #❓┊help
Select relationship
6 replies
FFilament
Created by karim charfaoui on 5/9/2023 in #❓┊help
Configure filament shield with filament-multi-guard
im using iotronlab filament-multi-guard pluging with 2 context the default one with admin guard and filament-users context with web guard and im using 2 Models for the auth Admin, User Model. I also installed filament shield but i have some issus
5 replies