I am confused with eloquent relationships. I have two tables:
USERS:
id, name, pwd, etc...
FRIENDS:
id, user_id, friend_id
Run Code Online (Sandbox Code Playgroud)
For the FRIENDS table, I have two foreign keys:
$t->foreign('user_id')
->references('id')
->on('users');
$t->foreign('friend_id')
->references('id')
->on('users');
Run Code Online (Sandbox Code Playgroud)
In each class I have the following relationships:
USER class:
/**
* A user can have many friends
*/
public function friends()
{
return $this->hasMany(User::class, 'friend_id', 'id');
}
Run Code Online (Sandbox Code Playgroud)
FRIEND class:
/**
* A friend can belong to a user
*/
public function friend()
{
return $this->belongsTo(User::class, …
Run Code Online (Sandbox Code Playgroud) 编辑:似乎我的一些原始数据不包含三个堆叠条中的每一个的值。这是有效的并且基于用户选择。例如:餐厅可能只有早餐菜单,但没有三明治或便餐(见下文)。
谷歌图表在这一行失败,对于(有效的)丢失的用户选择,没有零的物理条目。
是否有 Google Charts 设置将“缺失值”视为零值?
以下是 JSON 输入的示例:
[{"store_name":"Store 1","dish_menu":"Breakfast","dish_count":"13"},
{"store_name":"Store 1","dish_menu":"Light Meals","dish_count":"7"},
{"store_name":"Store 1","dish_menu":"Sandwiches","dish_count":"7"},
{"store_name":"Store 2","dish_menu":"Breakfast","dish_count":"13"},
{"store_name":"Store 2","dish_menu":"Light Meals","dish_count":"7"},
{"store_name":"Store 2","dish_menu":"Sandwiches","dish_count":"7"},
{"store_name":"Store 3","dish_menu":"Breakfast","dish_count":"13"}, <-- FAILS HERE
{"store_name":"Store 4","dish_menu":"Breakfast","dish_count":"13"},
{"store_name":"Store 4","dish_menu":"Light Meals","dish_count":"7"},
{"store_name":"Store 4","dish_menu":"Sandwiches","dish_count":"7"},]
Run Code Online (Sandbox Code Playgroud)
我在一个页面上有 3 个 Google 图表,2 个是饼图,1 个是堆叠条形图。
今天,由于我无法理解的原因,堆积条形图停止工作,消息检查显示“错误:第 14 行有 2 列,但必须有 4”,并指向 Google 代码的内部。这个页面已经制作了一个多月,工作得很好。
当我查看代码并将其与上次备份(运行正常,2 周前)进行比较时,代码完全相同。此外,SQL 查询输出工作正常。
任何关于在哪里看的建议都非常感谢。
代码:
function loadHQCharts() {
// CHART #1
google.load('visualization', '1', {'packages':['corechart'], callback: drawChartDishMix});
// CHART #2
google.load('visualization', '1', {'packages':['corechart'], callback: drawChartMenuMix});
// CHART #3
google.load('visualization', '1', {'packages':['corechart'], …
Run Code Online (Sandbox Code Playgroud) 我试图使用Carbon将分钟数转换为天数.
$minutes = 1400;
Run Code Online (Sandbox Code Playgroud)
我想做类似下面的事情(当然,这不起作用):
Carbon->minutes($minutes)->days();
Run Code Online (Sandbox Code Playgroud)
我找不到这样的例子.谢谢你的帮助.
当屏幕调整大小时,我无法让我的 highcharts 仪表的tootlip出现并保持可见并在仪表内居中。
在我的小提琴中,您可以看到工具提示出现,然后在一段时间后消失。此外,调整窗口大小时,它不会留在仪表的中心。
任何帮助表示赞赏。我的JSFIDDLE在这里。
gaugeChartObj = new Highcharts.Chart({
credits: false,
chart: {
renderTo: divID,
type: 'solidgauge',
marginTop: 30,
events: {
load: function(){
var p = this.series[0].points[0];
this.tooltip.refresh(p);
}
}
},
title: {
text: dataC.title,
style: {
fontSize: '16px'
}
},
exporting: {
enabled: false
},
tooltip: {
borderWidth: 0,
backgroundColor: 'none',
useHTML: true,
shadow: false,
style: {
fontSize: '16px'
},
formatter: function() {
return '<div style="width:100%;text-align:center;"><span style="font-size:1.2em;font-weight:bold;">' + this.point.series.name + '</span><br/><span style="font-size:3em;color:' + Highcharts.getOptions().colors[0] + ';font-weight:bold;">' + …
Run Code Online (Sandbox Code Playgroud) 我真的第一次在网络(EC2)上加载 Laravel 应用程序。
我有一个运行最新 Laravel 5.6 的 Ubuntu 18.04 实例。我已经被困了几个小时试图解决 403 问题。我遵循了:
这些步骤(创建新组,向其中添加 ubuntu 和 www-data,设置组和所有者为读取、写入和执行)
这些步骤设置文件夹权限
...许多其他尝试/服务器重建...
所以刚才我把root中的所有文件和文件夹都设置为777来测试
$ find /home/ubuntu/projectname -type f -exec chmod 777 {} \;
$ find /home/ubuntu/projectname -type d -exec chmod 777 {} \;
Run Code Online (Sandbox Code Playgroud)
根据下面的建议,我也这样做了:
$ namei -l /home/ubuntu/projectname/public
f: /home/ubuntu/projectname/public
drwxr-xr-x root root /
drwxr-xr-x root root home
drwxr-xr-x ubuntu ubuntu ubuntu
drwxrwxrwx www-data www-data projectname
drwxrwxrwx www-data www-data public
$ sudo chmod -R 777 /home/ubuntu/projectname
$ ls -l
drwxrwxrwx 8 www-data …
Run Code Online (Sandbox Code Playgroud) 我有一个表,其中的json列转换为数组。
在我的课上:
protected $casts = [
'row_ids' => 'array',
];
Run Code Online (Sandbox Code Playgroud)
我通过另一个类中的关系访问此列:
public function table_rows()
{
return $this->hasMany(TableChannelRow::class, 'channel_api_id', 'api_id');
}
Run Code Online (Sandbox Code Playgroud)
当dd
建立关系时,我可以看到目标表中的列正常,其中一列包含预期的数组:
dd($channel->table_rows);
#attributes: array:4 [?
"api_id" => 2
"table_api_id" => 1
"channel_api_id" => 6
"row_ids" => "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, …
Run Code Online (Sandbox Code Playgroud) 我正在寻找Javascript的一些帮助.我有一段HTML如下:
<div class="KeepShopping FloatRight GreenButton">
<a href="http://www.xyz.com">Click here to keep shopping</a>
</div>
Run Code Online (Sandbox Code Playgroud)
我试图从DIV中删除类"GreenButton一旦其中的链接在HTML中没有文本,所以最终结果应如下所示:
<div class="KeepShopping FloatRight">
<a href="http://www.xyz.com"></a>
</div>
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下代码尝试获取此功能失败,该代码在页面加载/刷新结束时运行:
<script type="text/javascript">
$(".KeepShopping").each(function() {
if($("a", this).html == "") {
$(this).removeClass("GreenButtonLge");
}
});
</script>
Run Code Online (Sandbox Code Playgroud)
任何建议/想法都非常欢迎!提前感谢您的帮助!
我试图阻止由于点击事件传播到父元素而运行的第二段 JS,但我被卡住了。
我对表中的行有以下 HTML:
<tr id="DEMO01-P" role="row" class="odd">
<td><img id="DEMO1" src="../imagedir/edit.png" onclick="Edit(this.id);">Info here</td>
<td>And here</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
我在 tr 上有一个点击事件like
:
jQuery('#system-tbl tbody').on('click', 'tr', function () {
var self = jQuery(this);
if ( self.hasClass('selected') ) {
self.removeClass('selected');
} else {
table.$('tr.selected').removeClass('selected');
self.addClass('selected');
}
DO STUFF....
});
Run Code Online (Sandbox Code Playgroud)
如果用户img
使用以下命令单击 tr 内部,我还会执行其他操作onclick="Edit(this.id);"
:
function Edit(system_id) {
alert("Edit: " + system_id);
window.location.href = "/go-to-page/";
};
Run Code Online (Sandbox Code Playgroud)
如何停止tr
调用中的事件Edit(this.id);
?谢谢!!
我在一页上有一些图表,每个图表都有自己的边框框。首页加载的所有图表都超过其父图表的宽度。
如果我稍微调整页面宽度,一切都会恢复到应有的样子。奇怪的是,这只出现在最新的 Chrome 版本上。Safari 和 FF 运行良好。
另一个奇怪的问题是,如果我empty cache and hard reload
在 Chrome 中,它加载正常。刷新页面,图表就会显示在其容器的右侧。
我已经从研究中尝试过这个CSS:
.highcharts-container {
width:100% !important;
height:100% !important;
}
Run Code Online (Sandbox Code Playgroud)
但这也会搞乱 Chrome 和其他浏览器上的工具提示。
欢迎任何建议。
我正在尝试使用FontAwesome获得仅CSS单选和复选框按钮。我在这里有一个jsfiddle。
当复选框具有包含内容的标签时,我正在使用以下效果很好的CSS。我现在正尝试在页面上的表格中创建复选框矩阵,并且图标显示为OK,但无法单击/更改状态。
我的CSS:
/**
* Checkboxes
*/
input[type=checkbox] {
display: none;
}
/* to hide the checkbox itself */
input[type=checkbox] + label:before {
display: inline-block;
letter-spacing: 5px;
content: "\f0c8";
font-family: 'Font Awesome 5 Pro';
}
/* unchecked icon */
input[type=checkbox]:checked + label:before {
content: "\f14a";
letter-spacing: 5px;
}
/**
* Radio buttons
*/
input[type=radio] {
display: none;
}
/* to hide the radio itself */
input[type=radio] + label:before {
display: inline-block;
letter-spacing: 5px;
content: "\f111";
font-family: …
Run Code Online (Sandbox Code Playgroud) 我坚持这样做.我正在使用ASP.net内置的CMS,它使用\
文件夹路径生成图像源.我需要读取这个src并将其用作其他地方作为div的背景图像,这需要/
路径分隔符.
尝试了这些没有成功:
str.replace(new RegExp('\', 'g'), '/');
str.replace(/\/g), '/');
Run Code Online (Sandbox Code Playgroud)
谢谢
javascript ×5
html ×4
jquery ×4
php ×4
css ×3
highcharts ×2
laravel ×2
checkbox ×1
class ×1
date ×1
eloquent ×1
laravel-5.4 ×1
laravel-5.6 ×1
mysql ×1
nginx ×1
php-carbon ×1