Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: PHPStan

on:
push:
branches:
- main
pull_request:

jobs:
phpstan:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: re: PHP version.

coverage: none

- name: Install Composer dependencies
run: composer install --no-interaction --prefer-dist --no-progress

- name: Run Larastan
run: composer analyse
5 changes: 5 additions & 0 deletions .lando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ tooling:
description: Run Duster fix|lint
cmd: ./vendor/bin/duster
dir: /app
analyse:
service: appserver
description: Run Larastan static analysis
cmd: composer analyse
dir: /app
art:
service: appserver
description: Run an Artisan command
Expand Down
7 changes: 5 additions & 2 deletions app/Console/Commands/CreateUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Models\User;
use Exception;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;

use function Laravel\Prompts\password;
use function Laravel\Prompts\select;
Expand All @@ -31,7 +32,7 @@ class CreateUser extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): int
{
$name = text(label: 'What is the name of the user?', required: true);
$email = text(
Expand Down Expand Up @@ -73,9 +74,11 @@ public function handle()
} catch (Exception $e) {
$this->error("Failed to create user: {$e->getMessage()}");

return;
return Command::FAILURE;
}

$this->info("User: {$user->name} with role {$role} created successfully.");

return Command::SUCCESS;
}
}
3 changes: 3 additions & 0 deletions app/Console/Commands/TestMailDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public function handle(): void
$this->info('Test email sent');
}

/**
* @return array<string, string>
*/
protected function promptForMissingArgumentsUsing(): array
{
return [
Expand Down
2 changes: 1 addition & 1 deletion app/Enums/NavigationGroupsEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ enum NavigationGroupsEnum: string implements HasLabel
{
case ADMIN = 'admin';

public function getLabel(): ?string
public function getLabel(): string
{
return match ($this) {
self::ADMIN => __('Organization'),
Expand Down
4 changes: 2 additions & 2 deletions app/Enums/RolesEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ enum RolesEnum: string implements HasColor, HasLabel
case ADMIN = 'admin';
case EDITOR = 'editor';

public function getLabel(): ?string
public function getLabel(): string
{
return match ($this) {
self::SUPER_ADMIN => __('Super Admin'),
Expand All @@ -20,7 +20,7 @@ public function getLabel(): ?string
};
}

public function getColor(): string|array|null
public function getColor(): string
{
return match ($this) {
self::SUPER_ADMIN => 'primary',
Expand Down
23 changes: 18 additions & 5 deletions app/Filament/Pages/Auth/EditProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Models\Role;
use Filament\Auth\Pages\EditProfile as EditProfileBase;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Components\Tabs;
use Filament\Schemas\Components\Tabs\Tab;
use Filament\Schemas\Schema;
Expand Down Expand Up @@ -33,31 +34,43 @@ public function getBreadcrumbs(): array

public function form(Schema $schema): Schema
{
/** @var TextInput $nameFormComponent */
$nameFormComponent = $this->getNameFormComponent();

/** @var TextInput $emailFormComponent */
$emailFormComponent = $this->getEmailFormComponent();

/** @var TextInput $passwordFormComponent */
$passwordFormComponent = $this->getPasswordFormComponent();

/** @var TextInput $passwordConfirmationFormComponent */
$passwordConfirmationFormComponent = $this->getPasswordConfirmationFormComponent();

return $schema
->components([
Tabs::make('Tabs')
->tabs([
Tab::make(__('Account Details'))
->schema([
$this->getNameFormComponent()
$nameFormComponent
->helperText(__('Your full name, used for display purposes')),
$this->getEmailFormComponent()
$emailFormComponent
->helperText(__('Your email address, used for notifications and account recovery'))
->prefixIcon('phosphor-envelope-simple'),
Select::make('roles')
->label(__('Role'))
->relationship('roles', 'name')
->getOptionLabelFromRecordUsing(fn (Role $record) => $record?->name?->getLabel())
->getOptionLabelFromRecordUsing(fn (Role $record): string => $record->name->getLabel())
->prefixIcon('phosphor-shield-check')
->required()
->searchable()
->preload(),
]),
Tab::make(__('Security'))
->schema([
$this->getPasswordFormComponent()
$passwordFormComponent
->label(__('New Password')),
$this->getPasswordConfirmationFormComponent()
$passwordConfirmationFormComponent
->label(__('Confirm New Password'))
->helperText(__('Verify your new password')),
$this->getCurrentPasswordFormComponent(),
Expand Down
3 changes: 3 additions & 0 deletions app/Filament/Resources/Users/Actions/InviteUserAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public static function make(string $name): Action
->action(fn (array $data) => InviteUserAction::handle($data));
}

/**
* @param array{name: string, email: string, role: string} $data
*/
public static function handle(array $data): void
{
$validator = Validator::make($data, [
Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Resources/Users/Schemas/UserForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function configure(Schema $schema): Schema
Select::make('roles')
->label(__('Role'))
->relationship('roles', 'name')
->getOptionLabelFromRecordUsing(fn (Role $record) => $record?->name?->getLabel())
->getOptionLabelFromRecordUsing(fn (Role $record): string => $record->name->getLabel())
->prefixIcon('phosphor-shield-check')
->required()
->searchable()
Expand Down
3 changes: 3 additions & 0 deletions app/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use App\Enums\RolesEnum;
use Spatie\Permission\Models\Role as SpatieRole;

/**
* @property RolesEnum $name
*/
class Role extends SpatieRole
{
protected function casts(): array
Expand Down
9 changes: 3 additions & 6 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Enums\RolesEnum;
use App\Observers\UserObserver;
use Database\Factories\UserFactory;
use Filament\Auth\MultiFactor\App\Contracts\HasAppAuthentication;
use Filament\Auth\MultiFactor\App\Contracts\HasAppAuthenticationRecovery;
use Filament\Facades\Filament;
Expand All @@ -25,9 +26,7 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
use HasFactory, HasRoles, Notifiable;

/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'name',
Expand All @@ -37,9 +36,7 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
];

/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
* @var list<string>
*/
protected $hidden = [
'password',
Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"barryvdh/laravel-debugbar": "^3.14",
"fakerphp/faker": "^1.23",
"filament/upgrade": "^4.0",
"larastan/larastan": "^3.0",
"laravel/boost": "^1.0",
"laravel/pail": "^1.1",
"laravel/pint": "^1.13",
Expand Down Expand Up @@ -62,6 +63,9 @@
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
"@php artisan migrate --graceful --ansi"
],
"analyse": [
"@php vendor/bin/phpstan analyse --memory-limit=2G"
],
"dev": [
"Composer\\Config::disableProcessTimeout",
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
Expand Down
134 changes: 132 additions & 2 deletions composer.lock

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

Loading
Loading