Ad
Laravel Error Add Photo_id To My Migration
i'm trying to add a photo to my scooter advertisement. but when i'm trying to migrate i get this error the whole time:
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'photo_id' doesn't exist in table (SQL: alter table `scooter` add constraint `scooter_photo_id_foreign` foreign key (`photo_id`) references `photo` (`id`))
i do not get what i'm doing wrong.
scooter migration class CreateScooterTable extends Migration {
public function up()
{
Schema::create('scooter', function (Blueprint $table) {
$table->bigIncrements('id');
$table->foreign('photo_id')->references('id')->on('photo');
$table->string("price");
$table->bigInteger("description");
$table->string("km");
$table->string("lincenseplatecolor");
$table->string("color");
$table->string("name");
$table->boolean("sold");
$table->string("motortype");
$table->string("brand");
$table->string("topspeed");
$table->string("contstructionYear");
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('scooter');
}
} photo migration:
class CreatePhotoTable extends Migration
{
public function up()
{
Schema::create('photo', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('src');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('photo');
}
}
i do not get what i'm doing wrong and love if you guys would know the awnser (:
Ad
Answer
The answer was that I had to change the time stamps in the filename. that way photo id existed when people wanted create a new relation.
Ad
source: stackoverflow.com
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms
Ad