How to delete a model using php artisan?

前端 未结 6 1564
Happy的楠姐
Happy的楠姐 2021-02-02 06:57

Is there a command to safely delete a model in Laravel 5? To create a model we use

php artisan make:model modelname

And that will create a mode

6条回答
  •  再見小時候
    2021-02-02 07:48

    No command, just do it manually and its safe

    1. Delete the model first (if you don't) need the model any longer
    2. Delete the migration from ...database/migrations folder
    3. If you have already migrated i.e if you have already run php artisan migrate, log into your phpmyadmin or SQL(whichever the case is) and in your database, delete the table created by the migration
    4. Still within your database, in the migrations folder, locate the row with that migration file name and delete the row.

    Works for me, hope it helps!

提交回复
热议问题