我希望禁用特定域的 CSRF 验证令牌。例如,我的 EC2 实例。这样我就可以在我的 EC2 实例上运行实时跨浏览器测试,而不会出现任何问题。
我找到了很多有关更新VerifyCsrfToken应用程序内特定路由的中间件目录的信息,但没有找到有关如何检查主机或域的信息。我可以/*在受保护的 URI 中使用。
class VerifyCsrfToken extends BaseVerifier
{
/**
* The URIs that should be excluded from CSRF verification.
*
* @var array
*/
protected $except = [
'/*'
];
}
Run Code Online (Sandbox Code Playgroud)
然而,出于显而易见的原因,我不想使用这种方法。
我使用的是标准 Laravel 5.3 设置,因此使用了该框架附带的常用中间件文件。
任何帮助,将不胜感激!
我有一个booked带有start和end列的表作为日期戳;
我知道
$start = "2015-07-12 01:00:00";
$end = "2015-07-12 02:00:00";
$users = DB::table('booked')
->whereBetween('start', [$start, $end])->get();
Run Code Online (Sandbox Code Playgroud)
检查start列中是否包含$ start和$ end内的任何日期。
我想要的实际上是另一种方式。
在检查$ start和$ end日期变量在表中的start和end列中出现时遇到困难book。
我想限制相关记录来自
$categories = Category::with('exams')->get();
Run Code Online (Sandbox Code Playgroud)
这将使我获得所有类别的考试,但我想要的是从一个类别和每个类别获得 5 个考试。
类别模型
public function Exams() {
return $this->hasMany('Exam');
}
Run Code Online (Sandbox Code Playgroud)
考试模式
public function category () {
return $this->belongsTo('Category');
}
Run Code Online (Sandbox Code Playgroud)
我已经尝试了几件事,但无法让它工作
首先我发现的是这样的
$categories = Category::with(['exams' => function($exams){
$exams->limit(5);
}])->get();
Run Code Online (Sandbox Code Playgroud)
但问题是它只会让我从所有类别中获得 5 条记录。我也尝试为类别模型添加限制
public function Exams() {
return $this->hasMany('Exam')->limit(5);
}
Run Code Online (Sandbox Code Playgroud)
但这并没有做任何事情,并且返回艰难,它没有限制 5。
那么有没有一种方法可以用 Eloquent 来做到这一点,或者我应该简单地加载所有东西(想传递它)并使用 foreach 的 break 吗?
我有一个如下的迁移
$table->increments('id');
$table->integer('order_num');
$table->timestamps();
Run Code Online (Sandbox Code Playgroud)
主键应该是id和order_num的组合.如果我把下面的代码,它说我正在尝试添加2个主键(因为增量也是主键).有没有办法告诉雄辩,我正试图将两者结合在一起
$table->primary(['course_id', 'order_num']);
Run Code Online (Sandbox Code Playgroud) 我有借方字段和借方字段
<input type="text" class="form-control" name="debit" value="{{ isset($expense->debit) ? $expense->debit : old('debit')}}">
Run Code Online (Sandbox Code Playgroud)
和
<input type="text" class="form-control" name="credit" value="{{ isset($expense->credit) ? $expense->credit: old('credit')}}">
Run Code Online (Sandbox Code Playgroud)
我需要确保提交表单时值相等。
我知道如果像这样命名它们,我可以做到:
debit 和 debit_confirmation 以及规则数组中
return Validator::make($data, [
'debit' => 'required|confirmed',
]);
Run Code Online (Sandbox Code Playgroud)
但我不想改变他们的名字。
Laravel 5 中的任何内置验证都可以做到这一点。
我在我的centos6主机上使用了laravel 5.1框架.我已经使用过composer install illuminate/html,但是调用HTML::style()导致了这个错误:FatalErrorException in 7b06fa36a7460c71e5daf57645a3dbda line 12: Call to undefined method Illuminate\Html\HtmlServiceProvider::style()
我的应用配置:
'aliases' => [
//more...
'HTML' => Illuminate\Html\HtmlServiceProvider::class,
'Form' => Illuminate\Html\FormFacade::class
],
'providers' => [
//more...
Illuminate\View\ViewServiceProvider::class,
Illuminate\Html\HtmlServiceProvider::class,
]
Run Code Online (Sandbox Code Playgroud)
composer.json:
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"illuminate/html": "5.*"
},
Run Code Online (Sandbox Code Playgroud)
比如说 {!! Form::open() !!} ...很好HTML::style().
我该怎么办?
我有两个模型:Uai和Information一个hasOne关系.
Uai (uai_id, a)
Information (uai_id, b)
Run Code Online (Sandbox Code Playgroud)
我想生成一个包含以下内容的Json响应:
Uai记录truewhitch 说如果hasOne Relationship存在于Uai和之间,Information并且false如果没有关系任何的想法 ?
在此先感谢Paguemaou
编辑一个
感谢jedrzej.kurylo的回答.我如何使用uai_id当前行中的fake column getter?我使用getter和seeter但我从不尝试使用另一列的内容.能给我举个例子 ?
如果我理解,我可以使用fake column name在其他列名称中选择.我是真的吗?
我已经阅读了有关可以在CouchDB上创建的验证(validate_doc_update)的信息,但是我没有弄清楚如何创建它们。我可以通过Fauxton吗?
Databases -> "mydb" -> Design Documents -> New Doc
Run Code Online (Sandbox Code Playgroud)
是这样吗 我必须将函数声明为字符串吗?我需要一个示例(文档中有任何分步说明)。
谢谢。
例如,模型有很多属性,但在 select 中我只指定了几个属性。
$listings = Realty::select('city', 'mls', 'class_id')->get();
Run Code Online (Sandbox Code Playgroud)
如何使一个特质(prefebable)或类继承 Eloquent,如果我尝试访问不在 select 中的属性,它将抛出异常:
$propertyType = $listings[0]->property_type; // returns `null`, but I need
// RuntimeException or ErrorException
Run Code Online (Sandbox Code Playgroud) 我有一个混合使用Laravel和Angular路由的问题,同时尝试捕获我的非Laravel路由并呈现Angular视图.
我在app\http\route.php中添加了丢失的方法后出现以下错误:
Facade.php第216行中的FatalErrorException:调用未定义的方法Illuminate\Foundation\Application :: missing()
我知道这对laravel 5或者down版本可以正常工作,但是我目前没有使用laravel 5.2,那么如何在laravel 5.2中编码?有解决方案吗
route.php看起来像:
<?php // app/routes.php
// HOME PAGE ===================================
// I am not using Laravel Blade
// I will return a PHP file that will hold all of our Angular content
Route::get('/', function() {
View::make('index'); // will return app/views/index.php
});
// API ROUTES ==================================
Route::group(['prefix' => 'api'], function() {
// Angular will handle both of those forms
// this ensures that a user can't access api/create or api/edit when there's nothing there …Run Code Online (Sandbox Code Playgroud) laravel ×9
php ×8
laravel-5 ×7
eloquent ×5
laravel-4 ×2
laravel-5.1 ×2
angularjs ×1
blade ×1
couchdb ×1
couchdb-2.0 ×1
csrf ×1
laravel-5.2 ×1
mysql ×1
one-to-many ×1
sql-limit ×1