Skip to content

Commit

Permalink
Merge pull request #13 from KingSit3/id-translation
Browse files Browse the repository at this point in the history
Add ID translation
  • Loading branch information
AaEzha authored Oct 27, 2024
2 parents f146a4a + ceba2b3 commit bbef845
Show file tree
Hide file tree
Showing 21 changed files with 221 additions and 37 deletions.
2 changes: 1 addition & 1 deletion app/Filament/Jamaah/Pages/JamaahProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class JamaahProfile extends EditTenantProfile

public static function getLabel(): string
{
return 'Jamaah profile';
return __("common.jamaah_profile");
}

public function form(Form $form): Form
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Jamaah/Pages/JamaahRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class JamaahRegistration extends RegisterTenant
{
public static function getLabel(): string
{
return 'Register Jamaah';
return __("common.register_jamaah");
}

public function form(Form $form): Form
Expand Down
14 changes: 7 additions & 7 deletions app/Filament/Jamaah/Resources/MajelisResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')->required(),
Forms\Components\TextInput::make('name')
->label(__('common.name'))
->required(),
Forms\Components\TextInput::make('website')
->label(__('common.website'))
->suffix('.jamaah.com')
->prefixIcon('heroicon-m-globe-alt')
->required()
Expand All @@ -57,12 +60,9 @@ public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('website'),
Tables\Columns\TextColumn::make('type'),
])
->filters([
// Tables\Filters\TrashedFilter::make(),
Tables\Columns\TextColumn::make('name')->label(__('common.name')),
Tables\Columns\TextColumn::make('website')->label(__('common.website')),
Tables\Columns\TextColumn::make('type')->label(__('common.type')),
])
->actions([
Tables\Actions\EditAction::make(),
Expand Down
27 changes: 22 additions & 5 deletions app/Filament/Jamaah/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,22 @@ class UserResource extends Resource
protected static ?string $model = User::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

public static function getNavigationLabel(): string
{
return __('common.users');
}

public static function getPluralLabel(): ?string
{
return __('common.users');
}

public static function form(Form $form): Form
{
return $form
->schema([
Select::make("user_id")
->label("User")
->label(__('common.name'))
->options(
User::whereNotIn('id', function ($query) {
$query->select('user_id')
Expand All @@ -45,7 +55,7 @@ public static function form(Form $form): Form
->searchable()
->required(),
Select::make("role")
->label("Role")
->label(__('common.role'))
->options([
'admin' => 'Admin',
'staff' => 'Staff',
Expand All @@ -61,9 +71,16 @@ public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name')->sortable()->searchable(),
TextColumn::make('email')->searchable(),
ViewColumn::make('role')->view("tables.columns.select-role")
TextColumn::make('name')
->label(__('common.name'))
->sortable()
->searchable(),
TextColumn::make('email')
->label(__('common.email'))
->searchable(),
ViewColumn::make('role')
->label(__('common.role'))
->view("tables.columns.select-role")
])
->actions([
DeleteAction::make()
Expand Down
7 changes: 6 additions & 1 deletion app/Filament/Jamaah/Widgets/TransactionsChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class TransactionsChart extends ChartWidget
{
protected static ?string $heading = 'Transaction Chart';
// protected static ?string $heading = 'Transaction Chart';
protected int | string | array $columnSpan = 'full';

protected function getData(): array
Expand All @@ -31,4 +31,9 @@ protected function getType(): string
{
return 'line';
}

public function getHeading(): string
{
return __("widget.transaction_chart");
}
}
22 changes: 14 additions & 8 deletions app/Filament/Superman/Resources/JamaahResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,22 @@ public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')->required(),
Forms\Components\TextInput::make('name')
->label(__('common.name'))
->required(),
Forms\Components\TextInput::make('website')
->label(__('common.website'))
->suffix('.jamaah.com')
->prefixIcon('heroicon-m-globe-alt')
->required()
->alphaDash()
->unique(table: Jamaah::class, column: "website", ignoreRecord: true),
Forms\Components\Select::make("type")->options([
'masjid' => 'Masjid',
'majelis' => 'Majelis',
])
Forms\Components\Select::make("type")
->label(__('common.type'))
->options([
'masjid' => 'Masjid',
'majelis' => 'Majelis',
])
->selectablePlaceholder(false)
->required()

Expand All @@ -47,12 +52,13 @@ public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('website'),
Tables\Columns\TextColumn::make('type'),
Tables\Columns\TextColumn::make('name')->label(__('common.name')),
Tables\Columns\TextColumn::make('website')->label(__('common.website')),
Tables\Columns\TextColumn::make('type')->label(__('common.type')),
])
->filters([
Filters\SelectFilter::make('type')
->label(__('common.type'))
->options([
'masjid' => 'Masjid',
'majelis' => 'Majelis',
Expand Down
22 changes: 17 additions & 5 deletions app/Filament/Superman/Resources/UsersResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,27 @@
class UsersResource extends Resource
{
protected static ?string $model = User::class;

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

public static function getNavigationLabel(): string
{
return __('common.users');
}

public static function getPluralLabel(): ?string
{
return __('common.users');
}

public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')->required(),
Forms\Components\TextInput::make('name')
->label(__('common.name'))
->required(),
Forms\Components\Select::make('roles')
->label(__('common.role'))
->relationship('roles', 'name')
->selectablePlaceholder(false)
->required()
Expand All @@ -35,9 +47,9 @@ public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('email'),
Tables\Columns\TextColumn::make('created_at')->label("Register date"),
Tables\Columns\TextColumn::make('name')->label(__('common.name')),
Tables\Columns\TextColumn::make('email')->label(__('common.email')),
Tables\Columns\TextColumn::make('created_at')->label(__('common.register_date')),
])
->filters([
//
Expand Down
4 changes: 2 additions & 2 deletions app/Filament/Superman/Widgets/StatsOverview.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class StatsOverview extends BaseWidget
protected function getStats(): array
{
return [
Stat::make('Total Jamaah', '192.1k'),
Stat::make('Total Users', '21%'),
Stat::make('Total Jamaah', '192.1k')->label(__("widget.total_jamaah")),
Stat::make('Total Users', '21%')->label(__("widget.total_users")),
];
}
}
11 changes: 11 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Http\Responses\LogoutResponse;
use App\Models\User;
use BezhanSalleh\FilamentLanguageSwitch\LanguageSwitch;
use Illuminate\Support\ServiceProvider;
use Filament\Http\Responses\Auth\Contracts\LogoutResponse as LogoutResponseContract;
use Illuminate\Database\Eloquent\Model;
Expand All @@ -29,5 +30,15 @@ public function boot(): void
Gate::before(function (User $user, string $ability) {
return $user->is_superman ? true : null;
});

LanguageSwitch::configureUsing(function (LanguageSwitch $switch) {
$switch
->locales(['id', 'en'])
->flags([
'id' => asset('flags/id.svg'),
'en' => asset('flags/en.svg'),
])
->visible(outsidePanels: true);
});
}
}
12 changes: 7 additions & 5 deletions app/Providers/Filament/SupermanPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ public function panel(Panel $panel): Panel
])

// Plugins
->plugin(FilamentSocialitePlugin::make()->providers([
Provider::make("google")
->icon('fab-google')
->label("google")
])->slug('superman'))
->plugin(FilamentSocialitePlugin::make()
->providers([
Provider::make("google")
->icon('fab-google')
->label("google")
])
->slug('superman'))
->plugin(FilamentSpatieRolesPermissionsPlugin::make())

// Middlewares
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"require": {
"php": "^8.2",
"althinect/filament-spatie-roles-permissions": "^2.2",
"bezhansalleh/filament-language-switch": "^3.1",
"dutchcodingcompany/filament-socialite": "^2.2",
"filament/filament": "^3.2",
"laravel/framework": "^11.9",
Expand Down
77 changes: 76 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
|
*/

'locale' => env('APP_LOCALE', 'en'),
'locale' => env('APP_LOCALE', 'id'),

'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),

Expand Down
11 changes: 11 additions & 0 deletions lang/en/common.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

return [
"users" => "Users",
"name" => "Name",
"email" => "Email",
"register_date" => "Register date",
"register_jamaah" => "Register Jamaah",

"jamaah_profile" => "Jamaah Profile",
];
8 changes: 8 additions & 0 deletions lang/en/widget.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

return [
"total_jamaah" => "Total Jamaah",
"total_users" => "Total Users",

"transaction_chart" => "Transaction Chart",
];
Loading

0 comments on commit bbef845

Please sign in to comment.