Compare commits

...

4 Commits

Author SHA1 Message Date
Mekan1206
c0bfe974ad Add avatar functionality to User model
- Implemented HasAvatar contract in User model to support avatar management.
- Added getFilamentAvatarUrl method to return the default avatar URL.
2025-12-21 04:20:45 +05:00
Mekan1206
895c5f6226 Update ManageCards page and localization for card creation
- Added a label for the 'Add card' action in the ManageCards page.
- Updated Turkish translations for card creation actions and notifications to improve clarity and consistency.
2025-12-21 04:13:47 +05:00
Mekan1206
88d84ac457 Add title method to ManageCards page for improved user experience 2025-12-21 04:01:05 +05:00
Mekan1206
94ad59ce24 Enhance user role management and update Filament panel middleware
- Added new user roles: operator, operator_card, operator_loan, client, and currency_maintainer in ShieldSeeder.
- Included EnsureUserHasRole middleware in the Filament panel for improved access control.
2025-12-21 03:49:55 +05:00
9 changed files with 80 additions and 12 deletions

View File

@@ -5,15 +5,23 @@ namespace App\Filament\Clusters\Cards\Cards\Pages;
use App\Filament\Clusters\Cards\Cards\CardResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ManageRecords;
use Illuminate\Contracts\Support\Htmlable;
class ManageCards extends ManageRecords
{
protected static string $resource = CardResource::class;
public function getTitle(): string | Htmlable
{
return __('My cards');
}
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
CreateAction::make()
->label(__('Add card'))
->createAnother(false),
];
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class EnsureUserHasRole
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
// if user does not have any role, add role "client"
/** @var \App\Models\User */
$user = $request->user();
if ($user->roles->count() == 0) {
$user->assignRole('client');
}
return $next($request);
}
}

View File

@@ -6,6 +6,7 @@ use App\Modules\UserAdjustments\Traits\UserAdjustments;
use Filament\Models\Contracts\FilamentUser;
use Filament\Panel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Filament\Models\Contracts\HasAvatar;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Date;
@@ -20,7 +21,7 @@ use Illuminate\Support\Facades\Date;
* @property Date|null $created_at
* @property Date|null $updated_at
*/
class User extends Authenticatable implements FilamentUser
class User extends Authenticatable implements FilamentUser, HasAvatar
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory;
@@ -56,4 +57,12 @@ class User extends Authenticatable implements FilamentUser
{
return true;
}
/**
* Get the avatar URL for the user.
*/
public function getFilamentAvatarUrl(): ?string
{
return '/assets/images/avatar.png';
}
}

View File

@@ -3,6 +3,7 @@
namespace App\Providers\Filament;
use App\Http\Middleware\EnsureProfileIsFilled;
use App\Http\Middleware\EnsureUserHasRole;
use App\Livewire\UserProfileFields;
use App\Modules\BaseAuth\Middleware\RedirectIfUserPhoneIsUnVerfied;
use BezhanSalleh\FilamentShield\FilamentShieldPlugin;
@@ -73,11 +74,12 @@ class WorkPanelProvider extends PanelProvider
UserProfileFields::class,
]),
// FilamentUpload::make(),
FilamentUpload::make(),
])
->authMiddleware([
Authenticate::class,
EnsureProfileIsFilled::class,
EnsureUserHasRole::class,
])
->spa()
->databaseTransactions()

View File

@@ -35,6 +35,26 @@ class ShieldSeeder extends Seeder
'name' => 'admin',
'guard_name' => 'web',
],
[
'name' => 'operator',
'guard_name' => 'web',
],
[
'name' => 'operator_card',
'guard_name' => 'web',
],
[
'name' => 'operator_loan',
'guard_name' => 'web',
],
[
'name' => 'client',
'guard_name' => 'web',
],
[
'name' => 'currency_maintainer',
'guard_name' => 'web',
],
])->map(fn ($role) => [
...$role,
'created_at' => now(),

View File

@@ -730,5 +730,6 @@
"Total": "Jemi",
"Data": "Maglumatlar",
"Watch Full": "Giňişleýin",
"Order ID": "Sargyt belgisi"
"Order ID": "Sargyt belgisi",
"Add card": "Kart goşmak"
}

View File

@@ -8,16 +8,16 @@ return [
'modal' => [
'heading' => ':label döret',
'heading' => ':label goşmak',
'actions' => [
'create' => [
'label' => 'Döret',
'label' => 'Goşmak',
],
'create_another' => [
'label' => 'Döret we başgasyny döret',
'label' => 'Goşmak we başgasyny goşmak',
],
],
@@ -27,7 +27,7 @@ return [
'notifications' => [
'created' => [
'title' => 'Döredildi',
'title' => 'Goşuldy',
],
],

View File

@@ -625,20 +625,20 @@ return [
'create_option' => [
'label' => 'Döret',
'label' => 'Goş',
'modal' => [
'heading' => 'Döret',
'heading' => 'Goş',
'actions' => [
'create' => [
'label' => 'Döret',
'label' => 'Goş',
],
'create_another' => [
'label' => 'Döret we başgasyny döret',
'label' => 'Goş we başgasyny goş',
],
],

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB