Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.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/11.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/9/java/319.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
梅莉很难像这样读。另外,请添加您遇到的错误或问题。非常感谢,但我删除了我的数据库,并使用其他名称重新创建了它,现在它显示“[Illumb\database\QueryException]SQLSTATE[HY000][1049]未知数据库“chatty”(_Database_Laravel_Database Connection_Laravel Facade - Fatal编程技术网

梅莉很难像这样读。另外,请添加您遇到的错误或问题。非常感谢,但我删除了我的数据库,并使用其他名称重新创建了它,现在它显示“[Illumb\database\QueryException]SQLSTATE[HY000][1049]未知数据库“chatty”(

梅莉很难像这样读。另外,请添加您遇到的错误或问题。非常感谢,但我删除了我的数据库,并使用其他名称重新创建了它,现在它显示“[Illumb\database\QueryException]SQLSTATE[HY000][1049]未知数据库“chatty”(,database,laravel,database-connection,laravel-facade,Database,Laravel,Database Connection,Laravel Facade,梅莉很难像这样读。另外,请添加您遇到的错误或问题。非常感谢,但我删除了我的数据库,并使用其他名称重新创建了它,现在它显示“[Illumb\database\QueryException]SQLSTATE[HY000][1049]未知数据库“chatty”(SQL:select*from information_schema.tables其中table_schema=chatty和table_name=migrations)[PDOException]SQLSTATE[HY000][1049]未知


梅莉很难像这样读。另外,请添加您遇到的错误或问题。非常感谢,但我删除了我的数据库,并使用其他名称重新创建了它,现在它显示“[Illumb\database\QueryException]SQLSTATE[HY000][1049]未知数据库“chatty”(SQL:select*from information_schema.tables其中table_schema=chatty和table_name=migrations)[PDOException]SQLSTATE[HY000][1049]未知数据库“chatty”(chatty是我以前的数据库)这可能是最好的单独问题,但您是否更改了
config/database.php
?没有,这是我的错误抱歉,我现在发现了错误,但回到我以前的问题,我尝试了您的评论,但它并不是工作类Post扩展迁移{use illumb\Database\Eloquent\Model;public function up(){Schema::create('Post',function(Blueprint$table){$table->increments('Post_id');$table->string('Post');$table->integer('time');$table->string('host');$table->integer('vote_up');$table->integer('vote_down'))$table->foreign('user_id')->references('id')->on('users');$table->timestamps();}公共函数down(){Schema::dropIfExists('post');}公共函数user(){return this->belongsTo('App\user');}请用代码更新您的问题,这样读起来非常困难。另外,请添加您遇到的错误或问题。
public function up()
{
    Schema::create('post', function (Blueprint $table) {
        $table->increments('post_id');
        $table->string('post');
        $table->integer('time');
        $table->string('host');
        $table->integer('vote_up');
        $table->integer('vote_down');
        $table->foreign('id_fk')->references('id')->on('users');
        $table->timestamps();
    });
}
public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->date('dob');
        $table->string('email')->unique();
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();
    });
}
$table->integer('user_id')->unsigned();
public function posts(){
return $this->hasMany(Post::class);
}
public function user(){
return $this->belongsTo(User::class);
}
$table->foreign('id_fk')->references('id')->on('users');
$table->foreign('user_id')->references('id')->on('users');
class Post extends Model
{
    /**
     * Get the user that owns the post.
     */
    public function user()
    {
        return $this->belongsTo('App\User');
        // if you want to keep your current structure:
        // return $this->belongsTo('App\User', 'id_fk', 'id);
    }
}
class User extends Model
{
    /**
     * Get the post for a user.
     */
    public function posts()
    {
        return $this->hasMany('App\Post');
        // if you want to keep your current structure:
        // return $this->belongsTo('App\Post', 'id_fk');
    }
}