小编Chr*_*itz的帖子

Laravel:找不到视图[layouts.default]

我在我的项目中安装了一个包,用于定义自己的视图.在进行一些更改后浏览网站时,我发现捆绑视图中发生的所有操作都可以正常工作,但当我回到头部路径时,我收到一条错误消息:

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)

php laravel-4

3
推荐指数
1
解决办法
2万
查看次数

无法使用Laravel 5迁移添加外键约束

我正在尝试为orders表创建迁移.此表具有两个表的外键约束:employeesclients.

订单表的架构:

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)references employees(id))

我拉出了它试图使用的查询并直接在数据库上尝试并得到了同样的错误:

-- Query:
alter table `orders` add constraint orders_employee_id_foreign foreign key (`employee_id`) references `employees` …
Run Code Online (Sandbox Code Playgroud)

mysql laravel laravel-5

3
推荐指数
1
解决办法
5768
查看次数

pytest mocker.patch.object 的 return_value 使用与我传递的模拟不同的模拟

我正在使用 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 值以及补丁应设置为返回值的模拟,发现它们是不同的实例:

在调试器中暂停并且 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)

我仍然遇到同样的“不同的模拟”问题。

python unit-testing mocking pytest python-unittest

3
推荐指数
1
解决办法
3407
查看次数

awk:在读取行之前打印第一行文件

在我开始使用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命令的部分,但这似乎不起作用.

有什么建议?

bash awk

2
推荐指数
2
解决办法
9095
查看次数

身体在100%,最小高度为100%,但内容延伸到浏览器屏幕

我知道我已经看到了这个问题的解决方案,但我找不到它的生命.

我已经将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)

html css

2
推荐指数
1
解决办法
1088
查看次数

通过绑定到Ext.js 6中的数据属性,无法通过条件隐藏选项卡

我有一个tabpanel,我在第一个标签上捕获购物车,第二个标签上显示付款信息,在第三个标签上显示摘要.

如果购物车总数为0,我想隐藏标签二.

我遇到的问题是,当我尝试绑定到一个确定隐藏选项卡的布尔值的公式时,选项卡不会隐藏.

这是一个poc:

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)

extjs mvvm extjs6 extjs6-classic

2
推荐指数
1
解决办法
2031
查看次数

如何在我试图用玩笑测试的课程中模拟私有财产

我有一个要测试的类方法:

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)

javascript unit-testing typescript jestjs

2
推荐指数
1
解决办法
4116
查看次数

PHP SoapClient __getLastRequest和__getLastRequestHeaders为成功调用返回NULL

我正在阅读关于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手册中的注释和示例,看起来所有内容都设置正确.我不知道我做错了什么:/

任何帮助,将不胜感激!

php soap web-services

1
推荐指数
1
解决办法
2266
查看次数

我应该把这些代码放在Laravel中?

我正在使用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)

php laravel laravel-4 mandrill

1
推荐指数
1
解决办法
303
查看次数

布局运行失败

每当我尝试设置布局类型覆盖时,我都会遇到布局运行失败,而我不确定导致它的原因.

我有一个父视图,它有一个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)

javascript extjs extjs6

1
推荐指数
1
解决办法
1964
查看次数

cstdint 代表什么?

我知道cstdint作为标题的目的是为数字提供更准确的描述,但实际的标题名称代表什么?

当我不知道全名是什么时,我很难记住缩写的名字,尤其是在编程中。我想它类似于“c 标准类型定义整数”之类的东西,但我无法完全找到名称的解释。

cstdint 的词源是什么?

c++

1
推荐指数
1
解决办法
86
查看次数

在 C++ 中链接方法时无法访问类

我正在一个图书馆工作,我遇到了奇怪的问题,我不确定发生了什么。我打破了我正在编写的类的核心部分来复制这个问题。

要点是我有几个类用于管理项目中 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)

c++ scope

0
推荐指数
1
解决办法
47
查看次数