我使用下面的代码,在laravel刀片
<div ng-show="displayErrorMsg" class="form-group m-b alert alert-danger">{{errorMsg}}
Run Code Online (Sandbox Code Playgroud)
在angularjs控制器中
$scope.errorMsg = "Data Empty";
$scope.displayErrorMsg = true;
setTimeout(function() { $scope.displayErrorMsg = false;}, 2000);
Run Code Online (Sandbox Code Playgroud)
消息在2秒后自动消失,如给定的那样.
但是当我简单地说出警告("测试"); 或点击任何地方消息消失.如何解决这个问题?
问题:
目前,我们希望在apollo调用期间过期时刷新oauth令牌,并且我们无法在onError
正确的内部执行异步获取请求.
码:
initApolloClient.js
import { ApolloClient } from 'apollo-client';
import { onError } from 'apollo-link-error';
import { ApolloLink, fromPromise } from 'apollo-link';
//Define Http link
const httpLink = new createHttpLink({
uri: '/my-graphql-endpoint',
credentials: 'include'
});
//Add on error handler for apollo link
return new ApolloClient({
link: ApolloLink.from([
onError(({ graphQLErrors, networkError, operation, forward }) => {
if (graphQLErrors) {
//User access token has expired
if(graphQLErrors[0].message==="Unauthorized") {
//We assume we have both tokens needed to run the …
Run Code Online (Sandbox Code Playgroud) 我还没有找到如何在bootstrap表中插入和更新数据的确切答案.
数据来自JSON格式的URL.
我必须在同一个表中使用多个URL.
Docker 守护进程无法解析 json 日志并抛出unexpected EOF
错误。我们正在调查问题的根本原因。
环境:
Docker 守护进程日志:
Apr 29 14:31:05 Prod-IS dockerd[30810]: time="2020-04-29T14:31:05.070677515+02:00" level=warning msg="got error while decoding json" error="unexpected EOF" retries=345
Apr 29 14:31:05 Prod-IS dockerd[30810]: time="2020-04-29T14:31:05.070695689+02:00" level=warning msg="got error while decoding json" error="unexpected EOF" retries=346
Apr 29 14:31:05 Prod-IS dockerd[30810]: time="2020-04-29T14:31:05.070712630+02:00" level=warning msg="got error while decoding json" error="unexpected EOF" retries=347
Apr 29 14:31:05 Prod-IS dockerd[30810]: time="2020-04-29T14:31:05.070732299+02:00" level=warning msg="got error while decoding json" error="unexpected EOF" retries=348
Apr 29 14:31:05 Prod-IS dockerd[30810]: …
Run Code Online (Sandbox Code Playgroud) 我已经尝试过去几个小时来设置从S3到我的谷歌存储桶的转移.
创建传输时,我不断收到的错误是:"无效的访问密钥.确保S3存储桶的访问密钥正确,或将存储桶权限设置为"授予所有人".
鉴于它们当前正在生产中用于S3完全访问,因此访问密钥和秘密都是正确的.
有几点需要注意:
桶政策:
{
"Version": "2008-10-17",
"Id": "Policy234234234",
"Statement": [
{
"Sid": "Stmt234234",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"s3:AbortMultipartUpload",
"s3:GetObjectAcl",
"s3:RestoreObject",
"s3:GetObjectVersion",
"s3:DeleteObject",
"s3:DeleteObjectVersion",
"s3:PutObjectVersionAcl",
"s3:PutObjectAcl",
"s3:GetObject",
"s3:PutObject",
"s3:GetObjectVersionAcl"
],
"Resource": "arn:aws:s3:::mybucket/*"
},
{
"Sid": "2",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity xyzmatey"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::mybucket/*"
},
{
"Sid": "3",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation"
],
"Resource": "arn:aws:s3:::mybucket"
}
] …
Run Code Online (Sandbox Code Playgroud) 在那里,我潜入了队列的世界及其所有美好之处,这让我感到震惊:
由于 Laravel 对信息进行序列化,当应用程序将任务推送到队列时,会话数据会丢失。
了解了如何将数据发送到队列后,仍然存在一个问题:
鉴于队列将信息推送到单个类,
在此任务的整个持续时间内,我如何使该信息在其他类中持久化(例如会话)?
编码示例:
//Case where the user object is needed by each class
class queueme {
...
//function called by queue
function atask($job,$data)
{
//Does xyz
if(isset($data['user_id'])
{
//Push user_id to another class
anotherclass::anothertask($data['user_id']);
}
}
}
class anotherclass {
...
function anothertask($user_id)
{
//Does abc
//Yup, that anotherofanother class needs user_id, we send it again.
anotherofanotherclass::yetanothertask($user_id);
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码说明了我的问题。
如果我的课程需要此信息,我是否必须传递$user_id
或User
对象?
没有更干净的方法吗?
嘿家伙我正在尝试开发一个从数据库中返回趋势文章的查询.
热门文章基于过去24小时内的大多数观点.这是迄今为止的代码:
$trending = Article::whereHas('view', function ($query) {
$query->where('created_at', '>=', Carbon::now()->subHours(24));
})
->with('view')
->orderBy('created_at', 'DESC')
->get();
return $trending;
}
Run Code Online (Sandbox Code Playgroud)
文章模型具有以下关系:
public function view()
{
return $this->hasMany('ArticleView', 'article_id');
}
Run Code Online (Sandbox Code Playgroud)
该查询有效,但我还需要按视图计数对文章进行排序.例如,显示当前趋势文章,但具有最多视图计数的artticles不是从头到尾排序(显然 - 它们按created_at排序)
帮助赞赏