小编mic*_*rry的帖子

如何在laravel中分离多个实例 雄辩的透视台?

数据透视表:'bonus_circle'可以使多个项目具有相同的circle_id和bonus_id.换句话说,同一个圈子可以有多个相同的奖励.使用$ circle-> bonus() - > detach($ id)删除所有实例.我需要它只分离一个实例.有谁知道这方面的工作?

php laravel eloquent

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

BigQuery [PHP] InsertAll Error:表数据附加请求中没有记录

除了这个函数的最后一行,我觉得一切都在工作.但似乎json(行)是问题......

任何帮助表示赞赏!

错误:

Google_Service_Exception
Error calling POST https://www.googleapis.com/bigquery/v2/projects/mtg/datasets/log/tables/v1/insertAll: (400) No records present in table data append request.
Run Code Online (Sandbox Code Playgroud)

表格架构:

raw_url         STRING      NULLABLE
endpoint        STRING      NULLABLE
parameter       STRING      NULLABLE
client_ip       STRING      NULLABLE
account         INTEGER     NULLABLE
response_code   INTEGER     NULLABLE
response_time   INTEGER     NULLABLE
datetime        TIMESTAMP   NULLABLE
Run Code Online (Sandbox Code Playgroud)

码:

public function insertLog()
{
    $rows = new Google_Service_Bigquery_TableDataInsertAllRequestRows;
    $rows->setJson('{"raw_url":"test","endpoint":"card.id","parameter":"1","client_ip":"127.0.0.1","account":1,"response_code":200,"response_time":1000,"created_at":"2014-02-14 19:16:21"}');
    $rows->setInsertId("21");

    $request = new Google_Service_Bigquery_TableDataInsertAllRequest;
    $request->setKind('bigquery#tableDataInsertAllRequest');
    $request->setRows($rows);

    $this->service->tabledata->insertAll($this->project_id, 'log', 'v1', $request);
}
Run Code Online (Sandbox Code Playgroud)

php google-bigquery

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

数据透视表中的 laravel/eloquent mutators/accessors

好吧,我认为标题解释了大部分内容。让我们开始吧!

空白模型:

class Blank extends Eloquent 
{

    protected $table = 'blanks';

    protected $softDelete = true;

    protected $hidden = array();

    /**
     * Get associated jobs.
     *
     * @return mixed
     */
    public function jobs()
    {
        return $this->belongsToMany('Job')->withPivot('status', 'inventory', 'sizes', 'mill', 'po', 'location', 'ordered_at', 'expected_at', 'note')->withTimestamps();
    }

    /**
     * Blanks sizes accessor
     *
     * @return object
     */
    public function getSizesAttribute($value)
    {
        return json_decode($this->pivot->sizes);
    }

    /**
     * Blanks sizes mutator
     *
     * @return void
     */
    public function setSizesAttribute($value)
    {
        $this->pivot->attributes['sizes'] = json_encode($this->pivot->sizes);
    }

} …
Run Code Online (Sandbox Code Playgroud)

php pivot-table laravel eloquent

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

具有多个ServerAlias的Apache2 Dynamic vHost

我正在尝试建立一个动态的vHost,但遇到了一些麻烦.它不允许我设置多个ServerAlias.

<VirtualHost *:80>
        ServerAlias *.com
        ServerAdmin michael.ian.curry@gmail.com
        VirtualDocumentRoot /var/www/%1/production/html
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        LogLevel warn
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

以上vHost仅适用于' .com'我需要它才能用于'www..com'和'*.com'我认为设置ServerAlias会修复它,但它无法正常工作.

ServerAlias *.com www.*.com
Run Code Online (Sandbox Code Playgroud)

如果您有任何见解,请回复

--MichaelCurry

==编辑1 ==

示例redcrusher.com和www.redcrusher.com

==编辑2 ==

下面的代码也不起作用

ServerAlias www.*.com *.com
Run Code Online (Sandbox Code Playgroud)

apache dns dynamic

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

PHP语法错误,意外'['

我从来没有遇到过这种情况,但是我们走了:

在此输入图像描述

有任何想法吗?

  • 运行php-fpm 5.3
  • Ubuntu 12.04(精确穿山甲)

看起来好像评论不起作用......

php nginx laravel

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

Salt-Stack/Vagrant:ubuntu 12.04上的php 5.5

通过使用下面的文件,我只能得到'PHP 5.3.10-1ubuntu3.8'.我至少需要PHP 5.4,并且非常喜欢php 5.5.

谁能帮我吗?我一直在寻找几个小时,似乎这不是一个被谈论很多的话题.

提前致谢.

php.sls

php5-fpm:
  pkg:
    - installed
  service.running:
    - enable: True
    - watch:
      - file: /etc/php5/fpm/pool.d/www.conf
    - require:
      - pkg: php5-fpm
      - pkg: php5-mcrypt
      - pkg: php5-curl
      - pkg: php5-mysql
      - pkg: php5-cli
  file.managed:
    - name: /etc/php5/fpm/pool.d/www.conf
    - source: salt://packages/php/www.conf
    - user: root
    - group: root
    - mode: '0640'
    - require:
      - pkg: php5-fpm
Run Code Online (Sandbox Code Playgroud)

php configuration vagrant salt-stack

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

Laravel - 路由返回本地主机

为什么route('charts.inline', 123123)返回http://localhost/charts/123123而不是我的实际域?我的 ENV config/app.php url 设置正确,我的 ENV 是正确的。我正在通过终端 [a 'command'] 运行此命令。

想法?

php laravel-4

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

Eloquent ORM单项集合作为数组返回

码: $account->deals

这就像返回一个对象或一个对象数组.

宾语: {deal}

对象数组: [{deal}, {deal}, {deal}]

有没有办法强制调用返回"对象数组",即使它只返回一个对象?

为了澄清,我不想使用foreach,is_array(),count()等...

这是我希望工作的最终产品:$deals = array_merge($account->deals, $user->deals);即使Eloquent只返回一个对象.

php arrays laravel eloquent laravel-4

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