integer("post_id"); $table->string("body"); $table->timestamps(); }); } /** * Reverse the migrations" /> integer("post_id"); $table->string("body"); $table->timestamps(); }); } /** * Reverse the migrations" />

WHAT ARE THE MOST USED ARTISAN COMMANDS FOR MIGRATION IN LARAVEL?

I am working on a laravel project and each time I change my table (add or remove column) & run php artisan migrate:refresh. I get this error:

Can"t use method return value in write context

Solution tried:

run composer dump-autoload (Fails)Drop table in database, delete the migration file và restart again (works)

Previous migration file:

increments("id"); $table->integer("post_id"); $table->string("body"); $table->timestamps(); }); } /** * Reverse the migrations. * *
return void */ public function down() Schema::dropIfExists("comments"); }Changed migration file:

increments("id"); $table->integer("user_id"); $table->integer("post_id"); $table->string("body"); $table->timestamps(); }); } /** * Reverse the migrations. * *
return void */ public function down() Schema::dropIfExists("comments"); }I added the user_id in the change tệp tin in the up function


*

Trending sort Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

Bạn đang xem: What are the most used artisan commands for migration in laravel?

It falls back lớn sorting by highest score if no posts are trending.

Switch lớn Trending sort
Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first)
Try this command it works for me

php artisan migrate:freshHowever, be careful! This command will drop all data from your DB:

Note: The migrate:fresh command will drop all tables from the database và then execute the migrate command.

Xem thêm: Share Code Slideshow Ảnh Html, Share Code : Slide Show Phong Cách Iphone X

as per Laravel docs.


*

try this fire this command

php artisan make:migration add_user_id_to_comments_table --table=comments this will create a new migration tệp tin then

$table->integer("user_id")->after("id"); then use

php artisan migrate

*

*

Thanks for contributing an answer to Stack Overflow!

Please be sure to answer the question. Provide details & share your research!

But avoid

Asking for help, clarification, or responding to other answers.Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.


Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy & cookie policy


Not the answer you're looking for? Browse other questions tagged php laravel-5 laravel-5.5 or ask your own question.


*

Site kiến thiết / hình ảnh sản phẩm © 2022 Stack Exchange Inc; user contributions licensed under CC BY-SA. Rev2022.8.2.42721


Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device & disclose information in accordance with our Cookie Policy.