我有一个名为Run的模型,其中包含以下方法:
public function getNameAttribute($name){
if($name == 'Eendaags')
return $this->race_edition->race->name;
return $this->race_edition->race->name.' '.$name;
}
Run Code Online (Sandbox Code Playgroud)
我需要laravel管理员的这个设置,因为很多运行将具有相同的名称,唯一的区别是比赛名称.但在网站的一个地方,我只需要获得名称,而不会发生变异.这可能吗?
我是新来angular2和之后的英雄从文档教程.我在使用angular2时遇到了相当慢的开发经验.angular2检测文件中的更改大约需要5秒,然后接下来需要30-40秒才能重新加载页面.
[0] 8:08:12 PM - File change detected. Starting incremental compilation...
[0] app/hero-detail.component.ts(2,8): error TS1192: Module '"app/app.component"' has no default export.
[0] 8:08:16 PM - Compilation complete. Watching for file changes.
[1][BS] File changed: app\app.component.js
[1] [BS] File changed: app\hero-detail.component.js
[1] [BS] File changed: app\main.js
[1] 16.02.07 20:08:39 304 GET /./index.html (Unknown - 8551ms)
[1] 16.02.07 20:08:45 304 GET /./index.html (Unknown - 1145ms)
[1] 16.02.07 20:08:45 304 GET /node_modules/es6-shim/es6-shim.min.js (Unknown - 384ms)
[1] 16.02.07 20:08:45 304 GET /node_modules/systemjs/dist/system-polyfills.js …Run Code Online (Sandbox Code Playgroud) 我很难理解WhereHas中的关系计数条件.文档页面没有讨论它,但API页面谈论它.来自API的报价.
Builder | Builder whereHas(string $ relation,Closure $ callback,string $ operator ='> =',int $ count = 1)
使用where子句向查询添加关系计数条件.
例
一个Resource模型具有多对多关系ResourceCategory
public function categories()
{
return $this->belongsToMany('ResourceCategory', 'resource_category_mapping');
}
Run Code Online (Sandbox Code Playgroud)
Has中的关系条件
Has中的关系条件正如预期的那样工作.
Resource::has('categories', '>', 1)->get()
//this return all resources which have more than one catgories
Run Code Online (Sandbox Code Playgroud)
WhereHas中的关系条件
WhereHas中的关系条件未按预期工作.我确信我误解了它.
Resource::whereHas('categories', function ( $query){
$query->whereIn('resource_category_id', [1, 2, 4]);
}, '>', 1)->get()
Run Code Online (Sandbox Code Playgroud)
上面的代码应该返回其类别属于[1,2,4]的资源,并且资源具有多个类别.但事实并非如此.
题
请在WhereHas中解释关系条件,可能提供一个例子会有很大帮助.
有一个着名的问题是噩梦和电子没有在无头的linux服务器上运行.官方电子文档建议使用xvfb来伪造显示器.他们建议将这个.yml文件用于travis.
addons:
apt:
packages:
- xvfb
install:
- export DISPLAY=':99.0'
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
题
如何将上面的代码app.yaml用于node.js的google appengine文件.我试图按原样使用它,但是glcoud会抛出一个addon无效命令的错误.差距官方文档没有任何类似的命令.
任何建议我们如何在node.js的谷歌appengine上运行噩梦和电子..?
我在Laravel写了一个简单的自定义指令.每当我对自定义指令的代码进行一些更改时,它就不会反映在视图中直到我
global.php中的自定义指令代码
Blade::extend(function($value, $compiler)
{
$pattern = $compiler->createMatcher('molvi');
return preg_replace($pattern, '$1<?php echo ucwords($2); ?>', $value);
});
Run Code Online (Sandbox Code Playgroud)
指令电话在视野中
@molvi('haji') //this will output 'Haji' due to ucwords($2)
//the ucwords() is replaced with strtolower()
@molvi('haji') //this will still output 'Haji'
Run Code Online (Sandbox Code Playgroud)
我将这些单词转换为大写.当我们想要使用strtolower()而不是代替时ucwords(),我必须重复上述步骤来反映变化.
UPDATE
我试图用这个线程中描述的各种方法清除缓存,但仍然没有成功.
UPDATE
由于没有人在StackOverFlow上回答这个问题,我已将它发布在laravel github上.
我使用angular2-seed作为我项目的种子.它require在源文件中工作得非常好.但每当我包含一个新库并在index.html中引用它时,就会在控制台中弹出一个require未定义的错误.
Systemjs包括在内
我已经在SO上阅读了以前的答案,建议使用system.js.systemjs已经包含在内.
的index.html
<!-- shims:js -->
<script src="/node_modules/systemjs/dist/system.src.js?1458283463580"></script>
<script src="/node_modules/systemjs/dist/system-polyfills.src.js?1458283463581"></script>
<script src="/node_modules/reflect-metadata/Reflect.js?1458283463582"></script>
<script src="/node_modules/es6-shim/es6-shim.js?1458283463582"></script>
<script src="/node_modules/angular2/bundles/angular2-polyfills.js?1458283463582"></script>
<!-- endinject -->
<script>System.config({"defaultJSExtensions":true,"paths":{"./admin/main":"/./admin/main","angular2/*":"/angular2/*","rxjs/*":"/rxjs/*","*":"/node_modules/*"},"packages":{"angular2":{"defaultExtension":false},"rxjs":{"defaultExtension":false}},"map":{"moment":"moment/moment.js"}})</script>
<!-- libs:js -->
<script src="/node_modules/rxjs/bundles/Rx.js?1458283463585"></script>
<script src="/node_modules/angular2/bundles/angular2.js?1458283463585"></script>
<script src="/node_modules/angular2/bundles/router.js?1458283463585"></script>
<script src="/node_modules/angular2/bundles/http.js?1458283463586"></script>
<script src="/node_modules/ng2-bootstrap/ng2-bootstrap.js?1458283463586"></script>
<script src="/node_modules/ng2-select/ng2-select.js?1458283463586"></script>
<script src="/node_modules/lodash/index.js?1458283463587"></script>
<script src="/node_modules/ng2-pagination/index.js?1458283463587"></script>
<!-- endinject -->
<!-- inject:js -->
<!-- endinject -->
<script>
System.import('./admin/main')
.catch(function (e) {
console.error(e,
'Report this error at https://github.com/punchagency/staffing-client/issues');
});
</script>Run Code Online (Sandbox Code Playgroud)
错误
使用需求的来源
lodash的index.js
module.exports = require('./lodash');
Run Code Online (Sandbox Code Playgroud)
类似地,其他库ng2-select也ng2-bootstrap …
因此,要部署angular2应用程序,我们只需将所有生产文件上传到存储桶,如此处所述.(部署静态网站).
但是我们如何重定向所有网址,index.html以便angular2路由器可以处理它们.我们可以Main Page从website configuration桶中设置.但我们无法指定所有网址都应重定向到index.html.
目前除了Main Page导致404页面未找到任何网址之外的任何网址.
关于亚马逊S3的SO有类似的问题,但是找不到谷歌云.
angular ×3
javascript ×3
laravel ×3
php ×3
laravel-4 ×2
node.js ×2
blade ×1
electron ×1
eloquent ×1
nightmare ×1
templating ×1
typescript ×1
yaml ×1