'how to fix "Method Illuminate\Database\Schema\Blueprint::class does not exist."

When I use php artisan migrate I receive this message. Can someone help me with this? I searched on the Internet but I didn't find anything that helped me. (I am new in laravel)

my table:

<?php

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

class CreateServiceTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('service', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title');
            $table->string('description');
            $table->string('icon');
            $table->class('class');
            $table->timestamps();
        });
    }

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


Solution 1:[1]

$table->class('class'); class is not the datatype, use String, char or other datatypes according to your requirements. Use the below link for the datatypes reference in Laravel

Datatype reference

Solution 2:[2]

I ran into the same problem. Check the naming of your columns.

for me:

$table->name("name") instead of the right syntax which is

$table->string("name")

Into context: the above was because the referral was $table->class("class") instead of the right syntax $table->string("class")

enter image description here

Solution 3:[3]

I have notice that this error is due to qoutes ('') we have to write the code without qoutes For Example:

$table->string('name')->unique()->nullable('false');

This above method is false we have to write the code just like below remove qoutes from nullable function

$table->string('name')->unique()->nullable(false);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Akshat
Solution 2 RiveN
Solution 3 Ali Abbas