在Laravel中基于外键搜索(Search based on foreign key in Laravel)
Laravel 5. *
我的
Case
模型与Customer
模型有一对一的关系,定义如下:public function customer { return $this->hasOne(Customer::class, 'id', 'customer'); }
在案例列表(cases.index)中,它根据关系
$case->customer->name
显示$case->customer->name
。我正在尝试创建搜索并根据客户名列出所有案例。
是否存在基于关系的本地搜索方式?
Laravel 5.*
I have the
Case
Model that has one to one relationship withCustomer
Model as defined below:public function customer { return $this->hasOne(Customer::class, 'id', 'customer'); }
In the cases listing (cases.index), it displays the customer name based on relationship
$case->customer->name
.I am trying to create search and list all the cases based on customer name.
Is there a native way to search based on the relationship?
原文:https://stackoverflow.com/questions/48928160
最满意答案
我已经拆分了jQuery Val包
//bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( // "~/Scripts/jquery.unobtrusive*", // "~/Scripts/jquery.validate*")); bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( "~/Scripts/jquery.validate*")); bundles.Add(new ScriptBundle("~/bundles/unobtrusive").Include( "~/Scripts/jquery.unobtrusive*"));
在我的布局中我只给了
@Scripts.Render("~/bundles/unobtrusive")
在我的所有表单视图中,我给了
@Scripts.Render("~/bundles/jqueryval")
这解决了这个问题。 希望这可以帮助别人
I have split jQuery Val bundle
//bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( // "~/Scripts/jquery.unobtrusive*", // "~/Scripts/jquery.validate*")); bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( "~/Scripts/jquery.validate*")); bundles.Add(new ScriptBundle("~/bundles/unobtrusive").Include( "~/Scripts/jquery.unobtrusive*"));
in my layout i gave only
@Scripts.Render("~/bundles/unobtrusive")
in all my form views i gave
@Scripts.Render("~/bundles/jqueryval")
that solved the problem. Hope this can help others
相关问答
更多-
通过将网格的autoBind属性设置为false来禁用网格数据源的自动加载,然后在单击按钮时调用数据源上的read() 。 Disable auto-loading from the grid's data source by setting the grid's autoBind property to false and then call read() on the data source when the button is clicked.
-
将验证消息添加为输入文本的属性“data-lowerThanHighest-msg”的值。 您可以这样做: input.attr("data-lowerThanHighest-msg", "Lowest must be lower than Highest"); 查看此处修订的演示版 Add the validation message as the value of the attribute "data-lowerThanHighest-msg" of the input text. You can d ...
-
实际上,事实证明这很容易。 通过自定义编辑器模板,您可以添加所需的属性。 因此,在列中为编辑器属性添加一个函数名称 columns: [ { field: "ID", title: "ID", editor: requiredField }, { field: "name", title: "Name", editor: requiredField }, { field: "capital", title: "Capital City" }, ...
-
我已经拆分了jQuery Val包 //bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( // "~/Scripts/jquery.unobtrusive*", // "~/Scripts/jquery.validate*")); bundles.Add(new ScriptBundle("~/bundles/jquery ...
-
Kendo网格客户端自定义输入验证'通过,但失败'(Kendo grid client-side custom input validation 'passes, yet fails')[2022-12-19]
所以对于Telerik Demos,我注意到我在函数结束时错过了“return true”语句; 它看起来应该是这样的 uniquenamevalidation: function (input, params) { var errorCount = 0; //check for the rule attribute if (input.filter("[data-val-uniquena ... -
转换日期kendo ui网格(convert date kendo ui grid)[2021-07-10]
kendo ui允许设置文化和日期格式添加 请查看http://docs.kendoui.com/api/framework/kendo#culture http://docs.kendoui.com/getting-started/framework/globalization/dateformatting 读我发现了这个: http://www.kendoui.com/forums/framework/globalization/kendo-fails-to-parse-or-format-utc-da ... -
问题在于kendo模板(带有“#something#”)在kendo代码中“编译”,并且没有提及您的Vue应用程序。 但在jquery-kendo文档中,我发现可以将函数传递给模板。 正如我在kendo源代码模板函数中所看到的,总是应该返回非null / undefined值。 所以我在下面添加了更改,它的功能就像一个魅力: Vue模板的变化(将模板绑定到函数)这是一个有效的例子: http://dojo.telerik.com/IVuko 我做了以下更改: 将Grid绑定到personDataArray ObservableObject,而不仅仅是ObservableObject的一个字段 将schema.data设置为指向personDataArray的data字段。 在将新数据设置为personDataArray时调用dataSource.read() 我认为不应该需要最后一步,但不确定。 Here is an example that works: htt ...要在Kendo UI Grid中启用键盘导航,您必须在初始化中通过可navigatable选项启用此功能( http://demos.telerik.com/kendo-ui/grid/keyboard-navigation ) $("#grid").kendoGrid({ ... selectable: "row", navigatable: true, ... }); 如果要按行选择导航行(不进行聚焦和确认),则应处理手动keydown事件。 在这种情况下,您可以找到焦 ...您可以在模板中插入带标题的范围: {{column.field}}({{columnIndex}}) http://plnkr.co/edit/eYtBLMv45XFLcnbXn2ZW?p=preview You can insert a span with a t ...
相关文章
更多- LARAVEL学习--安装
- mysql删除外键(Cannot drop index 'FK7D676EBBD0A6D8FD': needed in a foreign key constraint)
- Memcached get 获取key对应的值
- Memcached delete 删除key
- jqgrid 中组合框的值和key
- 别拿Hadoop map key当id使
- Java-based 实现的索引复制
- Memcached replace 替换已存在的 key命令
- javascript中json如何取key中带“.”值
- Memcached flush_all 命令清理缓存中的所有 key
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)