PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, April 13, 2022

[FIXED] how to fix "Method Illuminate\Database\Schema\Blueprint::id does not exist"

 April 13, 2022     laravel, laravel-5.8, migration     No comments   

Issue

When i use php artisan migrate , i get this error message "Method Illuminate\Database\Schema\Blueprint::id does not exist". Can someone help me out?

Here is my code:

<?php

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

class CreateGalleriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('galleries', function (Blueprint $table) {
            $table->id();
            $table->integer('gallery_folder_id')->index();
            $table->string('image');
            $table->string('image_thumbnail');
            $table->string('dimension');
            $table->integer('added_by')->index();
            $table->timestamps();
        });
    }

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

Solution

First of all it Depends on which version of laravel you are using. you can use $table->id(); from laravel 7.x or higher versions

OR

if you are using laravel 6.x or lower version you can use

$table->bigIncrements('id');


Answered By - dvijparekh
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing