私はモデルArticle、Filegroup、Fileを持っています。カラムが見つかりません:1054 'フィールドリスト'の 'image'が不明です
イメージを持つ新しい記事保存、それはこのエラーが表示されます。
{"exception":"Illuminate\Database\QueryException","message":"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'image' in 'field list' (SQL: insert into
articles
(title
,text
,like_count
,view_count
,comment_count
,image
,web_image
,updated_at
,created_at
) values (dsvdscdscdscsdcdsc, sacsaxasxsaxsaxsaxsaxsax, 0, 0, 0, 11, 13989, 2017-06-27 15:40:49, 2017-06-27 15:40:49))","trace":[{"file":"/var/www/laravel/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php","line":726,"function":"runQueryCallback","class":"Illuminate\Database\Connection","type":"->","args":["insert intoarticles
(title
,text
,like_count
,view_count
,comment_count
,image
,web_image
,updated_at
,created_at
) values (?, ?, ?, ?, ?, ?, ?, ?, ?)",..................
モデル/ Article.php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Article extends Model
{
protected $guarded = ['id'];
protected $with = ['image'];
public function image()
{
return $this->belongsTo('App\Models\Filegroup', 'image_id');
}
}
モデル/ FileGroup.php
use Illuminate\Database\Eloquent\Model;
class Filegroup extends Model
{
protected $table = 'file_groups';
protected $with = ['files', 'name'];
protected $guarded = ['id'];
/**
* One-to-Many relations with SiteString.
*
* @foreignModel SiteString
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function name()
{
return $this->belongsTo('App\Models\SiteString', 'name_id');
}
/**
* Many-to-Many relations with File.
*
* @foreignModel File
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function files()
{
return $this->hasMany('App\Models\File', 'filegroup_id');
}
}
移行して作成されたモデル/ file.php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class File extends Model
{
protected $table = 'files';
protected $fillable = [
'mimi_type',
'path',
'width',
'height',
'size'
];
/**
* One-to-Many inverse relations with Filegroup.
*
* @foreignModel Filegroup
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function group()
{
return $this->belongsTo('App\Models\Filegroup', 'filegroup_id');
}
}
テーブルの記事:
class CreateArticlesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('articles', function (Blueprint $table) {
$table->increments('id');
$table->integer('image_id');
$table->text('text');
$table->string('title');
$table->integer('like_count');
$table->integer('view_count');
$table->integer('comment_count');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('articles');
}
}
テーブル 'articles'に「image」列が存在するかどうか確認してください – ImAtWar
記事の移行に' image'と 'web_image'は存在しません – Nerea
記事列は記事テーブルの移行に存在しません –