Skip to content

Commit

Permalink
adding a new trait for user attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
atmonshi committed Mar 2, 2024
1 parent ee9a976 commit 1af4f2d
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 6 deletions.
8 changes: 8 additions & 0 deletions docs/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ To set up the plugin with filament, you need to add it to your panel provider; T
])
```

## Add Bolt Trait to User Model

add this to your user model:

`use \LaraZeus\Bolt\Models\Concerns\BelongToBolt;`

This will allow you to get the user name by another attribute like `full_name`

## Usage

To access the forms, visit the URL `/admin` , and `/bolt`.
8 changes: 8 additions & 0 deletions docs/getting-started/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ title: Upgrading
weight: 90
---

## upgrade to v3.0.25

in v3.0.25, I added a new trait for getting the user name

so you have to add this to your user model:

`use \LaraZeus\Bolt\Models\Concerns\BelongToBolt;`

## upgrade to v2.1

In v2.1, I refactored the configuration to separate the frontend configuration from filament-related ones.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
class="rounded-full"
size="lg"
:src="$getRecord->user->avatar"
:alt="($getRecord->user->{config('auth.providers.users.model')::getUserFullNameAttribute()}) ?? ''"
:alt="($getRecord->user->{config('auth.providers.users.model')::getBoltUserFullNameAttribute()}) ?? ''"
/>
<p class="flex flex-col gap-1">
<span>{{ ($getRecord->user->{config('auth.providers.users.model')::getUserFullNameAttribute()}) ?? '' }}</span>
<span>{{ ($getRecord->user->{config('auth.providers.users.model')::getBoltUserFullNameAttribute()}) ?? '' }}</span>
<span>{{ ($getRecord->user->email) ?? '' }}</span>
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
class="rounded-full"
size="lg"
:src="$response->user->avatar"
:alt="($response->user->{config('auth.providers.users.model')::getUserFullNameAttribute()}) ?? ''"
:alt="($response->user->{config('auth.providers.users.model')::getBoltUserFullNameAttribute()}) ?? ''"
/>
<p class="flex flex-col gap-1">
<span>{{ ($response->user->{config('auth.providers.users.model')::getUserFullNameAttribute()}) ?? '' }}</span>
<span>{{ ($response->user->{config('auth.providers.users.model')::getBoltUserFullNameAttribute()}) ?? '' }}</span>
<span>{{ ($response->user->email) ?? '' }}</span>
</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Filament/Exports/ResponseExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ResponseExporter extends Exporter
public static function getColumns(): array
{
$record = \Livewire\Livewire::current()->getRecord();
$getUserModel = config('auth.providers.users.model')::getUserFullNameAttribute();
$getUserModel = config('auth.providers.users.model')::getBoltUserFullNameAttribute();
$mainColumns = [
ExportColumn::make('user.' . $getUserModel)
->label(__('Name'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ManageResponses extends ManageRelatedRecords

public function table(Table $table): Table
{
$getUserModel = config('auth.providers.users.model')::getUserFullNameAttribute();
$getUserModel = config('auth.providers.users.model')::getBoltUserFullNameAttribute();

$mainColumns = [
ImageColumn::make('user.avatar')
Expand Down
11 changes: 11 additions & 0 deletions src/Models/Concerns/BelongToBolt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace LaraZeus\Bolt\Models\Concerns;

trait BelongToBolt
{
public static function getBoltUserFullNameAttribute(): string
{
return 'name';
}
}

0 comments on commit 1af4f2d

Please sign in to comment.