Salve galera, estou tendo esse erro quando clico no botão para excluir uma série, estava excluindo perfeitamente, mas após a implementação das temporadas e dos episódios no projeto consegui apagar umas 2 ou 3 séries e depois começou a aparecer esse erro...
Laravel v9
Migration series
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('series', function(Blueprint $table){
$table->increments('id');
$table -> string('nome');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('seies');
}
};
Migration temporadas
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('temporadas', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('numero');
$table->integer('serie_id');
$table->foreign('serie_id')->references('id')->on('series');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('temporadas');
}
};
Migration episodios
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('episodios', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('numero');
$table->integer('temporada_id');
$table->foreign('temporada_id')->references('id')->on('temporadas');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('episodios');
}
};
Obs:. o laravel criou os meus Models na pasta Providers
Model serie
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Serie extends Model
{
public $timestamps = false;
protected $fillable = ['nome'];
public function temporadas()
{
return $this->hasMany(Temporada::class);
}
}
Model temporada
<?php
namespace App;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Temporada extends Model
{
use HasFactory;
protected $fillable = ['numero'];
public $timestamps = false;
public function episodios()
{
return $this->hasMany(Episodio::class);
}
public function serie()
{
return $this->belongsTo(Serie::class);
}
}
Model episodio
<?php
namespace App;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Episodio extends Model
{
use HasFactory;
protected $fillable = ['numero'];
public $timestamps = false;
public function temporada()
{
return $this->belongsTo(Temporada::class);
}
}