Avriant
Avriant
FFilament
Created by Avriant on 7/25/2024 in #❓┊help
Chain filters in Table Search Text Input (hit enter -> add current input value as filter)?
Is there a way to do this without publishing the Table vendor files? This is how I would do it in JavaScript, hope it helps to understand what I want
if (searchInput) {
searchInput.addEventListener('keydown', function (event) {
if (event.key === 'Enter') {
event.preventDefault();

const currentValue = searchInput.value.trim();

if (currentValue) {
addFilter(currentValue);

searchInput.value = '';
}
}
});
if (searchInput) {
searchInput.addEventListener('keydown', function (event) {
if (event.key === 'Enter') {
event.preventDefault();

const currentValue = searchInput.value.trim();

if (currentValue) {
addFilter(currentValue);

searchInput.value = '';
}
}
});
Hit Enter -> Add Filter -> Clear Input -> Hit Enter -> Add Another Filter Remove filters by clicking filter tags (default Filament behavior) I did consult this before asking and searched for "chain" in Discord https://filamentphp.com/docs/3.x/tables/columns/getting-started#searching Any help would be much appreciated
5 replies
FFilament
Created by Avriant on 4/29/2024 in #❓┊help
Access properties on eagerly loaded relationships?
I don't know how to better approach this, any help appreciated. I have
protected function table(Table $table): Table
{
->query(Parent::latest()
->with(['relationship1', 'relationship2'])
)
protected function table(Table $table): Table
{
->query(Parent::latest()
->with(['relationship1', 'relationship2'])
)
I want (in this case Table EditAction, I'm okay with separate EditAction as well)
->actions([
EditAction::make('relationship1field')
->record($this->relationship1field)
->form([
TextInput::make('relationship1field'),
->actions([
EditAction::make('relationship1field')
->record($this->relationship1field)
->form([
TextInput::make('relationship1field'),
But I can't access relationship1field this way, what should I do? I can access $this->parentField and the field gets populated, but not $this->relationship1field or this->parent->relationship1field. I wonder if I need to separately save in a variable, but that would be n+1 query for something that already should be there and doesn't sit right with me (or maybe that's the actual best practice here so if anyone could enlighten me I'd appreciate it).
$memo = Parent::latest()->with(['relationship1', 'relationship2']);
$memo = Parent::latest()->with(['relationship1', 'relationship2']);
2 replies
FFilament
Created by Avriant on 4/24/2024 in #❓┊help
PanelBuilder wildcard NavigationItem? Is it possible?
I'm having doubts if doing something like Filament::getTenant()->id inside of panel builder is acceptable. Any advice appreciated, here's what I tried:
->navigationItems([
NavigationItem::make('Cool Page')
->url(function ($tenantID) {
return "/tenant/{$tenantID}";
}, shouldOpenInNewTab: true)
->icon('heroicon-s-globe-asia-australia')
])
->navigationItems([
NavigationItem::make('Cool Page')
->url(function ($tenantID) {
return "/tenant/{$tenantID}";
}, shouldOpenInNewTab: true)
->icon('heroicon-s-globe-asia-australia')
])
2 replies
FFilament
Created by Avriant on 4/17/2024 in #❓┊help
Filament Wizard Save to Different Tables on each Step
I suck at this, so any help would be much appreciated 🙂 Want: Wizard that on each step stores information in different tables Have: Multitenant Filament V3 Form. RegisterTenant needs to be a Wizard. Schema looks like this (exceeds the limit so I'll just drop the link here):
return $form->schema([
Wizard::make([
Step::make('STEP 1')
->schema([
TextInput::make('name')
TextInput::make('slug')
]),
Step::make('STEP 2')
->schema([
Fieldset::make('Profile Information')
->relationship('general')
->schema([
TextInput::make('name_madoguchi')
TextInput::make('phone')
TextInput::make('email_madoguchi')
]),
])
])
->persistStepInQueryString()
->startOnStep(1),
]);

protected function handleRegistration(array $data): Company
{
$data = $this->form->getState();
$company = Company::create($data);
$company->users()->attach(auth()->user());
session(['active_tenant_id' => $company->id]);
$this->form->model($company)->saveRelationships();
return $company;
}
return $form->schema([
Wizard::make([
Step::make('STEP 1')
->schema([
TextInput::make('name')
TextInput::make('slug')
]),
Step::make('STEP 2')
->schema([
Fieldset::make('Profile Information')
->relationship('general')
->schema([
TextInput::make('name_madoguchi')
TextInput::make('phone')
TextInput::make('email_madoguchi')
]),
])
])
->persistStepInQueryString()
->startOnStep(1),
]);

protected function handleRegistration(array $data): Company
{
$data = $this->form->getState();
$company = Company::create($data);
$company->users()->attach(auth()->user());
session(['active_tenant_id' => $company->id]);
$this->form->model($company)->saveRelationships();
return $company;
}
I also tried
->afterValidation(function () {
$data = $this->form->getState();
$company = Company::create($data);
$company->users()->attach(auth()->user());
return $company;
->afterValidation(function () {
$data = $this->form->getState();
$company = Company::create($data);
$company->users()->attach(auth()->user());
return $company;
Or (GPT)
Wizard::make([
Step::make('STEP 1')
->afterValidation(function () {
$company = Company::create([
'name' => $get('name'),
'slug' => $get('slug'),
]);
$company->users()->attach(auth()->user());
Wizard::make([
Step::make('STEP 1')
->afterValidation(function () {
$company = Company::create([
'name' => $get('name'),
'slug' => $get('slug'),
]);
$company->users()->attach(auth()->user());
3 replies
FFilament
Created by Avriant on 4/8/2024 in #❓┊help
Grouping Filters using Section or Fieldset returns an error, please help 😭
I get Method Filament\Forms\Components\Fieldset::table does not exist. I do import (or at least I think so) Fieldset. On Filament Discord people say it works, so probably wrapped something incorrectly https://discord.com/channels/883083792112300104/1187422662444720208/1187563565519998976
use Filament\Forms\Components\Fieldset;

//...
->filters([
Fieldset::make('Interior Filters')
->schema([
Filter::make('interior_flexible')
->query()
->label('A')
->toggle()
Filter::make('interior_not_flexible')
->query()
->label('B')
->toggle()
]),
...
use Filament\Forms\Components\Fieldset;

//...
->filters([
Fieldset::make('Interior Filters')
->schema([
Filter::make('interior_flexible')
->query()
->label('A')
->toggle()
Filter::make('interior_not_flexible')
->query()
->label('B')
->toggle()
]),
...
I suck at coding, so any help would be much appreciated 😦
2 replies
FFilament
Created by Avriant on 4/8/2024 in #❓┊help
Is there a way to have both Split and ->label?
Want: Labels displayed as labels in a Split layout (or switch to default layout with proper labels (overflow) when ->from('sm') does not apply). Have: This workaround: https://discord.com/channels/883083792112300104/1220350503112671283/1221033600754126858 does not work for IconColumn, any ideas? Any help would be much appreciated.
2 replies
FFilament
Created by Avriant on 3/1/2024 in #❓┊help
How to remove these inline styles (copy location returns undefined)
No description
20 replies
FFilament
Created by Avriant on 11/10/2023 in #❓┊help
Can't hydrate single edit/view page select field with M:M relationship
Laravel/Filament newbie. Any help would be much appreciated 🙂 I have data stored in M:M table
primary_id company_id prefecture_id timestamps
183 1 3 2023-11-09 08:33:37 2023-11-09 08:33:37
184 1 5 2023-11-09 08:33:37 2023-11-09 08:33:37
185 1 7 2023-11-09 08:33:37 2023-11-09 08:33:37
primary_id company_id prefecture_id timestamps
183 1 3 2023-11-09 08:33:37 2023-11-09 08:33:37
184 1 5 2023-11-09 08:33:37 2023-11-09 08:33:37
185 1 7 2023-11-09 08:33:37 2023-11-09 08:33:37
Trying to hydrate it in custom page CompanyRegions.php
namespace App\Filament\Pages;
class CompanyRegions extends Page implements HasForms
{
//
public function mount(): void {
$tenant = Filament::getTenant();
$companyID = $tenant->id;

$companyPrefectures = auth()->user()->companies->find($companyID)->prefectures;

$existing_prefectures = [];
foreach($companyPrefectures as $prefecture) {
Log::info($prefecture->prefecture_ja);

array_push($existing_prefectures, $prefecture->id);
}

$companyCities = auth()->user()->companies->find($companyID)->cities;

$this->form->fill($existing_prefectures);

}
namespace App\Filament\Pages;
class CompanyRegions extends Page implements HasForms
{
//
public function mount(): void {
$tenant = Filament::getTenant();
$companyID = $tenant->id;

$companyPrefectures = auth()->user()->companies->find($companyID)->prefectures;

$existing_prefectures = [];
foreach($companyPrefectures as $prefecture) {
Log::info($prefecture->prefecture_ja);

array_push($existing_prefectures, $prefecture->id);
}

$companyCities = auth()->user()->companies->find($companyID)->cities;

$this->form->fill($existing_prefectures);

}
But I end up passing fill($existing_prefectures) this:
+data: array:4 [▼
0 => 3
1 => 4
2 => 6
"prefecture_id" => []
]
}
+data: array:4 [▼
0 => 3
1 => 4
2 => 6
"prefecture_id" => []
]
}
doing fill($companyPrefectures->attributesToArray()) also does not work (method does not exist error) I feel like I'm almost there but don't understand something important. Or maybe https://livewire.laravel.com/docs/lifecycle-hooks#mount only accepts non-complex data, I don't know. fill($data) works just fine for me for Models that have simple input fields.
2 replies
FFilament
Created by Avriant on 10/31/2023 in #❓┊help
Custom page many-to-many sync() method creates duplicates (is this really the right way to do it?)
Filament/Laravel Newbie. I want: To store M:M relationship "company_prefecture" in MySQL DB through a pivot Custom Page. I have: A messy code that I want to improve and adjust it to Filament Custom Page conventions.
1) It duplicates entries 2) It does not generate timestamps even though I have those specified in migration I tried: 1. Raw SQL queries (worked) 2. save()/new CompanyPrefecturesModel/fill() approach (couldn't store company_id/prefecture_id, but did manage to generate timestamps this way) 3. sync() (managed to generate entries in my pivot table, but have issues described above) Code:
public function save(): void {

$tenant = Filament::getTenant();
$data = $this->form->getState();

foreach ($data['prefecture_id'] as $prefecture_id) {
$mergedData[] = [
'company_id' => $tenant->id,
'prefecture_id' => $prefecture_id,
];
}
$data = $mergedData;

$companyID = $tenant->id;

$company = auth()->user()->companies->find($companyID);
$Entry = $company->prefectures();

if ($company->pivot->prefecture_ja === null) {

$Entry->sync($data);

Notification::make()
->success()
// ->title(__('filament-panels::resources/pages/edit-record.notifications'))
->title('Entry Created')
->send();
} else {
$Entry->sync($data);

Notification::make()
->success()
// ->title(__('filament-panels::resources/pages/edit-record.notifications'))
->title('Entry Updated')
->send();
}
}
public function save(): void {

$tenant = Filament::getTenant();
$data = $this->form->getState();

foreach ($data['prefecture_id'] as $prefecture_id) {
$mergedData[] = [
'company_id' => $tenant->id,
'prefecture_id' => $prefecture_id,
];
}
$data = $mergedData;

$companyID = $tenant->id;

$company = auth()->user()->companies->find($companyID);
$Entry = $company->prefectures();

if ($company->pivot->prefecture_ja === null) {

$Entry->sync($data);

Notification::make()
->success()
// ->title(__('filament-panels::resources/pages/edit-record.notifications'))
->title('Entry Created')
->send();
} else {
$Entry->sync($data);

Notification::make()
->success()
// ->title(__('filament-panels::resources/pages/edit-record.notifications'))
->title('Entry Updated')
->send();
}
}
Believe it or not, I've spent a month of my post-work time trying to make it work...
2 replies
FFilament
Created by Avriant on 10/5/2023 in #❓┊help
Custom Page (single page edit/view, no table view) saving 2 many-to-many relationships possible?
My second Filament project, first V3 project. I ask very stupid questions from time to time, bear with me 🙇‍♂️ I want: To save a bunch of IDs for cities and prefectures as M:M relationship (company_prefectures and company_cities) using Filament Custom Page (by Custom Page I mean single page edit/view, no table view) Solution 1? I can save it as 2 separate multiselect JSONs with tenant ID attached in a migration as below:
Schema::create('company_regions', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(Company::class, 'company_id')->cascadeOnDelete();
$table->json('prefectures');
$table->json('cities');
$table->timestamps();
});
Schema::create('company_regions', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(Company::class, 'company_id')->cascadeOnDelete();
$table->json('prefectures');
$table->json('cities');
$table->timestamps();
});
But I hear JSONs are extremely heavy, especially if you need to be able to quickly search through these IDs. Solution 2? Save it as M:M, but I've no idea how to do it using a single custom page (Making 2 separate pages for 2-4 multiselect inputs seems like an overkill to me and is not a good UX). If it's possible, I understand I'll need 2 separate M:M tables (company_prefecture and company_city?) But if I try to pull something like that off, ->relationship returns null in my case. Any advice would be much appreciated
4 replies
FFilament
Created by Avriant on 9/13/2023 in #❓┊help
How to extract a form object in Filament V2?
Received a great pointer yesterday to here for Custom Pages https://www.youtube.com/watch?v=8Di6Yrqgsl8 Problem is, it's for V3, and I'm trying to finish my old V2 project first before migrating to V3 The dashboard renders, but the form does not 😦 Tried consulting this, but still feel stuck. Any help would be much appreciated! https://livewire.laravel.com/docs/forms#extracting-a-form-object Custom Page CompanyMembers.php
<?php

namespace App\Filament\Pages;

use Filament\Pages\Page;
use Filament\Resources\Form;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Contracts\Hasforms;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;

class CompanyMembers extends Page implements Hasforms
{
use InteractsWithForms;

public ?array $data = [];

protected static ?string $model = CompanyMembers::class;

protected static ?string $navigationIcon = 'heroicon-o-user';

protected static ?string $modelLabel = '社員数ブレイクダウン';

protected static string $view = 'filament.pages.company-members';

public function mount(): void {
$this->form->fill();
}

public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('total')->placeholder('10人')->label('トータル'),
TextInput::make('members-20s')->placeholder('2人')->label('20代'),
TextInput::make('members-30s')->placeholder('0人')->label('30代'),
TextInput::make('members-40s')->placeholder('4人')->label('40代'),
TextInput::make('members-50s')->placeholder('3人')->label('50代'),
TextInput::make('members-60s')->placeholder('1人')->label('60代'),
Toggle::make('daiku')->label('専属大工(あり・なし)'),
])
->statePath('data');
}
}
<?php

namespace App\Filament\Pages;

use Filament\Pages\Page;
use Filament\Resources\Form;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Contracts\Hasforms;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;

class CompanyMembers extends Page implements Hasforms
{
use InteractsWithForms;

public ?array $data = [];

protected static ?string $model = CompanyMembers::class;

protected static ?string $navigationIcon = 'heroicon-o-user';

protected static ?string $modelLabel = '社員数ブレイクダウン';

protected static string $view = 'filament.pages.company-members';

public function mount(): void {
$this->form->fill();
}

public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('total')->placeholder('10人')->label('トータル'),
TextInput::make('members-20s')->placeholder('2人')->label('20代'),
TextInput::make('members-30s')->placeholder('0人')->label('30代'),
TextInput::make('members-40s')->placeholder('4人')->label('40代'),
TextInput::make('members-50s')->placeholder('3人')->label('50代'),
TextInput::make('members-60s')->placeholder('1人')->label('60代'),
Toggle::make('daiku')->label('専属大工(あり・なし)'),
])
->statePath('data');
}
}
Blade (adjusted x-filament for V2)
<x-filament::page>
<x-filament::form>
{{ $this->form }}
</x-filament::form>
</x-filament::page>
<x-filament::page>
<x-filament::form>
{{ $this->form }}
</x-filament::form>
</x-filament::page>
12 replies
FFilament
Created by Avriant on 9/12/2023 in #❓┊help
Resource that manages only one entry? (HasOne, no table view, /edit and /view routes are the same)
Filament/Livewire newbie. Have built a few simple blogs in Laravel 9/10. Example: A company has a separate form for how many members it has and how many people of different age groups it has. There's no need to have multiple entries for this — only one page with input fields and "save" is enough. Could anyone guide me in the right direction? I Googled it and found this https://filamentphp.com/docs/2.x/admin/resources/custom-pages https://www.youtube.com/watch?v=wpZkFFqRYYI But looking at the result from this guy (I don't speak Indonesian) it seems like it's just another multiple-entry view.
4 replies
FFilament
Created by Avriant on 9/11/2023 in #❓┊help
How to query data from 20+ tables and pass it as a single variable to a View: UNION? JOIN?
Laravel/Filament V2 First Time Project Imagine something like this: Table 1 "Company" columns: id, name Table 2 "Company Members" columns: id, company_id, total_members, members_10s, members_20s Table 3 "Company Achievements" columns: id, company_id, scale, projects The method below requires my tables to have same fields, which just does not make sense to me (how can I put number of members into the same field as company name?). https://jianjye.medium.com/how-to-search-multiple-models-easily-with-laravel-eloquent-without-using-packages-d8773c43eda9 ANY video I managed to find on YouTube ALWAYS has literally one table for users and one table for entity and does not have anything specific for this mess. I've been staring at my app\Http\Controllers\CompanyController.php for the past 2 days, but staring seems to be not a solid strategy to resolve my conundrum
$companies = Company::query()
->where('created_at', '!=', NULL)
->orderBy('created_at', 'desc')
->paginate();

$members = CompanyMembers::query()
>select('')
->where('company_id', 'LIKE', )
->get();

$achievements = CompanyAchievements::query()
->select('')
->where('', 'LIKE', )
->get()

$companyData = $companies->union($members)->union($achievements)->get();
$companies = Company::query()
->where('created_at', '!=', NULL)
->orderBy('created_at', 'desc')
->paginate();

$members = CompanyMembers::query()
>select('')
->where('company_id', 'LIKE', )
->get();

$achievements = CompanyAchievements::query()
->select('')
->where('', 'LIKE', )
->get()

$companyData = $companies->union($members)->union($achievements)->get();
Please, show me the way
https://tenor.com/view/adam-levine-embarrassed-gif-21343983
2 replies
FFilament
Created by Avriant on 8/30/2023 in #❓┊help
Help with prefecture->city logic, best practice
Full disclosure: inexperienced with Filament and PHP, but trying my best anyway. Want: user inputs a list of prefectures and cities it operates in. Then I can output it as a "user1/2/3 works here" kind of card grid on the Frontend. Have: messy code — tried one too many things and feel too lost at this point. I think I got confused because I ended up trying to do both things at the same time. Questions: 1. What is the best practice (scalabilitywise) for this type of logic? 2. Is it better to store prefecture/city IDs as JSON (array of IDs) or create a separate entry for each prefecture/city?
Code: 1. Migration
return new class extends Migration
Schema::create('company_regions', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(\App\Models\Company::class, 'company_id');
$table->foreignIdFor(\App\Models\City::class, 'city_id')->nullable();
$table->foreignIdFor(\App\Models\Prefectures::class, 'prefecture_id')->nullable();
// $table->json('associated_prefectures');
// $table->json('associated_cities');
$table->timestamps();
});
Schema::create('company_cities', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(\App\Models\Company::class, 'company_id');
$table->foreignIdFor(\App\Models\City::class, 'city_ids');
$table->timestamps();
});
Schema::create('company_prefectures', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(\App\Models\Company::class, 'company_id');
$table->foreignIdFor(\App\Models\Prefectures::class, 'prefecture_ids');
$table->timestamps();
});
return new class extends Migration
Schema::create('company_regions', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(\App\Models\Company::class, 'company_id');
$table->foreignIdFor(\App\Models\City::class, 'city_id')->nullable();
$table->foreignIdFor(\App\Models\Prefectures::class, 'prefecture_id')->nullable();
// $table->json('associated_prefectures');
// $table->json('associated_cities');
$table->timestamps();
});
Schema::create('company_cities', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(\App\Models\Company::class, 'company_id');
$table->foreignIdFor(\App\Models\City::class, 'city_ids');
$table->timestamps();
});
Schema::create('company_prefectures', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(\App\Models\Company::class, 'company_id');
$table->foreignIdFor(\App\Models\Prefectures::class, 'prefecture_ids');
$table->timestamps();
});
6 replies
FFilament
Created by Avriant on 8/29/2023 in #❓┊help
multiple() fields on /create return null
Full Disclosure: very inexperienced with Filament and php in general. Began this project a while ago in my free time with V2+Companies plugin and plan to finish it before going for V3. Trying to save an array of tag IDs as JSON, fields not registered (first time implementing Multiple() Filament logic). Any advice would be much appreciated 🙂 Error:
SQLSTATE[HY000]: General error: 1364 Field 'tenyi' doesn't have a default value

insert into
company_interiors (
shiyou_henkou,
company_id,
updated_at,
created_at
)
values
(1, 2, 2023 -08 -29 07: 18: 37, 2023 -08 -29 07: 18: 37)
SQLSTATE[HY000]: General error: 1364 Field 'tenyi' doesn't have a default value

insert into
company_interiors (
shiyou_henkou,
company_id,
updated_at,
created_at
)
values
(1, 2, 2023 -08 -29 07: 18: 37, 2023 -08 -29 07: 18: 37)
Migration
Schema::create('company_interiors', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(\App\Models\Company::class, 'company_id');
$table->json('tenyi');
$table->json('yuka');
$table->json('kabe');
$table->json('kengu');
$table->boolean('shiyou_henkou');
$table->timestamps();
Schema::create('company_interiors', function (Blueprint $table) {
$table->id();
$table->foreignIdFor(\App\Models\Company::class, 'company_id');
$table->json('tenyi');
$table->json('yuka');
$table->json('kabe');
$table->json('kengu');
$table->boolean('shiyou_henkou');
$table->timestamps();
Model
Model
namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class CompanyInterior extends Model
{
use HasFactory;

protected $table = 'company_interiors';

protected $casts = [
'tenyi' => 'array',
'yuka' => 'array',
'kabe' => 'array',
'kengu' => 'array',
'shiyou_henkou' => 'boolean'
];

protected $fillable = [
'company_id',
'tenyi',
'yuka',
'kabe',
'kengu',
'shiyou_henkou'
];

public function types(): BelongsToMany
{
return $this->belongsToMany(InteriorProvider::class);
}
}
Model
namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class CompanyInterior extends Model
{
use HasFactory;

protected $table = 'company_interiors';

protected $casts = [
'tenyi' => 'array',
'yuka' => 'array',
'kabe' => 'array',
'kengu' => 'array',
'shiyou_henkou' => 'boolean'
];

protected $fillable = [
'company_id',
'tenyi',
'yuka',
'kabe',
'kengu',
'shiyou_henkou'
];

public function types(): BelongsToMany
{
return $this->belongsToMany(InteriorProvider::class);
}
}
18 replies
FFilament
Created by Avriant on 6/19/2023 in #❓┊help
First Time Filament Project, stuck on M:M relationship 🆘
Background: It's my first Filament and Backend-heavy project. *Any help would be immensely appreciated! * I plan to use Filament dashboard for user input, multiple users can belong to the same org, but will see the same dashboard. All content will only be shown to a single user authenticated as "admin." There can be different orgs.
I want: 1. To have user_id, company_id, role_id saved in my table when I input data on Filament (right now I only have Filament user who inputs data and it's saved in the DB, but M:M table is not filled 😦 ). 2. To find the right plugin on Filament to use for 1-org-many-users-that-can-edit-the-same-inputs scenario (was thinking about this one: https://filamentphp.com/plugins/companies, but I have a feeling this one only works for org=user scenario). 3. To understand how to setup "roles" migration/logic for a Filament project (see 1.3 below). 4. What to do with user migration if I need other fields to register a user (not only name, email and psw, but maybe org_id and phone number)?
I have: 1. Migrations 1.1. Users
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->string('phone', 12)->unique()->nullable();
$table->timestamp('email_verified_at')->nullable();
[...]
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->string('phone', 12)->unique()->nullable();
$table->timestamp('email_verified_at')->nullable();
[...]
1.2 Companies

$table->id();
$table->string('name', 100)->unique();
$table->string('address', 100)->unique();
$table->smallInteger('total')->nullable();
$table->timestamps();

$table->id();
$table->string('name', 100)->unique();
$table->string('address', 100)->unique();
$table->smallInteger('total')->nullable();
$table->timestamps();
1.3 Roles
$table->id();
$table->string('name', 20);
$table->json('privileges');
$table->id();
$table->string('name', 20);
$table->json('privileges');
1.4 User_Role (M:M)
$table->id();
$table->foreignId('role_id')->references('id')->on(table: 'roles');
$table->foreignId('user_id')->references('id')->on(table: 'users');
$table->foreignId('company_id')->references('id')->on(table: 'companies');
$table->timestamps();
$table->id();
$table->foreignId('role_id')->references('id')->on(table: 'roles');
$table->foreignId('user_id')->references('id')->on(table: 'users');
$table->foreignId('company_id')->references('id')->on(table: 'companies');
$table->timestamps();
2. Filament v.2.17.49 3. Doctrine/dbal I'll be rerunning migrations in the background and try to figure it out in the meantime.
10 replies