-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathProfileSingleShow.php
More file actions
70 lines (63 loc) · 2.45 KB
/
Copy pathProfileSingleShow.php
File metadata and controls
70 lines (63 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace App\Sharp\Profile;
use App\Sharp\Profile\Commands\Activate2faCommand;
use App\Sharp\Profile\Commands\ChangePasswordCommand;
use App\Sharp\Profile\Commands\Deactivate2faCommand;
use Code16\Sharp\Auth\Passkeys\Entity\PasskeyEntity;
use Code16\Sharp\Show\Fields\SharpShowEntityListField;
use Code16\Sharp\Show\Fields\SharpShowPictureField;
use Code16\Sharp\Show\Fields\SharpShowTextField;
use Code16\Sharp\Show\Layout\ShowLayout;
use Code16\Sharp\Show\Layout\ShowLayoutColumn;
use Code16\Sharp\Show\Layout\ShowLayoutSection;
use Code16\Sharp\Show\SharpSingleShow;
use Code16\Sharp\Utils\Fields\FieldsContainer;
use Code16\Sharp\Utils\Transformers\Attributes\Eloquent\SharpUploadModelThumbnailUrlTransformer;
class ProfileSingleShow extends SharpSingleShow
{
protected function buildShowFields(FieldsContainer $showFields): void
{
$showFields
->addField(
SharpShowTextField::make('email')
->setLabel('Email address'),
)
->addField(
SharpShowPictureField::make('avatar'),
)
->when(config('demo.enable_passkeys'), fn () => $showFields->addField(
SharpShowEntityListField::make(PasskeyEntity::class)
->setLabel('Passkeys')
));
}
protected function buildShowLayout(ShowLayout $showLayout): void
{
$showLayout
->addSection('', function (ShowLayoutSection $section) {
$section
->addColumn(6, fn (ShowLayoutColumn $column) => $column->withField('email'))
->addColumn(6, fn (ShowLayoutColumn $column) => $column->withField('avatar'));
})
->when(config('demo.enable_passkeys'))->addEntityListSection(PasskeyEntity::class);
}
public function buildShowConfig(): void
{
$this->configurePageTitleAttribute('name')
->configureBreadcrumbCustomLabelAttribute('name');
}
public function getInstanceCommands(): ?array
{
return [
ChangePasswordCommand::class,
...sharp()->config()->get('auth.2fa.handler') === 'totp'
? [Activate2faCommand::class, Deactivate2faCommand::class]
: [],
];
}
public function findSingle(): array
{
return $this
->setCustomTransformer('avatar', new SharpUploadModelThumbnailUrlTransformer(140))
->transform(auth()->user());
}
}