我在我的项目中安装了一个包,用于定义自己的视图.在进行一些更改后浏览网站时,我发现捆绑视图中发生的所有操作都可以正常工作,但当我回到头部路径时,我收到一条错误消息:
View [layouts.default] not found. (View: /var/www/app/views/home.blade.php)
Run Code Online (Sandbox Code Playgroud)
该文件app/views/home.blade.php肯定存在.我的头部路线的闭合看起来像这样:
Route::get('/', array('as' => 'home', function()
{
return View::make('home');
}));
Run Code Online (Sandbox Code Playgroud)
什么可以改变我的观点的结构?
编辑:
这是我的home.blade.php文件的内容:
@extends('layouts.default')
{{-- Web site Title --}}
@section('title')
@parent
{{trans('pages.helloworld')}}
@stop
{{-- Content --}}
@section('content')
<div class="jumbotron">
<div class="container">
<h1>{{trans('pages.helloworld')}}</h1>
<p>{{trans('pages.description')}}</p>
</div>
</div>
@if (Sentry::check() )
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title"><span class="glyphicon glyphicon-ok"></span> {{trans('pages.loginstatus')}}</h3>
</div>
<div class="panel-body">
<p><strong>{{trans('pages.sessiondata')}}:</strong></p>
<pre>{{ var_dump(Session::all()) }}</pre>
</div>
</div>
@endif
@stop
Run Code Online (Sandbox Code Playgroud) 我正在尝试为orders表创建迁移.此表具有两个表的外键约束:employees和clients.
订单表的架构:
Schema::create('orders', function (Blueprint $table) {
$table->increments('id');
$table->integer('client_id')->unsigned();
$table->foreign('client_id')->references('id')->on('clients');
$table->integer('employee_id')->unsigned();
$table->foreign('employee_id')->references('id')->on('employees');
$table->text('description');
$table->string('status');
$table->date('submitted_on');
$table->date('completed_on');
$table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
employees表的架构:
Schema::create('employees', function (Blueprint $table) {
$table->increments('id');
$table->string('type');
$table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
clients表的架构:
Schema::create('clients', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
$table->timestamps();
});
Run Code Online (Sandbox Code Playgroud)
当我运行迁移时,会为clients表成功创建约束,但由于某种原因,在尝试为employees创建约束时会出错:
[Illuminate\Database\QueryException] SQLSTATE [HY000]:常规错误:1215无法添加外键约束(SQL:alter table
ordersadd constraint orders_employee_id_foreign foreign key(employee_id)referencesemployees(id))
我拉出了它试图使用的查询并直接在数据库上尝试并得到了同样的错误:
-- Query:
alter table `orders` add constraint orders_employee_id_foreign foreign key (`employee_id`) references `employees` …Run Code Online (Sandbox Code Playgroud) 我正在使用 pytest 修补 os.makedirs 方法以进行测试。在一个特定的测试中,我想添加异常的副作用。
因此,我导入os在测试脚本中导入的对象,对其进行修补,然后在测试中设置副作用:
from infrastructure.scripts.src.server_administrator import os
def mock_makedirs(self, mocker):
mock = MagicMock()
mocker.patch.object(os, "makedirs", return_value=mock)
return mock
def test_if_directory_exist_exception_is_not_raised(self, administrator, mock_makedirs):
mock_makedirs.side_effect = Exception("Directory already exists.")
with pytest.raises(Exception) as exception:
administrator.initialize_server()
assert exception.value == "Directory already exists."
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,当在我的测试脚本中调用模拟时,副作用不再存在。在进行故障排除时,我停止了调试器中的测试,以查看我创建的模拟的 ID 值以及补丁应设置为返回值的模拟,发现它们是不同的实例:
我对 python 中的一些测试工具还比较陌生,所以这可能是我在文档中遗漏了一些东西,但是这里修补的返回的模拟不应该是我创建的模拟吗?难道是我补丁错了?
我什至调整了导入样式以makedirs直接抓取来修补它:
def mock_makedirs(self, mocker):
mock = MagicMock()
mocker.patch("infrastructure.scripts.src.server_administrator.makedirs", return_value=mock)
return mock
Run Code Online (Sandbox Code Playgroud)
我仍然遇到同样的“不同的模拟”问题。
在我开始使用awk逐步遍历每一行之前,我将如何打印给定输入的第一行?
假设我想运行命令ps aux并返回列标题和我正在搜索的特定模式.过去我做过这个:
ps aux | ggrep -Pi 'CPU|foo'
Run Code Online (Sandbox Code Playgroud)
哪里CPU是我知道会在输入的第一行,因为它是一个列标题和值foo是特定的模式实际上,我寻找.
我找到了一个将拉出第一行的awk模式:
awk 'NR > 1 { exit }; 1'
Run Code Online (Sandbox Code Playgroud)
这是有道理的,但在我对其余输入进行模式匹配之前,我似乎无法弄清楚如何解决这个问题.我以为我可以把它放在BEGINawk命令的部分,但这似乎不起作用.
有什么建议?
我知道我已经看到了这个问题的解决方案,但我找不到它的生命.
我已经将html和body元素扩展到了dom的100%.它们的最小高度为100%.问题是当我的内容超出浏览器屏幕的底部时,正文将不会随之扩展:
<!DOCTYPE html>
<html>
<head>
<title>Damn you body, extend!!</title>
<style type="text/css">
html,body{
height :100%;
min-height :100%;
}
html{
background-color:gray;
}
body{
width :90%;
margin :auto;
background-color :white;
}
body > div{
background-color :red;
height :50px;
width :80px;
margin :auto;
text-align :center;
}
</style>
</head>
<body>
<div>testitem <br />testItem</div>
<div>testitem <br />testItem</div>
<div>testitem <br />testItem</div>
<div>testitem <br />testItem</div>
<div>testitem <br />testItem</div>
<div>testitem <br />testItem</div>
<div>testitem <br />testItem</div>
<div>testitem <br />testItem</div>
<div>testitem <br />testItem</div>
<div>testitem <br />testItem</div>
<div>testitem <br />testItem</div>
<div>testitem …Run Code Online (Sandbox Code Playgroud) 我有一个tabpanel,我在第一个标签上捕获购物车,第二个标签上显示付款信息,在第三个标签上显示摘要.
如果购物车总数为0,我想隐藏标签二.
我遇到的问题是,当我尝试绑定到一个确定隐藏选项卡的布尔值的公式时,选项卡不会隐藏.
Ext.define('TestPanel',{
extend: 'Ext.tab.Panel',
xtype: 'testpanel',
title: 'Test Panel',
viewModel:{
data:{
cartTotal: 0
},
formulas:{
hideTabTwo: function(get){
return get('cartTotal') == 0 ? true : false
}
}
},
items:[
{
title: 'Tab 1',
items:[
{
xtype: 'textfield',
bind:{
value: '{cartTotal}'
}
},
{
bind:{html:'Cart Total: {cartTotal}'}
},
{
bind:{
html: 'Hide Tab 2: {hideTabTwo}'
}
}
]
},
{
title: 'Tab 2',
html: 'omg',
bind:{
hidden: '{hideTabTwo}'
}
},
{
title: 'Tab 3',
html: 'lol'
} …Run Code Online (Sandbox Code Playgroud) 我有一个要测试的类方法:
setStepResolution(resolution: stepResolution): void {
switch (resolution) {
case stepResolution.FULL_SETUP:
this.stepperMotors.left.ms1Pin.digitalWrite(0)
this.stepperMotors.left.ms2Pin.digitalWrite(0)
this.stepperMotors.left.ms3Pin.digitalWrite(1)
this.stepperMotors.right.ms1Pin.digitalWrite(0)
this.stepperMotors.right.ms2Pin.digitalWrite(0)
this.stepperMotors.right.ms3Pin.digitalWrite(1)
break
case stepResolution.HALF_STEP:
this.stepperMotors.left.ms1Pin.digitalWrite(1)
this.stepperMotors.left.ms2Pin.digitalWrite(0)
this.stepperMotors.left.ms3Pin.digitalWrite(0)
this.stepperMotors.right.ms1Pin.digitalWrite(1)
this.stepperMotors.right.ms2Pin.digitalWrite(0)
this.stepperMotors.right.ms3Pin.digitalWrite(0)
break
Run Code Online (Sandbox Code Playgroud)
这些digitalWrite调用中的每一个都是对构建我的类时创建的不同类的实例进行的:
export default class BotController {
private stepperMotors: StepperMotorCollection
constructor() {
this.initalizeMotors()
}
private initalizeMotors(): void {
this.stepperMotors = {
left: {
directionPin: new Gpio(Number(process.env.LEFT_DIRECTION_PIN), { mode: Gpio.OUTPUT }),
stepPin: new Gpio(Number(process.env.LEFT_STEP_PIN), { mode: Gpio.OUTPUT }),
ms1Pin: new Gpio(Number(process.env.LEFT_RESOLUTION_PIN_MS1), { mode: Gpio.OUTPUT }),
ms2Pin: new Gpio(Number(process.env.LEFT_RESOLUTION_PIN_MS2), { mode: Gpio.OUTPUT }),
ms3Pin: new …Run Code Online (Sandbox Code Playgroud) 我正在阅读关于webservices和SOAP的教程.在了解这些内容时,我创建了一个php文件,以便对w3schools提供的WSDL进行操作,该文件将温度转换为摄氏温度和华氏温度.
我编写了以下成功触发的PHP代码:
$wsdl = "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL";
$soapClient = new SoapClient($wsdl);
// print_r ($soapClient->__getFunctions());
// print_r ($soapClient->__getTypes());
$parameters = array("Celsius" => "0");
$result = $soapClient->__soapCall("CelsiusToFahrenheit", array($parameters) );
echo "key: " . key($result) . "<br />" ;
echo "value: " . current($result) . "<br />" ;
Run Code Online (Sandbox Code Playgroud)
浏览器成功返回以下内容:
key: CelsiusToFahrenheitResult
value: 32
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用SoapClient方法__getLastRequest()并__getLastRequestHeaders()查看发送的标头,看看它们与我读过的内容的比较以及两个方法调用返回null
echo "Last call headers: <br />";
echo $soapClient->__getLastRequestHeaders();
echo "<br />" ;
echo "Last call headers: <br />";
echo $soapClient->__getLastRequest();
Run Code Online (Sandbox Code Playgroud)
我查看了_getLastRequestHeaders()的php手册中的注释和示例,看起来所有内容都设置正确.我不知道我做错了什么:/
任何帮助,将不胜感激!
我正在使用Laravel4构建一个站点.这是我的第一个Laravel项目,所以我仍然在学习如何将所有东西放在一起以及它应该在哪里.
我刚刚将Laravel-Mandrill-Request包添加到我的网站.我能够从我的测试控制器中的方法发送电子邮件,如下所示:
public function sendMeSomething(){
$payload = array(
'message' => array(
'subject' => 'Greetings!!',
'from_email' => 'xxxx@yyyy.com',
'to' => array(
array('email'=>'aaaa@bbbb.com'),
array('email' => 'cccc@bbbb.com')
),
'global_merge_vars' => array(
array(
'name' => 'time',
'content' => time()
),
array(
"name" => "SenderName",
"content" => "Chris"
)
),
'merge_vars' => array(
array(
'rcpt' => 'aaaa@bbbb.com',
'vars' => array(
array(
'name' => 'firstName',
'content' => 'Christopher'
)
)
),
array(
'rcpt' => 'cccc@bbbb.com',
'vars' => array(
array(
'name' => 'firstName',
'content' => …Run Code Online (Sandbox Code Playgroud) 每当我尝试设置布局类型覆盖时,我都会遇到布局运行失败,而我不确定导致它的原因.
我有一个父视图,它有一个tabpanel作为子项:
Ext.define('InventoryDemo.view.main.Main', {
extend: 'Ext.panel.Panel',
xtype: 'app-main',
requires: [
'Ext.plugin.Viewport',
'InventoryDemo.view.brand.Brand'
],
title: '<h1>Inventory Demo</h1>',
layout: 'border',
items:[
{
...
},
// This is the tab panel that I'm trying to add the container class to
{
xtype: 'tabpanel',
title: 'Inventories',
header: false,
region: 'center',
reference: 'inventoryTabSet'
}
]
});
Run Code Online (Sandbox Code Playgroud)
这是我试图将选项卡添加到选项卡面板的视图:
Ext.define("InventoryDemo.view.inventory.list.Inventory",{
extend: "Ext.container.Container",
xtype: 'inventory',
...
closable: true,
layout:{
type: 'hbox',
align: 'stretch'
},
items:[
{
xtype: 'grid',
bind:{
store: '{inventory}'
},
listeners:{
itemclick: 'showDetails'
},
columns:[
{ …Run Code Online (Sandbox Code Playgroud) 我正在一个图书馆工作,我遇到了奇怪的问题,我不确定发生了什么。我打破了我正在编写的类的核心部分来复制这个问题。
要点是我有几个类用于管理项目中 LED 的索引分组。
我有一个课程来跟踪 LED 指数范围:
class Range
{
public:
Range () {}
Range (int start, int end):_start (start), _end (end) {}
private:
int _start;
int _end;
};
Run Code Online (Sandbox Code Playgroud)
另一个类将范围组合成一个部分:
class Section
{
public:
Section () {}
void addRange(int start, int end)
{
addRange(Range (start, end));
}
void addRange(Range r)
{
if (_rangeCount < TOTAL_RANGES)
{
_ranges[_rangeCount] = r;
_rangeCount++;
}
}
Range getRange(int index)
{
return _ranges[index];
}
int getRangeCount()
{
return _rangeCount;
}
private:
int _rangeCount = 0; …Run Code Online (Sandbox Code Playgroud)