• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

luttje / filament-user-attributes / 6907253484

17 Nov 2023 05:27PM UTC coverage: 51.704% (+0.3%) from 51.437%
6907253484

push

github

luttje
wizard make menus consistent

0 of 14 new or added lines in 2 files covered. (0.0%)

43 existing lines in 2 files now uncovered.

698 of 1350 relevant lines covered (51.7%)

12.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Commands/WizardStepConfig.php
1
<?php
2

3
namespace Luttje\FilamentUserAttributes\Commands;
4

5
use Illuminate\Console\Command;
6
use Luttje\FilamentUserAttributes\CodeGeneration\CodeTraverser;
7
use Luttje\FilamentUserAttributes\Contracts\ConfiguresUserAttributesContract;
8
use Luttje\FilamentUserAttributes\Traits\ConfiguresUserAttributes;
9

10
class WizardStepConfig extends Command
11
{
12
    public function __construct()
×
13
    {
14
        $this->signature = 'filament-user-attributes:wizard-config';
×
15
        $this->description = 'Wizard to help setup your config model with Filament User Attributes';
×
16

17
        parent::__construct();
×
18
    }
19

20
    public function handle()
×
21
    {
22
        if (!$this->promptForConfigSetup()) {
×
23
            return;
×
24
        }
25

26
        $this->finalizeConfigSetup();
×
27
    }
28

29
    protected function promptForConfigSetup(): bool
×
30
    {
31
        $this->listConfigurableModels();
×
32

33
        return $this->confirm(
×
34
            "Do you want to let a model (like user or tenant) configure user attributes?",
×
35
            true
×
36
        );
×
37
    }
38

39
    protected function finalizeConfigSetup(): void
×
40
    {
41
        $model = $this->selectModelForConfig("Which model should configure user attributes?");
×
42
        $this->setupConfigModel($model);
×
43
    }
44

45
    private function listConfigurableModels(): void
×
46
    {
47
        $this->line('The following models are setup to support user attributes:');
×
48

49
        collect(WizardStepModels::scanForModels())
×
50
            ->filter(fn ($model) => WizardStepModels::isModelSetup($model))
×
51
            ->each(fn ($model) => $this->line("- $model"));
×
52
    }
53

54
    private function selectModelForConfig(string $prompt): string
×
55
    {
56
        $models = WizardStepModels::scanForModels();
×
57
        $choice = $this->choice($prompt, $models);
×
NEW
58
        return $choice;
×
59
    }
60

61
    protected function setupConfigModel(string $model): void
×
62
    {
63
        $file = $this->getModelFilePath($model);
×
64
        $contents = file_get_contents($file);
×
65

66
        $contents = CodeTraverser::addTrait($contents, ConfiguresUserAttributes::class);
×
67
        $contents = CodeTraverser::addInterface($contents, ConfiguresUserAttributesContract::class);
×
68

69
        file_put_contents($file, $contents);
×
70
    }
71

72
    private function getModelFilePath(string $model): string
×
73
    {
74
        return app_path(str_replace('\\', '/', substr($model, strlen(app()->getNamespace()))) . '.php');
×
75
    }
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc