diff --git a/resources/views/tables/columns/created_by.blade.php b/resources/views/tables/columns/created_by.blade.php new file mode 100644 index 00000000..e912b757 --- /dev/null +++ b/resources/views/tables/columns/created_by.blade.php @@ -0,0 +1,9 @@ +
+
+
+ + {{ $getRecord()->User?->name }} + +
+
+
diff --git a/src/Filament/Resources/FormEntryResource.php b/src/Filament/Resources/FormEntryResource.php index acbb6c77..82ee8c78 100644 --- a/src/Filament/Resources/FormEntryResource.php +++ b/src/Filament/Resources/FormEntryResource.php @@ -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') diff --git a/src/Models/FormEntry.php b/src/Models/FormEntry.php index 1bffd0c9..0cd873da 100644 --- a/src/Models/FormEntry.php +++ b/src/Models/FormEntry.php @@ -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 () {