我将实际数据播种到我的数据库时遇到了一些麻烦.我收到错误消息:
"Integrity constraint violation: 1062 Duplicate entry 'jon@doe.de' for key 'users_email_unique'"
Run Code Online (Sandbox Code Playgroud)
这就是我工厂的样子:
$factory('App\User', [
'name' => 'Jon Doe',
'email' => 'jon@doe.com',
'password' => password_hash('123456', PASSWORD_DEFAULT),
]);
$factory('App\User', [
'name' => 'Jane Doe',
'email' => 'jane@doe.com',
'password' => password_hash('123456', PASSWORD_DEFAph ULT),
]);
Run Code Online (Sandbox Code Playgroud)
我甚至没有运行UserTableSeeder,但它似乎再次触发了jon@doe.com.
有线索吗?
这是我的DatabaseSeeder:
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
// $this->call('UserTableSeeder');
$this->call('ClientTableSeeder');
$this->call('OrderTableSeeder');
$this->call('FileTableSeeder');
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的UserTableSeeder,上面已注释掉了
<?php
use …Run Code Online (Sandbox Code Playgroud) 我以这个类为例:
我使用哪个插件才能点击:
PHPUnit_Framework_TestCase
并去上课吗?
class PracticeTest extends PHPUnit_Framework_TestCase {
public function testHelloWorld() {
$greeting = 'Hello, World.';
$this->assertTrue($greeting === 'Hello, World.');
}
}
Run Code Online (Sandbox Code Playgroud)
现在我必须手动搜索它。我知道 PHPStorm 有这个功能,我相信 Sublime 一定有一个插件。
多谢。
我有一个表从Laravel API获取一些JSON来填充行.我正在使用VueJS和v-repeat:
<tbody>
<tr v-repeat="entry: entries">
<td>@{{ entry.id }} </td>
<td>@{{ entry.distance }} km</td>
<td>@{{ entry.consumption }} l</td>
<td>@{{ getPrice(entry) + ' €'}}</td>
<td>@{{ getCost(entry) + ' €'}}</td>
<td>@{{ getAverageConsumption(entry) + ' l' }}</td>
<td>@{{ getAverageCost(entry) + ' €' }}</td>
<td>@{{ getCostPerDay(entry) + ' €' }}</td>
<td>@{{ this.getDate(entry) }}</td>
</tr>
</tbody>
Run Code Online (Sandbox Code Playgroud)
现在我想计算AverageCostPerDay().问题是,我需要访问迭代中的上一个项目,以便比较过去的天数.
如何在VueJS中使用v-repeat访问以前的项目?我的getCostPerDay()方法怎么样?
如何将多个文件与Elixir混合复制?
这不起作用:
mix.copy([
['node_modules/vue/dist/vue.js', 'resources/assets/js/vendor/vue.js'],
['node_modules/vue-resource/dist/vue-resource.js', 'resources/assets/js/vendor/vue-resource.js']
]);
Run Code Online (Sandbox Code Playgroud)
除以下任何其他建议:
mix.copy('node_modules/vue/dist/vue.js', 'resources/assets/js/vendor/vue.js');
mix.copy('node_modules/vue-resource/dist/vue-resource.js', 'resources/assets/js/vendor/vue-resource.js');
Run Code Online (Sandbox Code Playgroud) 我正在使用Laravel 4并有两个模型:项目和任务.我的Project.php是
class Project extends \Eloquent {
protected $guarded = [];
public function tasks()
{
return $this->hasMany('Task');
}
}
Run Code Online (Sandbox Code Playgroud)
我的Task.php是
class Task extends \Eloquent {
protected $guarded = [];
public function project()
{
return $this->belongsTo('Project');
}
}
Run Code Online (Sandbox Code Playgroud)
直到现在相当标准的东西.
现在我想显示最近30天.我正在使用nesbot/Carbon,我可以这样做:
$projects = Project::with('tasks')->where('created_at', '>', Carbon::now()->subDays(30))->get();
Run Code Online (Sandbox Code Playgroud)
但这显示了过去30天的项目,但我想显示过去30天的任务.在Laravel.io聊天中,我得到了使用此建议:
$projects = Project::with(['tasks' => function($query) { $query->where('created_at', '>', Carbon::now()->subDays(30)); }]);
Run Code Online (Sandbox Code Playgroud)
但这也不起作用.
我会很感激有关如何在过去30天内访问任务的建议,同时使用我通常在我的控制器中执行的模型关系.
爱,
乔治 :)
我想在我的Windows机器上使用gulp,它实际上工作得很好,除非我尝试使用创建的文件(如推送到github或删除).然后它就会中断,因为文件路径太长而且似乎是一个相当普遍的问题.https://github.com/joyent/node/issues/6960#issuecomment-45569604
我知道问题是通过npm的嵌套目录产生的,这些目录扩展了Windows目录的最大字符数,但据我所知,还没有任何解决方案.
我现在看到它有三个选择:
那么这是我的问题,我究竟如何更改默认的'node_modules'目录名?
将我的开发环境改为Ubuntu,坦白说这是我不喜欢的解决方案,因为我从未使用过Ubuntu.
停止使用gulp整体.
那么,如何更改通过npm创建的默认"node_modules"目录或您实际建议的解决方案?
我宁愿将文件保存到会话中,并在以后的某个条件下上传,而不是将文件直接上传并移动到服务器上的某个位置.
这是我的方法,当前将文件保存到我的服务器:
public function step3store() {
$file = Input::file('file');
$identifier = date("Ymd") . " - " . Session::get('lastName') . "_" . Session::get('firstName');
$destinationPath = base_path() . '/uploads/'. $identifier ;
$extension = $file->getClientOriginalExtension();
$filename = $identifier . " - " . uniqid() . "." . $extension;
$upload_success = Input::file('file')->move($destinationPath, $filename);
if( $upload_success ) {
return Response::json('success', 200);
} else {
return Response::json('error', 400);
}
}
Run Code Online (Sandbox Code Playgroud)
而我正在考虑使用这样的东西:
Session::put([
'file' => Input::get('file'),
]);
Run Code Online (Sandbox Code Playgroud)
但每当我检查我的会话时,在我上传文件后,我得到"文件"的值为"null".
由于我每个Ajax上传多个文件,我不确定它是否会破坏我将文件放入Session的方式.
那么,如何将每个Ajax的多个文件保存到Laravel会话中?
提前致谢.
我想创建一些资源丰富的路由,但是限制了一些方法,所以它们不会显示为路由.
这可能是一条足智多谋的路线:
Route::resource('users', 'UsersController');
Run Code Online (Sandbox Code Playgroud)
我记得有一种方法来限制这些资源丰富的路线,如下所示:
Route::resource('users', ['uses' => 'UsersController', 'except' => ['store', 'delete']]);
Run Code Online (Sandbox Code Playgroud)
然而,当我做这样的事情时,我会得到一个
[ErrorException]数组到字符串转换
如何在不手动键入每个路径的情况下限制Laravel 5中的资源丰富路由?
我想把RED按钮放在右边,就像我过去使用花车一样
小提琴:http://jsfiddle.net/vb61r4uL/
.container {
height: 100%;
width: 100%;
background-color: yellow;
display: flex;
align-items: center;
justify-content: center;
}
ul, li {
list-style: none;
padding: 0px;
}
#list {
width: 300px;
background: grey;
}
.item {
display: flex;
align-items: center;
justify-content: flex-start;
}
.destory-button {
background:red;
justify-content: flex-end;
}Run Code Online (Sandbox Code Playgroud)
<div class="container">
<ul id="list">
<li>
<div class="item">
<input type="checkbox">
Title
<button class="destory-button">Destroy</button>
</div>
</li>
<li>
<div class="item">
<input type="checkbox">
2nd Title
<button class="destory-button">Destroy</button>
</div>
</li>
<li>
<div class="item">
<input type="checkbox"> …Run Code Online (Sandbox Code Playgroud)我有一个聚合物元素,我想应用一个令牌作为头属性.
当我按下按钮时,将发送XMLHttpReqeust.负责iron-ajax元素具有headers带字符串的属性.我想更改字符串,并应用不同的属性.
我被告知正常compound bindings不起作用,我应该尝试computed bindings或只是computed properties.
但问题似乎是问题,如何bind这些computed properties或computed bindings到iron-ajax元素?
每当我使用花括号时,都不会评估任何内容.如果我将它们遗漏,只剩下剩余的字符串被解析.
这是我的元素:
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/iron-ajax/iron-ajax.html">
<dom-module id="demo-element">
<template>
<button on-click="sendXMLHttpRequest">sendXMLHttpRequest</button>
<div>
Computed Binding HeadersProperty:
<span>{{computeHeadersProperty(csrfToken)}}</span>
</div>
<div>
Computed Property HeadersProperty:
<span>{{headersProperty}}</span>
</div>
<div>
Computed Binding HeadersToken:
<span>{{computeHeadersToken(csrfToken)}}</span>
</div>
<div>
Computed Property HeadersToken:
<span>{{headersToken}}</span>
</div>
<iron-ajax
id="ajax"
method="POST"
url=""
handle-as="json"
headers='{"X-CSRF-Token": "csrfToken"}'
></iron-ajax>
</template>
<script>
Polymer({
is: 'demo-element',
properties: {
csrfToken: …Run Code Online (Sandbox Code Playgroud)