这是我尝试做的事情:
$q = Question::where('id',$id -> id)->get();
$q[] = $q->push([ 'test' => true]);
dd($q);
Run Code Online (Sandbox Code Playgroud)
这将输出:
Collection {#220 ?
#items: array:3 [?
0 => Question {#225 ?}
1 => array:1 [?
"test" => true
]
2 => null
]
}
Run Code Online (Sandbox Code Playgroud)
所以'test' => true将作为一个新密钥附加,但我想插入它,Question所以后者我可以像foreach一样访问它$q -> test
所以这是我想要访问项目的方式:
@foreach($q as $qq)
{{ $qq->test }}
@endforeach
Run Code Online (Sandbox Code Playgroud) 任何人都有使用角度cli项目安装角度通用的经验?
我试着按照这个指南:
https://universal.angular.io/quickstart/
但在我这样做之后:
typings install node express body-parser serve-static express-serve-static-core mime --global
Run Code Online (Sandbox Code Playgroud)
我收到错误:
typings INFO globaldependencies "express" lists global dependencies on "node" that must be installed manually
typings ERR! message Unable to find "node" ("npm") in the registry.
typings ERR! message However, we found "node" for 2 other sources: "dt" and "env"
typings ERR! message You can install these using the "source" option.
typings ERR! message We could use your help adding these typings to the registry: https://github.com/typings/registry
typings …Run Code Online (Sandbox Code Playgroud) 检查用户是否以编辑器身份登录后,我需要重定向到个人资料页面...
这是我的代码:
<?php namespace App\Http\Middleware;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Closure;
class AdminMiddleware {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if(Auth::check()){
if(Auth::user()->roles->toArray()[0]['role'] == 'editor'){
return redirect('/profile');
}
return $next($request);
}
else
{
return $next($request);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这段代码的问题是当用户是编辑器时我得到无限循环....
这是我的溃败:
Route::group(['middleware' => 'auth'], function(){
Route::get('home', ['middleware' => 'admin', function()
{
return view('home');
}]);
Route::get('profile', array(
'as' => 'profile',
'uses' => 'UserController@getProfile'
)); …Run Code Online (Sandbox Code Playgroud) 我按照本教程:https://www.youtube.com/watch?v = kmJYVhG6UzM目前我可以检查我的刀片,如果用户是管理员或不是这样的:
{{ Auth::user()->roles->toArray()[0]['role'] }}
HI ADMIN
@endif
Run Code Online (Sandbox Code Playgroud)
如何才能让我的路由仅供管理员用户使用?
我有project_group这个字段的数据透视表:id, group_id, project_id, admin_id, user_id
这用于将组和项目连接在一起:
$group -> projects() -> attach($projects,array('admin_id' => Auth::user()->id));
Run Code Online (Sandbox Code Playgroud)
是否可以为该数据透视表中的每个记录添加diffirent user_id.
例如:
第一记录:
id= 1, group_id= 1 project_id= 2 admin_id= 1 user_id= 1
第二条记录:
id= 2, group_id= 1 project_id= 3 admin_id= 1 user_id= 1
第3记录:
id= 3, group_id= 1 project_id= 2 admin_id= 1 user_id= 2
第4记录:
id= 3, group_id= 1 project_id= 3 admin_id= 1 …
我的ajax脚本发送这样的数组:这个数组属于 Input::get('questions')
Array
(
[0] => Array
(
[name] => fields[]
[value] => test1
)
[1] => Array
(
[name] => fields[]
[value] => test2
)
)
Run Code Online (Sandbox Code Playgroud)
在html部分用户可以添加多个fields.
你可以帮助我,我需要这样的东西:
$inputs = array(
'fields' => Input::get('questions')
);
$rules = array(
'fields' => 'required'
);
$validator = Validator::make($inputs,$rules);
if($validator -> fails()){
print_r($validator -> messages() ->all());
}else{
return 'success';
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试按照角度的样式指南,写道我们应该使用thisinsted scope...
当我能够使用时,有人能解释我this吗?
这是我的尝试.....我做错了什么?
我正在尝试切换表格....这是我的HTML代码:
<a href="#" ng-click="formEdit(x)" ng-if="!x.formEditShow">REPLY</a>
<a href="#" ng-click="formEdit(x)" ng-if="x.formEditShow" >CLOSE</a>
Run Code Online (Sandbox Code Playgroud)
使用经典$scope我会在我的控制器中这样做:
$scope.formEdit = function(data){
data.formEditShow = !data.formEditShow;
}
Run Code Online (Sandbox Code Playgroud)
但this它应该看起来像这样(但不起作用):
var vm = this;
vm.formEdit = formEdit;
function formEdit(data){
data.formEditShow = !data.formEditShow;
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮我理解这个吗?
javascript angularjs angularjs-scope angularjs-controller angularjs-controlleras
当我使用没有 vhosts 的默认配置时,一切正常。但是当我添加虚拟主机时它不起作用..
以下是 vhost 的样子:
<VirtualHost *:80>
ServerName example
ServerAlias example.com $
ServerAdmin example@example.com
DocumentRoot "/home/example/public_html"
ErrorLog "/home/example/logs"
CustomLog "/home/example/logs1.log" combined
ScriptAlias /cgi-bin/ /home/example/cgi-bin/
Alias /phpmyadmin /home/phpmyadmin
<Directory "/home/example/public_html">
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.php index.html index.htm default.htm
</Directory>
<Directory "/home/phpmyadmin">
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.php index.html index.htm default.htm
Options -Indexes
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我也有这个httpd.conf:
<IfModule mod_fastcgi.c>
FastCGIExternalServer /usr/sbin/php-fpm -host 127.0.0.1:9000
AddHandler php-fastcgi .php
<LocationMatch "/status">
SetHandler php-fastcgi-virt
Action php-fastcgi-virt /usr/sbin/php-fpm.fcgi …Run Code Online (Sandbox Code Playgroud) 我正在使用MyISAM for MySQL,我想在这里使用事务是我的代码:
DB::transaction(function () {
$project = Project::find($id);
$project->users()->detach();
$project->delete();
});
Run Code Online (Sandbox Code Playgroud)
这段代码成功执行,但我不确定交易是否有效...我该如何测试呢?
我怎样才能只观看 Angular ReactiveForm 的 2 个字段?我有一个如下所示的表格:
this.filter = this.fb.group({
text: ['', []],
bankCountry: ['', []],
bankCity: ['', []]
});
Run Code Online (Sandbox Code Playgroud)
我如何监视与最后 2 个字段相关的更改?
laravel-5 ×6
php ×6
angular ×2
eloquent ×2
angularjs ×1
apache2.2 ×1
arrays ×1
collections ×1
fastcgi ×1
javascript ×1
mysql ×1
redirect ×1
routes ×1
rxjs ×1
transactions ×1
validation ×1