0
When executing the command php Artisan migrate to create the table in the database, the error appears below:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Parse error: syntax error, unexpected '(', expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$'
It seems to be a syntax error, but I can not see where the error is, I have created other tables, including those that are foreign keys of this without any problem.
My Migration is like this:
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateConvServsTable extends Migration
{
public function up()
{
Schema::create('conv_servs', function (Blueprint $table) {
$table->increments('id');
$table->integer('id_convenio')->unsigned();
$table->integer('id_especialidade')->unsigned();
$table->foreign('id_convenio')->references('id')->('convenios')->onDelete('cascade');
$table->foreign('id_especialidade')->references('id')->('especialidades')->onDelete('cascade');
});
}
public function down()
{
Schema::dropIfExists('conv_servs');
}
}
According to Laravel’s documentation, that’s where the name of the table goes. I have created other tables with foreign keys and worked normally.
– Diego Vieira
Man, I can’t believe I forgot the ON before the table name. My old God. What a stupid mistake.
– Diego Vieira
@Diegovieira if it is programming believe we will always make stupid mistakes :) ... is like me with Portuguese, is a gaffe behind the other XD, can mark the answer as accepted?
– Guilherme Nascimento