Level 51
You can set default values for your table fields, such as:
$table->string('level')->default('novice');
But, I think what you're really looking for is database seeding:
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I would like to know if it's possible to create a database and also directly add content to that database? I have this to create my database:
class CreateIssueTypesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('issue_types', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('level');
$table->string('description');
$table->string('category');
$table->string('extendedComment');
$table->timestamps();
});
}
What I want is to run "php artisan migrate" and that the table IssueTypes is created with default values like id=1 name=test1...,id=2 name=test2...,... .
If it's possible where and how should I write the code for that?
Thank you.
Please or to participate in this conversation.