小编mik*_*ike的帖子

Liquid是否在数组运算符中包含或不包含?

在Liquid模板中调用items和array时,如何调用does not containnot in array

liquid jekyll

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

如何使用Laravel架构生成器更改列类型?

我需要将两个字段从整数更改为外键.如何构建我的迁移呢?

Schema::create('messages', function($table)
{
    $table->increments('id');
    $table->integer('sender');
    $table->integer('recipient');
    $table->string('title');
    $table->longtext('body');
    $table->timestamps();
    $table->softDeletes();
    $table->integer('regarding');
});
Run Code Online (Sandbox Code Playgroud)

我会改sendersender_id,recipientrecipient_idregardingregarding_id.

database laravel-4

14
推荐指数
4
解决办法
2万
查看次数

使用Laravel Eloquent ORM从"胖模型,瘦身控制器"角度工作的做法是什么?

阅读后,我一直在选择其他开发人员的大脑"脂肪模型,瘦身控制器"的概念:

大多数受访者正在使用我认为的胖控制器.

虽然这个主题已经出现在Stack Overflow上,但我还没有在实践中找到对该方法的详尽描述.

我刚刚在这里找到一个旧的相关问题.

php laravel eloquent

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

请解释 Laravel ORM 中的foreign_key 和 local_key 关系

我正在有效地尝试定义用户(发送者和接收者)和消息之间的关系。

我的消息迁移是:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMessagesTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //
        Schema::create('messages', function($t){
            $t->increments('id');
            $t->integer('sender_user_id')->unsigned();
            $t->integer('recipient_user_id')->unsigned();
            $t->string('subject');
            $t->text('content');
            $t->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
        Schema::dropIfExists('messages');
    }

}
Run Code Online (Sandbox Code Playgroud)

我的消息模型很简单:

<?php

class Message extends Eloquent{
    // link to sender user id
    public function from(){
        return $this->hasOne('User', 'sender_user_id'); 
    }
    // link to recipient user id …
Run Code Online (Sandbox Code Playgroud)

orm laravel-4

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

为什么Laravel中的示例测试无法重定向?

请解释为什么Laravel 4的示例测试失败了.

我的"/"路由重定向到我的routes.php文件中的"login".

(哦,我是RTFMed并搜索了几个网站,博客和内容.)

-sh-3.2$ phpunit
PHPUnit 4.0.7 by Sebastian Bergmann.

Configuration read from /home/dev/phpunit.xml

The Xdebug extension is not loaded. No code coverage will be generated.

F

Time: 83 ms, Memory: 13.50Mb

There was 1 failure:

1) ExampleTest::testBasicExample
Failed asserting that false is true.

/home/dev/app/tests/ExampleTest.php:14

FAILURES!                            
Tests: 1, Assertions: 1, Failures: 1.
-sh-3.2$ 
Run Code Online (Sandbox Code Playgroud)

这是ExampleTest.php中的代码

<?php

class ExampleTest extends TestCase {

    /**
     * A basic functional test example.
     *
     * @return void
     */
    public function testBasicExample()
    {
        $crawler = $this->client->request('GET', …
Run Code Online (Sandbox Code Playgroud)

phpunit eloquent laravel-4

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

为什么我的while循环永远不会结束

我一直在尝试使用PHP从我的数据库中呈现我的数据.我的while循环继续运行.

  function makeCollection(){
    $images = mysql_query("select file_id from images where collection_id = 1");
     //returns file_id

     $fileIds = mysql_fetch_array($images, MYSQL_NUM );
     //get file ids from $images into array

     while($fileIds != false){
      echo($fileIds[0]);
     }
  }
Run Code Online (Sandbox Code Playgroud)

我有三个符合id = 1,2和3的对象(它是自动递增的).不应该循环迭代然后在第三个之后停止?它只是为无穷大写'1'.

php loops

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

如何测试是否设置了从Eloquent查询返回的对象?

我正在测试用户是否已经在数据库中有记录(d).

我的查询:

$userResults = Results::where('d','=',Input::get('d'))
                      ->where('user','=',Input::get('user'),'AND')->get();
Run Code Online (Sandbox Code Playgroud)

var_dump回报

object(Illuminate\Database\Eloquent\Collection)#333 (1) { ["items":protected]=> array(0) { } }
Run Code Online (Sandbox Code Playgroud)

当空时或结果数组(如果有).

如何测试对象isset

php arrays laravel eloquent

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

标签 统计

eloquent ×3

laravel-4 ×3

php ×3

laravel ×2

arrays ×1

database ×1

jekyll ×1

liquid ×1

loops ×1

orm ×1

phpunit ×1