0

I want to save data of books with the image URL also in the database. How to set default value URL links in the database? I've tried with string but it turned out to be an error too.

This is the data tables

public function up()
{
    Schema::create('perpuses', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('title');
        $table->string('author');
        $table->string('location');
        $table->string('publisher');
        $table->string('print_year');
        $table->unsignedBigInteger('user_id');
        $table->foreign('user_id')->references('id')->on('users');
        $table->string('image_URL'); // sdefault value?
        $table->timestamps();
    });
}

1 Answer 1

1

You can use default() method on your image_URL column like so

$table->string('image_URL')->default('your-default-link');

You can read more about Column Modifiers

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.