问题标签 [laravel-nova]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
2109 浏览

laravel - Laravel nova overriding/setting custom value for the Fields or Has Through relationship

I am developing a Web application using Laravel. For the admin panel, I am using Laravel Nova. What I am trying to do now is that I need to use data from the table which has relationship through another table. To be, clear, see my database structure below.

What I am trying to achieve inside the Nova is that I want to display the parent category name of the item on the item index/list page. The first thing is that I do not want to create custom attribute something like this in the model

Therefore, there are two solutions I can think of. The first solution is using the HasThrough relationship. But I cannot find it in Nova. So, I cannot use it. The second solution is that overriding the field value on render. Something like this.

But the above code is not working. So, what would be the best approach to handle the has-through relationship in Nova?

0 投票
4 回答
5244 浏览

laravel-nova - Laravel Nova - 如何在索引上显示部分文本区域文本

有没有办法在资源的索引上显示 Laravel\Nova\Fields\Textarea 的前 25 个字符?

0 投票
1 回答
7742 浏览

javascript - 未捕获的类型错误:尝试在 Vuejs 中调用 onchange() 方法时无法读取未定义的属性“应用”

我正在使用Laravel Nova自定义工具来创建自己的模板。Nova 使用vuejs所以我试图在里面添加我的自定义表单和 js 逻辑Tool.vue

我运行这个非常简单的代码在选择上执行onChange()事件,但出现以下错误:

这是我的表格:

这是我的 js 逻辑,而不是 alert() 产生错误:

PS:它适用于简单的javascript simple onChange,但使用vuejs方法我总是得到这个奇怪的错误。

0 投票
1 回答
554 浏览

laravel - Laradock 上的 Nova 引发 bcadd 异常

我用 Laradock 简单地安装了 Laravel。
当我尝试更新模型时,没有问题。

但是,当我安装 Nova 并尝试更新某些模型(例如用户名)时,我收到以下错误:

在此处输入图像描述

查看 ajax 调用,我看到以下错误:

我尝试设置PHP_WORKER_INSTALL_BCMATH并重建 docker 映像true.env但没有帮助。

我也发现了这个问题:
https ://github.com/laravel/telescope/issues/25#issuecomment-432302285

但这并没有帮助我解决问题。

0 投票
2 回答
3982 浏览

php - Nova Relatable Filtering - 如何过滤 company_id 与位置 company_id 匹配的用户

我在用户和位置之间有多对多的关系。我想过滤我的“附加用户”选择列表以仅显示与我当前所在位置company_id匹配的用户。company_id我创建了一个名为的静态函数relatableUsers,它在查询中添加了“where”子句。

如何将当前位置拉到company_id这个 where 查询中?如果我在过滤器下面硬编码一个company_id类似的代码,那么我知道这是可能的。

记录信息不存储在$request或 中$query

编辑 - 添加关系

用户型号:

定位模型:

公司型号关系:

0 投票
1 回答
6455 浏览

php - 当关系方法名称和外键前缀不同时,Laravel Nova BelongsTo 不起作用

当关系方法名称和外键前缀不同时,属于关系在我的 Nova 应用程序中不起作用。

我有两个表,event & client_location 和 Models Event & ClientLocation

事件模型:

客户位置模型:

事件的 Nova 资源字段方法:

关于如何处理这个问题的任何想法?

0 投票
1 回答
1508 浏览

laravel - Laravel Nova field BelongsToMany drilling down the data

I am developing a Web Application using Laravel. I am using Laravel Nova for building the admin panel. But I am having an issue with BelongsToMany field.

I have the database schema as follow

So in the Station nova resource, I added a field like this.

Therefore, when I go to the Station details page from the Nova admin panel and select "Attach manager", in the dropdown of the next page (page to attach a manager to the department), I can see all the available managers in the database.

But instead of displaying all the available managers in the drop down, I like to filter the managers/users which belongs to the same area as the selected Station. I mean when I attached a manager to the Station, I have to select a station. Is it possible to filter or to achieve what I want in Nova?

0 投票
1 回答
729 浏览

php - Laravel 从 DB where in Collection 中选择 - Laravel Nova

我有一个数据库,“视图”,有很多很多条目。我还有一个“课程”表,这些视图与该表是一对多相关的。在 Laravel Nova 中,我可以使用如下代码获取课程的所有视图随时间变化的指标:

在这种情况下,viewable_id是课程$request->resourceId的 ID,并给出要排序的课程 ID。很简单。

然而,现在事情变得有些困难。我有另一个模型叫做Teachers. 每个都Teacher可以有很多课程,也是一对多的关系。我如何获得教师教授的所有课程的观看次数指标?

我假设最简单的方法是创建一个 Laravel 集合,其中包含教师教授的所有课程(效率不高),然后选择数据库中viewable_id与该列表中的一门课程匹配的所有视图。当然,通过发布这个,我无法弄清楚如何做到这一点。

当然,一旦弄清楚了这一点,我很乐意为它做同样的事情Categories(尽管它的功能应该与教师非常相似,所以我不需要问这个问题)。

0 投票
1 回答
1096 浏览

javascript - 在 Vue js 中动态使用多个页面(组件)

我正在使用用于自定义功能的Laravel Nova自定义工具。vue js

创建后组件内部有一个tool.vue文件,所有内容都在那里处理。问题是我想要不同的模板(vue 文件)并在需要时渲染它们。

在这种情况下,我的主要tool.vue内容是我完全实现的带有下拉列表的搜索。vue但是我想在单击按钮后从不同的文件中呈现结果列表。(当然,另一个 vue 文件将包含一个表格或其他东西来显示数据)。

问题是如何使用 vue js 处理这个问题,以及如何在组件之间进行更改?以及如何将参数/数据从主 vue 文件传递​​到结果页面,以便我可以执行 ajax 请求等。

0 投票
1 回答
860 浏览

laravel - 如何在 Laravel nova 中的索引上显示降价字段?

我有一个名为“Note”的新星模型,具有以下字段方法

在索引页面中,我只能看到表的 ID。关于如何在索引中显示 Markdown 字段的任何想法?