Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show who made the entry when it's for logged in users only #197

Merged
merged 1 commit into from
Nov 15, 2024
Merged
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
9 changes: 9 additions & 0 deletions resources/views/tables/columns/created_by.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="fi-ta-text grid w-full gap-y-1 px-3 py-4">
<div class="flex">
<div class="fi-ta-text-item inline-flex items-center gap-1.5 ">
<span class="fi-ta-text-item-label text-sm leading-6 text-gray-950">
{{ $getRecord()->User?->name }}
</span>
</div>
</div>
</div>
6 changes: 6 additions & 0 deletions src/Filament/Resources/FormEntryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ public static function getColumns(ModelsForm $form): array
->words(10);
}

if ($form->only_for_logged_in) {
// show user who created it
$columns[] = Tables\Columns\ViewColumn::make('')
->label('Submitted By')
->view('fila-cms::tables.columns.created_by');
}

$columns[] = Tables\Columns\ViewColumn::make('created_at')
->label('Submitted Time')
Expand Down
5 changes: 5 additions & 0 deletions src/Models/FormEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public function form()
return $this->belongsTo(Form::class);
}

public function user()
{
return $this->belongsTo(config('auth.providers.users.model'));
}

public function displayHtml(): Attribute
{
return new Attribute(function () {
Expand Down
Loading