laravel before migration
Schema::table('users', function ($table) {
$table->string('email')->after('id')->nullable();
});
laravel before migration
Schema::table('users', function ($table) {
$table->string('email')->after('id')->nullable();
});
laravel run query after migration
//You should be able to add data to your new fields in your new migration. I'm not sure if it's the best way to go, but I've seen something like this before:
public function up()
{
Schema::table('my_table', function (Blueprint $table) {
$table->string('my_column')->nullable();
});
$this->updateData();
}
private function updateData()
{
$allCategories = Category::where('slug', null)->get();
foreach($allCategories as $singleCategory) {
$singleCategory->update([
'slug' => Category::makeSlug($singleCategory->name, $singleCategory->parent_id)
]);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us