asaadon
4 months ago
452
1
Laravel

can,t create new video

Posted 4 months ago by asaadon

when i try to create new video i show this error

SQLSTATE[HY000]: General error: 1364 Field 'META_KEYWORDS' doesn't have a default value (SQL: insert into vedieos (NAME, updated_at, created_at) values (ewew, 2020-03-05 00:10:58, 2020-03-05 00:10:58))

migration videos table

public function up() { Schema::create('vedieos', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('NAME'); $table->string('META_KEYWORDS'); $table->string('DESC'); $table->text('META_DESC'); $table->string('YOUTUBE'); $table->boolean('PUBLISHED')->default(1); $table->integer('USER_ID'); $table->integer('CAT_ID'); $table->string('IMAGE'); $table->timestamps(); }); }

videos model

class Vedieos extends Model { protected $table = "vedieos"; protected $fillable = [ 'NAME', 'META_KEYWORDS', 'DESC', 'META_DESC', 'YOUTUBE', 'PUBLISHED', 'USER_ID', 'CAT_ID', 'IMAGE' ]; }

viedeos controller

public function store(Request $request) { $this->validate($request, [ 'name' => 'required', // 'META_KEYWORDS' => 'max:191', // 'DESC' => 'required', // 'META_DESC' => 'max:191', // 'YOUTUBE' => 'required|url', // 'PUBLISHED' => 'required', // 'CAT_ID' => 'required|integer', ]);

        $userId = auth()->user()->id;
        $create = Vedieos::create(
            [
                'NAME' => $request->name,
                
            ]);

        return redirect()->route('Vedieos.index');


}

Please sign in or create an account to participate in this conversation.