Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php artisan迁移已断开:未定义的属性_Php_Laravel_Laravel Artisan - Fatal编程技术网

Php artisan迁移已断开:未定义的属性

Php artisan迁移已断开:未定义的属性,php,laravel,laravel-artisan,Php,Laravel,Laravel Artisan,我在和一个破碎的工匠打交道。每次我运行任何migrate命令时,它都会显示: [ErrorException] Undefined property: Illuminate\Database\Query\Builder::$projects 无论我是否删除projects表和model,它都无法再次运行migrate命令。我已经在一个用户和一个项目之间建立了一种关系,一个用户可以有很多项目,自从引入这个关系以来,我的整个应用程序似乎都坏了。像Auth::check这样的东西也会出现同样

我在和一个破碎的工匠打交道。每次我运行任何migrate命令时,它都会显示:

  [ErrorException]
  Undefined property: Illuminate\Database\Query\Builder::$projects
无论我是否删除projects表和model,它都无法再次运行migrate命令。我已经在一个用户和一个项目之间建立了一种关系,一个用户可以有很多项目,自从引入这个关系以来,我的整个应用程序似乎都坏了。像Auth::check这样的东西也会出现同样的错误

项目模型:

class Projects extends Eloquent {
    public function user() {
        return $this->belongsTo("User");
    }

    public function android_app_entries() {
        return $this->hasMany("AndroidAppEntries");
    }
}
用户模型:

class User extends Eloquent implements UserInterface, RemindableInterface {

    use UserTrait, RemindableTrait;

    protected $table = 'users';

    public static $rules = array(
        'username'=>'required|between:6,18',
        'password'=>'required|between:6,18',
        'project_id'=>'required'
    );

    // Artist __has_many__ projects
    public function projects()
    {
        return $this->hasMany('Projects');
    }
项目迁移文件:

<?php

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

class CreateProjectsTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('projects', function($table) {
            $table->increments('id');
            $table->string('project_name');
            $table->string('client_name');
            $table->integer('users_id');
            $table->foreign('users_id')->references('id')->on('users');
            $table->timestamps();
        });



    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('projects');
    }
<?php

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

class CreateUsersTable extends Migration {

/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    Schema::create('users', function($table){
        $table->increments('id');
        $table->string('username');
        $table->string('password', 64);
        $table->string('role');
        $table->string('remember_token');
        $table->timestamps();
    });
}

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

最终,在回滚应用程序代码之后,我还从一个工作副本中回滚了供应商的laravel代码,这就成功了。奇怪的是,供应商目录可能会被破坏。

您还有其他迁移吗?或者你也跑的播种机?该错误意味着您在某个不具有该属性的对象上访问->项目。您可能认为这是您的模型,并尝试访问关系是的,我进行了一些其他迁移,但自从我添加了关系后,关系就中断了。与任何项目相关的种子也将被移除。最后,有趣的是,如果我在->项目上搜索整个项目,就不会有结果。。似乎是缓存问题或其他什么如果删除关系会怎么样?没有结果,删除了所有与项目有关的内容。看起来它的缓存速度非常快。真让我沮丧。因为我可能需要重新创建一个新的应用程序或其他东西..请查看您的日志app/storage/logs/laravel.log,看看是否可以从中找出错误的来源。。。
[2015-01-29 21:29:03] local.ERROR: exception 'ErrorException' with message 'Undefined property: Illuminate\Database\Query\Builder::$projects' in /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php:56
Stack trace:
#0 /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php(56): Illuminate\Exception\Handler->handleError(8, 'Undefined prope...', '/var/www/larave...', 56, Array)
#1 /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php(38): Illuminate\Database\Query\Grammars\Grammar->compileComponents(Object(Illuminate\Database\Query\Builder))
#2 /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php(34): Illuminate\Database\Query\Grammars\Grammar->compileSelect(Object(Illuminate\Database\Query\Builder))
#3 /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1234): Illuminate\Database\Query\Grammars\MySqlGrammar->compileSelect(Object(Illuminate\Database\Query\Builder))
#4 /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1359): Illuminate\Database\Query\Builder->toSql()
#5 /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1349): Illuminate\Database\Query\Builder->runSelect()
#6 /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1336): Illuminate\Database\Query\Builder->getFresh(Array)
#7 /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1771): Illuminate\Database\Query\Builder->get(Array)
#8 /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1731): Illuminate\Database\Query\Builder->aggregate('max', Array)
#9 /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php(105): Illuminate\Database\Query\Builder->max('batch')
#10 /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php(58): Illuminate\Database\Migrations\DatabaseMigrationRepository->getLastBatchNumber()
#11 /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(158): Illuminate\Database\Migrations\DatabaseMigrationRepository->getLast()
#12 /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/ResetCommand.php(61): Illuminate\Database\Migrations\Migrator->rollback(false)
#13 /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Console/Command.php(112): Illuminate\Database\Console\Migrations\ResetCommand->fire()
#14 /var/www/laravel-develop/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(252): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /var/www/laravel-develop/vendor/laravel/framework/src/Illuminate/Console/Command.php(100): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /var/www/laravel-develop/vendor/symfony/console/Symfony/Component/Console/Application.php(889): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/laravel-develop/vendor/symfony/console/Symfony/Component/Console/Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\ResetCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /var/www/laravel-develop/vendor/symfony/console/Symfony/Component/Console/Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /var/www/laravel-develop/artisan(59): Symfony\Component\Console\Application->run()
#20 {main} [] []