Skip to content

Commit

Permalink
- admin panel i18n (#236)
Browse files Browse the repository at this point in the history
* - added filament package and first crud - user resource

* - cdf

* #222 - activity crud with multilanguage

* #222 - merged main

* - fixes

* #222 - activities crud update

* #222 - added factory and seeder

* - cr fix

* - cr fix

* #222 - cr fixes

* - fixes

* - wip with i18n of admin panel

* - fixes and bumps

* - fixes

* - composer update

* - updated workflow

* - cr fixes
  • Loading branch information
kamilpiech97 authored Apr 23, 2024
1 parent d0a6c2c commit 8215989
Show file tree
Hide file tree
Showing 12 changed files with 859 additions and 539 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check.php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
pgsql:
image: postgres:16.1-alpine3.18 # https://hub.docker.com/_/postgres
env:
POSTGRES_DB: website
POSTGRES_USER: website
POSTGRES_DB: website-ci
POSTGRES_USER: website-ci
POSTGRES_PASSWORD: password
# Set health checks to wait until postgres has started
options: >-
Expand Down
12 changes: 9 additions & 3 deletions app/Filament/Resources/ActivityResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class ActivityResource extends Resource
use Translatable;

protected static ?string $model = Activity::class;
protected static ?string $label = "Aktualność";
protected static ?string $pluralLabel = "Aktualności";
protected static ?string $navigationIcon = "heroicon-o-rectangle-stack";

public static function form(Form $form): Form
Expand All @@ -46,7 +48,7 @@ public static function form(Form $form): Form
Forms\Components\DateTimePicker::make("published_at")
->format(DateFormats::DATE_DISPLAY)
->time(false)
->requiredUnless("published", true)
->required()
->label("Data publikacji"),
Forms\Components\FileUpload::make("photo")
->label("Zdjęcie")
Expand Down Expand Up @@ -87,8 +89,12 @@ public static function table(Table $table): Table
->falseLabel("Nieopublikowane"),
Filter::make("published_at")
->form([
Forms\Components\DatePicker::make("published_from"),
Forms\Components\DatePicker::make("published_to"),
Forms\Components\DatePicker::make("published_from")
->label("Data publikacji od")
->format(DateFormats::DATE_DISPLAY),
Forms\Components\DatePicker::make("published_to")
->label("Data publikacji do")
->format(DateFormats::DATE_DISPLAY),
])->query(function (Builder $query, array $data): Builder {
return $query
->when(
Expand Down
2 changes: 2 additions & 0 deletions app/Filament/Resources/UserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
class UserResource extends Resource
{
protected static ?string $model = User::class;
protected static ?string $label = "Użytkownik";
protected static ?string $pluralLabel = "Użytkownicy";
protected static ?string $navigationIcon = "heroicon-o-rectangle-stack";

public static function form(Form $form): Form
Expand Down
18 changes: 18 additions & 0 deletions app/Http/Middleware/AdminPanelDefaultLanguage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Blumilk\Website\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class AdminPanelDefaultLanguage
{
public function handle(Request $request, Closure $next)
{
app()->setLocale(config("app.dashboard_locale"));

return $next($request);
}
}
10 changes: 9 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace Blumilk\Website\Models;

use Carbon\Carbon;
use Filament\Models\Contracts\FilamentUser;
use Filament\Panel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
Expand All @@ -18,7 +20,7 @@
* @property Carbon $created_at
* @property Carbon $updated_at
*/
class User extends Authenticatable
class User extends Authenticatable implements FilamentUser
{
use HasApiTokens;
use HasFactory;
Expand All @@ -37,4 +39,10 @@ class User extends Authenticatable
"email_verified_at" => "datetime",
"password" => "hashed",
];

#[\Override]
public function canAccessPanel(Panel $panel): bool
{
return true;
}
}
5 changes: 4 additions & 1 deletion app/Providers/Filament/AdminPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Blumilk\Website\Providers\Filament;

use Blumilk\Website\Http\Middleware\AdminPanelDefaultLanguage;
use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
Expand Down Expand Up @@ -57,9 +58,11 @@ public function panel(Panel $panel): Panel
SubstituteBindings::class,
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
AdminPanelDefaultLanguage::class,
])
->authMiddleware([
Authenticate::class,
]);
])
->spa();
}
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"fakerphp/faker": "^1.23",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.1",
"nunomaduro/larastan": "^2.9",
"phpunit/phpunit": "^10.5",
"larastan/larastan": "^v2.9.5",
"phpunit/phpunit": "^11.1.2",
"spatie/laravel-ignition": "^2.4"
},
"autoload": {
Expand Down
Loading

0 comments on commit 8215989

Please sign in to comment.