我想知道是否有任何方法可以在filamentPHP管理面板中显示私人上传的文件。只有经过身份验证的用户才能看到它,因为它不在 Laravel 的公共存储文件夹中。他们的文档似乎不包含它。
我目前正在使用filamentPHP 开发Laravel 项目。但是,我找不到删除特定资源的创建功能的方法。考虑到视图页面中有一个名为“客户”的资源,我想删除位于列表顶部的“新客户”按钮。有什么办法可以做到这一点吗?
如何在具有hasMany关系的filament where表中仅获取一个值?
我有两个数据库表:
products
| ID | 存货单元 |
|---|---|
| 1 | SKU_1 |
| 2 | SKU_2 |
product_descriptions
| ID | 产品编号 | 翻译_id | 姓名 |
|---|---|---|---|
| 1 | 1 | 1 | 欧宝 |
| 2 | 1 | 2 | 沃克斯豪尔 |
在我的产品模型中我有hasMany关系
public function productDescriptions(): HasMany
{
return $this->hasMany(ProductDescription::class);
}
Run Code Online (Sandbox Code Playgroud)
当我这样做时Tables\Columns\TextColumn::make('productDescriptions.name'),它返回所有用逗号分隔的值。在我的例子中“欧宝,沃克斯豪尔”
有没有办法使用回调来操纵/改变返回值?假设只返回第一个值“Opel”?
目前,我正在参与一个使用 Laravel 的 Filemant 的项目,我注意到在页面之间导航或提交表单时速度明显缓慢。延迟范围为 10 到 18 秒。我的开发环境是:Wampserver Windows 10、Intel Core i7 第 7 代 CPU、16 GB RAM 和 SSD 驱动器。 屏幕截图显示了我遇到的问题
在查看 Laravel Filament 教程时,我没有观察到他们遇到这个问题。我不明白这个问题,也没有找到解决办法。请帮忙。
我正在尝试访问field_1中继器内的值
return $form->schema([
Select::make('field_1')->reactive()->options(['a','b','c']),
Repeater::make('repeater_1')->schema([
TextInput::make('field_2')->default(fn (Closure $get) => $get('field_1')),
]),
]);
Run Code Online (Sandbox Code Playgroud) 我正在使用 Filament 创建一个表。我的 Livewire 类中有以下两个函数。getTableRecordUrlUsing() 函数按预期工作。
getTableActions() 函数会生成一个错误页面,显示“缺少 [Route:recipe.show][URI:recipe/{id}][Missingparameter:id] 所需的参数。”
protected function getTableActions()
{
return [
Action::make('edit')
->url(fn (Recipe $r): string => route('recipe.show', ['id' => $r])),
];
}
protected function getTableRecordUrlUsing()
{
return function (Recipe $r) {
return route('recipe.show', ['id' => $r]);
};
}
Run Code Online (Sandbox Code Playgroud)
一种功能有效。另一个则不然。我没主意了。
根据灯丝文档,在 app/Filament/Pages/Dashboard.php 创建了一个新文件,并从灯丝.php 中删除了原始的 Dashboard 类
Dashboard.php 文件代码:( https://i.stack.imgur.com/39INc.png )
filament.php 文件代码:
'pages' => [
'namespace' => 'App\\Filament\\Pages',
'path' => app_path('Filament/Pages'),
'register' => [],
],
Run Code Online (Sandbox Code Playgroud)
执行这些步骤后,我在侧边栏中多次获取仪表板选项时遇到这些问题。
我为 PostResource 制作了 CommentsRelationManager。
无论添加或删除评论,我如何刷新/重新计算标题上的计数值。
图片注释:我添加了新评论,但计数值没有刷新。
这是我的帖子资源表格:
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('title')->required(),
TextInput::make('body')->required(),
TextInput::make('count')
->reactive()
->label('count')
->disabled()
->placeholder(fn ($record) => $record->comments()->count())
]);
}
Run Code Online (Sandbox Code Playgroud)
这是我的 RelationManager
class CommentsRelationManager extends RelationManager
{ ...
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('comment'),
])
->filters([
//
])
->headerActions([
Tables\Actions\CreateAction::make(),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
}
}
Run Code Online (Sandbox Code Playgroud)
最后的建议是:
Emit a Livewire event from the relation manager after() the Edit or Create action,
and …Run Code Online (Sandbox Code Playgroud) 我目前正在 FilamnentPHP v3 中开发一个项目,我试图找出如何自动将当前 user_id 传递到我的数据库实体。
我想创建一个隐藏的输入字段并将该字段的默认值设置为当前的 user_id。但 Filament 似乎忽略了 hide() TextInput 并插入 null 或根本不执行任何操作。
我的错误解决方案
TextInput::make('user_id')
->label(__('messages.created_by'))
->required()
->default(
Filament::auth()->id()
)->readOnly()
->hidden()
Run Code Online (Sandbox Code Playgroud)
那么,在 Filament v3 中,有什么方法可以在表单提交后自动将值传递到数据库吗?
我还尝试查看 Filament 文档,但我没有真正幸运地找到可以帮助我解决问题的东西。
我在显示使用 spatie 媒体库和灯丝管理面板上传的图像时遇到问题。
这是表单架构的代码:
SpatieMediaLibraryFileUpload::make('thumbnail')->collection('posts')
Run Code Online (Sandbox Code Playgroud)
这是表列的代码
SpatieMediaLibraryImageColumn::make('thumbnail')->collection('posts')
Run Code Online (Sandbox Code Playgroud)
谢谢。
模型 Employee 与模型 Detail 相关,其中包含每个员工的地址和电话号码。员工资源中有一个表单,其中包含员工和详细信息表的字段。如何从该表单将数据保存到详细模型?
在员工资源的表单函数中,我尝试使用点表示法,但数据未保存。
Card::make()
->schema([
TextInput::make('detail.email')
->email(),
TextInput::make('detail.mobile'),
])->columns(2)
Run Code Online (Sandbox Code Playgroud) laravel-filament ×11
laravel ×10
php ×7
admin ×1
laravel-8 ×1
laravel-9 ×1
panel ×1
placeholder ×1