如何app/config/app.php从我的控制器访问调试变量以查看我是否处于调试模式?
<?php
|
/* | if ( $this->user->id )
|-------------------------------------------------------------------------- | {
| Application Debug Mode | // Save roles. Handles updating.
|-------------------------------------------------------------------------- | $this->user->saveRoles(Input::get( 'roles' ));
| |
| When your application is in debug mode, detailed error messages with | // Redirect to the new user page
| stack traces will be shown on every error that occurs within your | return Redirect::to('admin/users/'.$this->user->id)->with('success', Lang::get('admin/users/messages.cre
| application. If disabled, a simple generic error page is shown. |ate.success')); …Run Code Online (Sandbox Code Playgroud) 对于这条规则,我收到了一个错误 syntax error, unexpected '.', expecting ')'
public static $rules = array(
'first_name' => 'required|alpha-dash',
'last_name' => ' required|alpha-dash',
'media_release' => 'required|boolean',
'birthday' => 'before:' . date('Y-m-d')
);
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚为什么这不起作用.我正在运行Laravel 4.2.12
当我按下No按钮时,我希望它变成红色.我希望Yes按钮的行为与它已经完成的方式相同,即.什么是limegreen active.我该怎么做呢?
请看我的小提琴
HTML
<div class="col-sm-5 btn-group" data-toggle="buttons">
<label class="btn btn-info">
<input checked="checked" name="media_release" value="1" type="radio"> Yes
</label>
<label class="btn btn-info active">
<input name="media_release" value="0" type="radio"> No
</label>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.btn-info.active {
background-color: limegreen;
}
Run Code Online (Sandbox Code Playgroud) 我想从我的收藏中删除管理员用户.我知道它的主键(id)是1.但是当我使用forget(1)它时,从0开始删除集合中的数组元素.如何通过id从集合中删除项目?
// Grab all the users
$users = User::all(); //$this->user; use to return array not Laravel Object
if($users->find(1)->hasRole('admin'))
$users->forget(0);
Run Code Online (Sandbox Code Playgroud) 我git commit -am立即跟进git stash并得到了消息
No local changes to save
当我跑步时,git status我得到了
Your branch is ahead of 'origin/master' by 3 commits.
这是正确的吗?
我正在研究一些东西,做了一些提交,但没有推动变化.现在我想'藏匿'它们并回到一个干净的版本(我的最新pushed更改 - 不知道如何参考这个)
如何存储我尚未推送的工作并恢复到最新的推送主分支?
我在config/databases中定义了2个数据库,mysql和mysql2
默认连接是mysql
我需要从mysql2获取这些数据
$programs=DB::table('node')->where('type', 'Programs')->get();
Run Code Online (Sandbox Code Playgroud)
文档告诉我,我可以使用更改连接
$programs=DB::connection('mysql2')->select(...)
Run Code Online (Sandbox Code Playgroud)
这将让我运行一个SQL语句来获取$ program的数组.但我想知道是否有一种方法来组合2个语句,即在特定的db :: connection上使用查询构建器.
我想返回我的模态对话框编辑表单以显示验证错误,但使用Redirect::back我最终在没有模态窗口的HTML页面.
我使用BootstrapDialog 将我的attendee.edit路线加载到弹出编辑表单的模态对话框中.
HTML
<td>{{link_to_route('attendee.edit','',array($attendee->id), array(
'class'=>'edit-attendee btn btn-info btn-xs glyphicon glyphicon-pencil',
'data-title' => 'Edit Attendee'))}}
</td>
Run Code Online (Sandbox Code Playgroud)
JQuery调用BootstrapDialog
$(document).ready(function(){
$('.btn.edit-attendee').click(function(e){
e.preventDefault();
url = $(this).attr('href');
BootstrapDialog.show({
title: $(this).data('title'),
message: $('<div></div>').load(url),
buttons: [{
label: 'Update',
action: function(dialogRef) {
$('form').submit();
}
}]
});
});
});
Run Code Online (Sandbox Code Playgroud)
调节器
public function update($id)
{
$attendee = Attendee::findOrFail($id);
$validator = Validator::make($data = Input::all(), Attendee::$rules);
if ($validator->fails())
{
return Redirect::back()->withErrors($validator)->withInput();
}
$attendee->update($data);
return Redirect::route('attendees.index');
}
Run Code Online (Sandbox Code Playgroud)
在我编辑表单后,我想返回到模态窗口以显示验证错误,但我最终只是在没有对话框的HTML页面上.如何重定向回模态窗口?
UPDATE
添加id到控制器返回
return Redirect::back()->withErrors($validator)->withInput()->with('id', $id);
Run Code Online (Sandbox Code Playgroud)
添加了Jquery …
我有一个用户模型,需要有唯一的电子邮件地址,但我也想让它们留空,以防用户没有电子邮件...我在文档中看到有一种方法可以为独特和异常制定规则对于一个id ...但我不知道如何使这个允许null或空白,但如果不是这样就是唯一的.对不起似乎这很简单,但我想不出答案.
public static $adminrules =
'email' => 'email|unique:users,email,null,id,email,NOT_EMPTY'
);
Run Code Online (Sandbox Code Playgroud)
编辑可能是因为使用规则required是不够的,因为空白或null将在这些情况下通过验证.我可能有一个相关的错误,所以我不能添加超过1个空白电子邮件,所以我无法验证这一点.
public static $adminrules =
'email' => 'email|unique:users'
);
Run Code Online (Sandbox Code Playgroud) 我选择全部ScheduledPrograms从具有一定范围内的数据Attendees属于某User。我想添加一个过滤器以仅选择SchduledPrograms枢纽字段registered=1
IE浏览器,我需要为wherePivot('registered', 1)多对多关系添加一个scheduledPrograms->attendees。我该怎么做?我的头脑被所有where子句打乱了。
$programs = ScheduledProgram::where('registration_start_date', '<=', $today)
->where('end_date', '>=', $today)
->whereHas('attendees', function($q) use($user)
{
$q->whereHas('user', function($q) use($user){
$q->where('id', $user->id);
});
})->get();
Run Code Online (Sandbox Code Playgroud)
楷模
Attendee->belongsTo('User')
->belongsToMany('ScheduledPrograms')
User->hasMany('Attendee')
ScheduledProgram->belongsToMany('Attendee')
Run Code Online (Sandbox Code Playgroud)
` ScheduledProgram模型
public function attendees()
{
return $this->belongsToMany('Attendee', 'prog_bookings')->withPivot('registered','paid');
}
Run Code Online (Sandbox Code Playgroud) 我曾经是一名C++程序员,对我来说宏是一个预处理器定义使用#define.
现在我回到使用C++的Unreal引擎进行编程,但是所有这些宏 UCLASS() UFUNCTION() FORCELINE都是UNreal教程调用的宏.我以前从未见过这样的东西,想要了解它.
我不是在询问宏在虚幻中做了什么,但是有人帮助我用C++填补我的知识空白,所以我(作为开发人员)可以理解如何设计以及何时实现这种类型的宏.即使给我链接指南或其他东西也没关系.我尝试使用术语宏,C++,UCLass,Unreal进行搜索,但这些术语并没有真正提出这个宏的C++定义.
#include "GameFramework/Actor.h"
#include "Pickup.generated.h"
UCLASS()
class BATTERYCOLLECTOR_API APickup : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
APickup();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
Run Code Online (Sandbox Code Playgroud)