wandiaprianto
wandiaprianto
FFilament
Created by wandiaprianto on 12/7/2023 in #❓┊help
Filament Shield, how to create different permissions in same role
yes, thankyou @Vp for your help i use php artisan permission:show to list out all of the permission and i wrong , not view_any::users but view_any_other::user because i put User.php in 'other'
22 replies
FFilament
Created by wandiaprianto on 12/7/2023 in #❓┊help
Filament Shield, how to create different permissions in same role
Okay, thankyou so much. i will investigate the permission.
22 replies
FFilament
Created by wandiaprianto on 12/7/2023 in #❓┊help
Filament Shield, how to create different permissions in same role
No description
22 replies
FFilament
Created by wandiaprianto on 12/7/2023 in #❓┊help
Filament Shield, how to create different permissions in same role
okay Sir, i'll try
22 replies
FFilament
Created by wandiaprianto on 12/7/2023 in #❓┊help
Filament Shield, how to create different permissions in same role
No description
22 replies
FFilament
Created by wandiaprianto on 12/7/2023 in #❓┊help
Filament Shield, how to create different permissions in same role
@DrByte in this capture, the user already have the permission all of the permission in UserResources
22 replies
FFilament
Created by wandiaprianto on 12/7/2023 in #❓┊help
Filament Shield, how to create different permissions in same role
already clear cache using
php artisan optimize
php artisan optimize
but still not working, any solution Sir? or maybe i have wrong in my code?
22 replies
FFilament
Created by wandiaprianto on 12/7/2023 in #❓┊help
Filament Shield, how to create different permissions in same role
UserResource.php (app > filament > resources > other)
<?php

namespace App\Filament\Resources\Other;

use App\Filament\Resources\Other\UserResource\Pages;
use App\Models\User;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Infolists\Components;
use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;

class UserResource extends Resource
{
protected static ?string $model = User::class;
protected static ?string $slug = 'other/users';
protected static ?string $recordTitleAttribute = 'name';
protected static ?string $navigationGroup = 'Other';
protected static ?string $navigationIcon = 'heroicon-o-circle-stack';
protected static ?int $navigationSort = 3;

public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->required()
->unique(User::class, 'name', ignoreRecord: true),

Forms\Components\Select::make('roles')
->relationship('roles', 'name')
->multiple()
->preload()
->searchable()
])->columns(1);
}

public static function table(Table $table): Table
{
...
}

public static function infolist(Infolist $infolist): Infolist
{
...
}

public static function getPages(): array
{
...
}
}
<?php

namespace App\Filament\Resources\Other;

use App\Filament\Resources\Other\UserResource\Pages;
use App\Models\User;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Infolists\Components;
use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;

class UserResource extends Resource
{
protected static ?string $model = User::class;
protected static ?string $slug = 'other/users';
protected static ?string $recordTitleAttribute = 'name';
protected static ?string $navigationGroup = 'Other';
protected static ?string $navigationIcon = 'heroicon-o-circle-stack';
protected static ?int $navigationSort = 3;

public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->required()
->unique(User::class, 'name', ignoreRecord: true),

Forms\Components\Select::make('roles')
->relationship('roles', 'name')
->multiple()
->preload()
->searchable()
])->columns(1);
}

public static function table(Table $table): Table
{
...
}

public static function infolist(Infolist $infolist): Infolist
{
...
}

public static function getPages(): array
{
...
}
}
22 replies
FFilament
Created by wandiaprianto on 12/7/2023 in #❓┊help
Filament Shield, how to create different permissions in same role
ManageUsers.php (app > filament > resources > other > userresource > pages)
<?php

namespace App\Filament\Resources\Other\UserResource\Pages;

use App\Filament\Resources\Other\UserResource;
use Filament\Resources\Pages\ManageRecords;

class ManageUsers extends ManageRecords
{
protected static string $resource = UserResource::class;

protected function getActions(): array
{
return [
\Filament\Actions\CreateAction::make(),
];
}
}
<?php

namespace App\Filament\Resources\Other\UserResource\Pages;

use App\Filament\Resources\Other\UserResource;
use Filament\Resources\Pages\ManageRecords;

class ManageUsers extends ManageRecords
{
protected static string $resource = UserResource::class;

protected function getActions(): array
{
return [
\Filament\Actions\CreateAction::make(),
];
}
}
22 replies
FFilament
Created by wandiaprianto on 12/7/2023 in #❓┊help
Filament Shield, how to create different permissions in same role
No description
22 replies
FFilament
Created by wandiaprianto on 12/7/2023 in #❓┊help
Filament Shield, how to create different permissions in same role
thankyou for your answer Sir, i have another question Sir,
why user resources doesn't show in navbar?
this is my User.php (app > models > User.php)
use Spatie\Permission\Traits\HasRoles;
use Filament\Models\Contracts\FilamentUser;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use BezhanSalleh\FilamentShield\Traits\HasPanelShield;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements HasTenants, MustVerifyEmail, FilamentUser
{
use HasApiTokens;
use HasFactory;
use Notifiable;
use HasRoles;
use HasPanelShield;

...
use Spatie\Permission\Traits\HasRoles;
use Filament\Models\Contracts\FilamentUser;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use BezhanSalleh\FilamentShield\Traits\HasPanelShield;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements HasTenants, MustVerifyEmail, FilamentUser
{
use HasApiTokens;
use HasFactory;
use Notifiable;
use HasRoles;
use HasPanelShield;

...
and this is my UserPolicy.php (app > policies > UserPolicy.php)
<?php

namespace App\Policies;

use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;

class UserPolicy
{
use HandlesAuthorization;

public function viewAny(User $user): bool
{
return $user->can('view_any::user');
}

public function view(User $user): bool
{
return $user->can('view::user');
}

public function create(User $user): bool
{
return $user->can('create::user');
}

...

}
<?php

namespace App\Policies;

use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;

class UserPolicy
{
use HandlesAuthorization;

public function viewAny(User $user): bool
{
return $user->can('view_any::user');
}

public function view(User $user): bool
{
return $user->can('view::user');
}

public function create(User $user): bool
{
return $user->can('create::user');
}

...

}
and my AuthServiceProvider:
protected $policies = [
...
'App\Models\User' => 'App\Policies\UserPolicy',
'Spatie\Permission\Models\Role' => 'App\Policies\RolePolicy',
...
];
protected $policies = [
...
'App\Models\User' => 'App\Policies\UserPolicy',
'Spatie\Permission\Models\Role' => 'App\Policies\RolePolicy',
...
];
can you help me Sir?
22 replies
FFilament
Created by wandiaprianto on 11/13/2023 in #❓┊help
How to access resource from resource?
okey, thankyou
7 replies
FFilament
Created by wandiaprianto on 11/13/2023 in #❓┊help
How to access resource from resource?
7 replies
FFilament
Created by wandiaprianto on 11/13/2023 in #❓┊help
How to access resource from resource?
what package Sir?
7 replies
FFilament
Created by wandiaprianto on 11/11/2023 in #❓┊help
Last letter is not capitalized
i solved by adding mutateFormDataUsing
...
$data['police_number'] = strtoupper($data['police_number']);
...
...
$data['police_number'] = strtoupper($data['police_number']);
...
thanks everyone
7 replies
FFilament
Created by wandiaprianto on 11/11/2023 in #❓┊help
Last letter is not capitalized
No description
7 replies
FFilament
Created by wandiaprianto on 11/11/2023 in #❓┊help
Last letter is not capitalized
Please anyone, can u help me? thanks
7 replies
FFilament
Created by wandiaprianto on 11/11/2023 in #❓┊help
Last letter is not capitalized
No description
7 replies
FFilament
Created by wandiaprianto on 11/11/2023 in #❓┊help
How to set TextColumn isHidden / Disabled but searchable?
4 replies
FFilament
Created by wandiaprianto on 11/11/2023 in #❓┊help
How to searchable and sortable my custom column?
this is my code:
TextColumn::make('brand.name')
->searchable()
->sortable()
->hidden(),
TextColumn::make('brand.name')
->searchable()
->sortable()
->hidden(),
is hide, but i can't search. where did i missed? thankyou
8 replies