shenntek
shenntek
FFilament
Created by shenntek on 5/31/2024 in #❓┊help
Too much space between Widgets and Content when having Clusters (submenu)
When i have a large amount of menuitems in my cluster i notice there is space between a page his Header Widgets and its content. I checked vendor/filament/filament/resources/views/components/page/index.blade.php and starting on line 57:
@class([
'flex flex-col gap-8' => $subNavigation,
match ($subNavigationPosition) {
SubNavigationPosition::Start,
SubNavigationPosition::End => 'md:flex-row',
default => null,
} => $subNavigation,
'h-full' => $fullHeight,
])
>
@class([
'flex flex-col gap-8' => $subNavigation,
match ($subNavigationPosition) {
SubNavigationPosition::Start,
SubNavigationPosition::End => 'md:flex-row',
default => null,
} => $subNavigation,
'h-full' => $fullHeight,
])
>
When i add md:items-start behind the md:flex-row like so:
@class([
'flex flex-col gap-8' => $subNavigation,
match ($subNavigationPosition) {
SubNavigationPosition::Start,
SubNavigationPosition::End => 'md:flex-row md:items-start',
default => null,
} => $subNavigation,
'h-full' => $fullHeight,
])
>
@class([
'flex flex-col gap-8' => $subNavigation,
match ($subNavigationPosition) {
SubNavigationPosition::Start,
SubNavigationPosition::End => 'md:flex-row md:items-start',
default => null,
} => $subNavigation,
'h-full' => $fullHeight,
])
>
the space between the widgets disappear. also when i had more than 2 widgets and the flex-columns were 2 so the third and forth etc. had to much space between them. with the md:items-start this is fixed.
Can anybody confirm they have the same problem with the Custers and long cluster menu's --> and spaces between widgets and content?
8 replies
FFilament
Created by shenntek on 4/25/2024 in #❓┊help
RelationManager belongsToMany withPivot(['id']) returns Column 'id' in order clause is ambiguous
When attaching an Product item to my Warehouse model which is a manyToMany relationship. I'm getting an SQL error (see below) the order by should contain the pivot table name .... i need the "id" because my attachments can be duplicated. I also already have configured: $table->allowDuplicates() this is my migration:
Schema::create('product_warehouse', function (Blueprint $table) {

$table->id();
$table->foreignId('product_id');
$table->foreignId('warehouse_id');
$table->string('quantity');
$table->text('location_info');
$table->timestamps();
});
Schema::create('product_warehouse', function (Blueprint $table) {

$table->id();
$table->foreignId('product_id');
$table->foreignId('warehouse_id');
$table->string('quantity');
$table->text('location_info');
$table->timestamps();
});
Product Model:
public function warehouses()
{
return $this->belongsToMany(Warehouse::class)->withPivot(['id', 'quantity', 'location_info']);
}
public function warehouses()
{
return $this->belongsToMany(Warehouse::class)->withPivot(['id', 'quantity', 'location_info']);
}
Warehouse Model:
public function products(): BelongsToMany
{
return $this->belongsToMany(Product::class)->withPivot(['id', 'quantity', 'location_info']);
}
public function products(): BelongsToMany
{
return $this->belongsToMany(Product::class)->withPivot(['id', 'quantity', 'location_info']);
}
SELECT
`product_warehouse`.`warehouse_id` AS `pivot_warehouse_id`,
`product_warehouse`.`product_id` AS `pivot_product_id`,
`product_warehouse`.`quantity` AS `pivot_quantity`,
`product_warehouse`.`location_info` AS `pivot_location_info`,
`product_warehouse`.*,
`products`.*
FROM
`products`
INNER JOIN `product_warehouse` ON `products`.`id` = `product_warehouse`.`product_id`
WHERE
`product_warehouse`.`warehouse_id` = 1
ORDER BY
`id` DESC
limit
50 OFFSET 0
SELECT
`product_warehouse`.`warehouse_id` AS `pivot_warehouse_id`,
`product_warehouse`.`product_id` AS `pivot_product_id`,
`product_warehouse`.`quantity` AS `pivot_quantity`,
`product_warehouse`.`location_info` AS `pivot_location_info`,
`product_warehouse`.*,
`products`.*
FROM
`products`
INNER JOIN `product_warehouse` ON `products`.`id` = `product_warehouse`.`product_id`
WHERE
`product_warehouse`.`warehouse_id` = 1
ORDER BY
`id` DESC
limit
50 OFFSET 0
102 replies
FFilament
Created by shenntek on 3/14/2024 in #❓┊help
cluster menu layout gives a lot of space between widgets and table
when a cluster has a lot of submenu items and open the submenu items there is a lot of space between the widgets and the table. see short video. is this a bug?
1 replies
FFilament
Created by shenntek on 3/4/2024 in #❓┊help
how to register {tenant} routes for API (api.php routes file)
I cannot figure out how i can manage the api.php routes to register the {tenant} parameter so that i can use this for my API routes. filament/filament/routes/web.php uses something like this:
Route::name('filament.')
->group(function () {
foreach (Filament::getPanels() as $panel) {
/** @var \Filament\Panel $panel */
$panelId = $panel->getId();
$hasTenancy = $panel->hasTenancy();
$tenantRoutePrefix = $panel->getTenantRoutePrefix();
$tenantSlugAttribute = $panel->getTenantSlugAttribute();
$domains = $panel->getDomains();
Route::name('filament.')
->group(function () {
foreach (Filament::getPanels() as $panel) {
/** @var \Filament\Panel $panel */
$panelId = $panel->getId();
$hasTenancy = $panel->hasTenancy();
$tenantRoutePrefix = $panel->getTenantRoutePrefix();
$tenantSlugAttribute = $panel->getTenantSlugAttribute();
$domains = $panel->getDomains();
but when i add these to my routes/api.php only $panelId = 1 and $hasTenancy = true. the rest of the variables are NULL... Also in the Http/Middleware/IdentifyTenant.php this get mentioned like this:
if (! $request->route()->hasParameter('tenant')) {}
if (! $request->route()->hasParameter('tenant')) {}
and
$tenant = $panel->getTenant($request->route()->parameter('tenant'));
$tenant = $panel->getTenant($request->route()->parameter('tenant'));
how can i make sure that also for my API enpoints i can use the tenant slug in the URI. php artisan route:list only shows it for the web.php endpoints like so:
GET|HEAD admin/{tenant}/jobs .......................................................... filament.admin.resources.jobs.index › App\Filament\Resources\JobResource\Pages\ListJobs
GET|HEAD admin/{tenant}/jobs .......................................................... filament.admin.resources.jobs.index › App\Filament\Resources\JobResource\Pages\ListJobs
but for my API endpoints: no {tenant}
POST api/admin/jobs ........................................................ api.admin.jobs.create › App\Filament\Resources\JobResource\Api\Handlers\CreateHandler@handler
POST api/admin/jobs ........................................................ api.admin.jobs.create › App\Filament\Resources\JobResource\Api\Handlers\CreateHandler@handler
23 replies
FFilament
Created by shenntek on 1/30/2024 in #❓┊help
protected $isScopedToTenant not available when extending from package Resource Class
I cannot change the $isScopedToTenant variable when i use the following setup: Package has an Resource called:
class ScheduleResource extends Resource {}
class ScheduleResource extends Resource {}
in my application i override/extend this ScheduleResource:
use Package\Resource\ScheduleResource as BaseScheduleResource;

class ScheduleResource extends BaseScheduleResource {

protected static bool $isScopedToTenant = false; // <-- will not work
}
use Package\Resource\ScheduleResource as BaseScheduleResource;

class ScheduleResource extends BaseScheduleResource {

protected static bool $isScopedToTenant = false; // <-- will not work
}
i have to add in my package Resource class:
class ScheduleResource extends Resource {
public static bool $isScopedToTenant = true;
}
class ScheduleResource extends Resource {
public static bool $isScopedToTenant = true;
}
and then in my application ScheduleResource:
use Package\Resource\ScheduleResource as BaseScheduleResource;

class ScheduleResource extends BaseScheduleResource {
public static bool $isScopedToTenant = false; // <-- this WILL work
}
use Package\Resource\ScheduleResource as BaseScheduleResource;

class ScheduleResource extends BaseScheduleResource {
public static bool $isScopedToTenant = false; // <-- this WILL work
}
also this won't work:
class ScheduleResource extends BaseScheduleResource {

public function __construct() {
static::scopeToTenant(false); <-- will not work
}
}
class ScheduleResource extends BaseScheduleResource {

public function __construct() {
static::scopeToTenant(false); <-- will not work
}
}
4 replies
FFilament
Created by shenntek on 1/14/2024 in #❓┊help
multi tenancy as polymorphic table
In multi-tenancy by default every resource should get an extra table column team_id for example. Isn’t it possible to use one polymorphic table with which resource holds access to which team and which resource record and corresponding user? Keeps all the rest of the tables clean and no extra migrations to run on the tables. Has anybody tried yet / is it possible?
4 replies