DS
DS
FFilament
Created by DS on 8/29/2023 in #❓┊help
Create action in simple resource as slideover
I found it, I hadn't read it and it's on the Manage${Resource} Page
5 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
it can be changed as the proyect needs and as you say in the config, it can be used as the tenant_id
122 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
hello! yes, sure,
<?php

namespace App\Models\Support;

use App\Models\Company;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Spatie\Permission\Traits\HasRoles as SpatieHasRoles;

trait HasRoles
{
use SpatieHasRoles;

public function rolesOnTenant(Company $tenant): BelongsToMany
{
$originalTenantId = getPermissionsTeamId();

setPermissionsTeamId($tenant);

$roles = $this->roles();

setPermissionsTeamId($originalTenantId);

return $roles;
}

public function syncRolesOnTenant(
Company $tenant,
array|\Spatie\Permission\Contracts\Role|\Illuminate\Support\Collection|string|int $roles
): self
{
$originalTenantId = getPermissionsTeamId();

setPermissionsTeamId($tenant);

$this->syncRoles($roles);

setPermissionsTeamId($originalTenantId);

return $this;
}

public function assignRoleOnTenant(
Company $tenant,
array|string|int|\Spatie\Permission\Contracts\Role|\Illuminate\Support\Collection $role
): self
{
$originalTenantId = getPermissionsTeamId();

setPermissionsTeamId($tenant);

$this->assignRole($role);

setPermissionsTeamId($originalTenantId);

return $this;
}
}
<?php

namespace App\Models\Support;

use App\Models\Company;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Spatie\Permission\Traits\HasRoles as SpatieHasRoles;

trait HasRoles
{
use SpatieHasRoles;

public function rolesOnTenant(Company $tenant): BelongsToMany
{
$originalTenantId = getPermissionsTeamId();

setPermissionsTeamId($tenant);

$roles = $this->roles();

setPermissionsTeamId($originalTenantId);

return $roles;
}

public function syncRolesOnTenant(
Company $tenant,
array|\Spatie\Permission\Contracts\Role|\Illuminate\Support\Collection|string|int $roles
): self
{
$originalTenantId = getPermissionsTeamId();

setPermissionsTeamId($tenant);

$this->syncRoles($roles);

setPermissionsTeamId($originalTenantId);

return $this;
}

public function assignRoleOnTenant(
Company $tenant,
array|string|int|\Spatie\Permission\Contracts\Role|\Illuminate\Support\Collection $role
): self
{
$originalTenantId = getPermissionsTeamId();

setPermissionsTeamId($tenant);

$this->assignRole($role);

setPermissionsTeamId($originalTenantId);

return $this;
}
}
122 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
im using "company" as the relation for tenancy
122 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
sorry, it was here 😒 the error is this "SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'company_id' in where clause is ambiguous "
122 replies
FFilament
Created by metelidrissi on 8/26/2023 in #❓┊help
It's possible to modify template not just colors?
awesome, thanks!
25 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
i could find it, i've make a post here in the discord channel but it says something related to the query, please let me find it
122 replies
FFilament
Created by metelidrissi on 8/26/2023 in #❓┊help
It's possible to modify template not just colors?
@awcodes it's possible to implement a new layout for the dashboard using tailwind ? keeping all the filament functionalities ?
25 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
@tuto1902 i've implemented the HasRoles trait and it works but sometimes i got some errors
122 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
i dont think that will be the best solution @BKF Dev because in that solution to the problem its not related to this one... it would be a work around but not solves my problem, anyway thanks for sharing this here...
122 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
@JamesAutoDude
122 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
as a suggestion we can add the company_id to the roles and use a custom HasRoles trait to change the roles for each company ... if i can make it work i would make a PR to filament hoping it works for someone else, i really like filament and i want to somehow be able to contribute something. Thanks for your help.
122 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
if i remove the teams functionality from spatie everything work as spected but i really need to use spatie roles teams functionality with filament any help will be really appreciated
122 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
I've a repo but its a private repo if you need i can give you part of the related code or i can make a new public repo replicating the problem if you want
122 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
@JamesAutoDude it returns roles but when do that i got
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'company_id' in where clause is ambiguous
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'company_id' in where clause is ambiguous
`
122 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
I understand and I thank you for the explanation, but in my case I need the role by team, for example, a role can exist in a team (company in my case) but not in another. That is why I need it, until now I have made it work only when I want to "attach" a role to a user, the role relationship manager returns only those that have been related to that team regardless of whether they belong to that team or not. @JamesAutoDude when i do
Tables\Actions\AttachAction::make()
->preloadRecordSelect()
->recordSelectOptionsQuery(function (Builder $query) {
$roles = Role::where('company_id', Filament::getTenant()->id)->get()->pluck('id')->toArray();
return $query->whereIn('company_id', $roles);
})
Tables\Actions\AttachAction::make()
->preloadRecordSelect()
->recordSelectOptionsQuery(function (Builder $query) {
$roles = Role::where('company_id', Filament::getTenant()->id)->get()->pluck('id')->toArray();
return $query->whereIn('company_id', $roles);
})
` i got SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'company_id' in where clause is ambiguous
122 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
thanks a lot
122 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
im thinking to continue searching how to do this
122 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
and i would like to implement this
122 replies
FFilament
Created by DS on 8/10/2023 in #❓┊help
is there a way to use spatie roles with teams id and filament multenancy on V3 ?
really i love how it works filament
122 replies