When you run the php artisan migrate command to create the table in the database, the following error appears:
[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 already created other tables, including those that are foreign keys of this one with no problem at all.
My migration looks 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');
}
}