por favor ayuda. Ya le hice los cambios a Laravel tales como:
/App/Providers/AppService.Provider.php
agregar lo siguiente:
public function boot()
{
Schema::defaultStringLength(191);
}
También realiza las siguientes modificaciones:
/config/database.php/
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix_indexes' => true,
Tengo instalado en Laragon: PHP 7.2.19 phpMyAdmin 4.8.5.... y al hacer esta migración me sigue saliendo el error
Schema::create('courses', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('teacher_id');
$table->foreign('teacher_id')->references('id')->on('teachers');
$table->unsignedInteger('category_id');
$table->foreign('category_id')->references('id')->on('categories');
$table->unsignedInteger('level_id');
$table->foreign('level_id')->references('id')->on('levels');
$table->string('name');
$table->text('description')->nullable();
$table->string('slug')->nullable();
$table->string('picture')->nullable();
$table->enum('status' , [
\App\courses::PUBLISHED,
\App\courses::PENDING,
\App\courses::REJECTED,
]);
$table->boolean('previus_approved')->default(false);
$table->boolean('previus_rejected')->default(false);
// $table->timestamps();
$table->softDeletes();
});
He hecho las pruebas y sin los siguientes datos puedo hacer la migración sin problemas, pero si los vuelvo activar me muestra el error 664
$table->unsignedInteger('category_id');
$table->foreign('category_id')->references('id')->on('categories');
$table->unsignedInteger('level_id');
$table->foreign('level_id')->references('id')->on('levels');
Amigos muchas graciaspor su gran ayuda....
Este es el error que me sale:
`Illuminate\Database\QueryException : SQLSTATE[HY000]:
General error: 1215 Cannot add foreign key constraint
(SQL: alter tablecourses
add constraint
courses_category_id_foreign
foreign key(
category_id)
referencescategories
(
id))
at
C:\laragon\www\plataforma\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error`
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {
664| throw new QueryException( 665| $query, $this->prepareBindings($bindings), $e 666| ); 667| }