1

Heres my migration codes:

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
          Schema::create('orders', function (Blueprint $table){
          $table->increments('order_id');
          $table->integer('order_no');
          $table->string('total_price');
          $table->date('date_received');
          $table->date('date_expected');
          $table->integer('product_id')->unsigned();
          $table->foreign('product_id')->references('product_id')->on('product');
          $table->string('product_snumber');
          $table->integer('customer_name')
          $table->string('order_status');
          $table->timestamps();
          });
    }

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

But after I run 'php artisan migrate', the following error appears.

[Symfony\Component\Debug\Exception\FatalThrowableError]
Parse error: syntax error, unexpected '$table' (T_VARIABLE)

Please help! I am migrating to phpmyadmin database.

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43

5 Answers5

4

Yes @Bagus Tesa is right. (Just wanted to answer because I nearly missed the comment as it contains no answer) The missing semicolon ; could be the problem. Check all your modified migrations.

bishnub
  • 41
  • 1
  • 5
0

Check if into another migration has some char or something was lost there, In my case, I forgot a character in an old migration :(, after removed that worked for me!

José Bispo
  • 161
  • 1
  • 3
0

The error occurred for me when I cut and pasted a list of fields from another program, Freemind 1.0.1, into VS Code (the one before 1.47.1). Some pasted lines included leading spaces. VS Code continually showed the error until all the leading spaces were deleted and replaced with the usual tab key presses.

It was necessary to start deleting the leading spaces above the highlighted error line. The error highlight would then hop from line to line down the code till it disappeared.

Sometimes the error switched from unexpected '$table' to: unexpected ' '

Because the problem was in the leading spaces, it couldn't be seen, unlike the missing semicolon solution.

wightowl
  • 1
  • 1
0

semicolon is missing on this line $table->integer('customer_name') add semicolon $table->integer('customer_name');

0
$table->integer('customer_name')

missing semicolon ';'

meanwhile for avoiding these errors when your coding , you should use as such EA inspect codes plugins , usually smell check code and background inspect tools

dılo sürücü
  • 3,821
  • 1
  • 26
  • 28