Laravel 4 How to delete a resource with its files and records from the project

ぐ巨炮叔叔 提交于 2019-12-10 12:18:44

问题


I created a controller via the sublime text plugin. Generate resource -> Tweets But later on i wanted to get rid of it and all the files and records it had created on my project so i did the following:

  1. deleted:

    Tweetscontroller.php
    views/Tweets folder
    models/Tweets.php
    create_Tweets_table migration
    seeds/TweetsTableSeeder.php
    
  2. edited off the records in:

    route.php
    databaseseeder.php,
    
  3. run dump-autoload

But later when i run "php artisan migrate:refresh" i get the following error on my command line:

    {"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'CreateTweetsTable' not found","file":"C:\\xampp\\htdocs\\l4radiate\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Migrations\\Migrator.php","line":301}}

Please let me know how i can solve this or any easier way of getting rid of a whole resource.


回答1:


When creating migrations the name of the migration file gets saved in the migrations table in the database.

So the first time when you generated the files and run migrate the name of the migration file was saved in the table.

Afterwards when you deleted manually the files and ran migrate:refresh laravel tries to read each file that is recorded in the table, so in your case it doesn't find the migration file (CreateTweetsTable) and you get the error.

Try to delete manually the row (you should see the name of the tweets table migration) in the table and see if that fixes it for you.



来源:https://stackoverflow.com/questions/17278322/laravel-4-how-to-delete-a-resource-with-its-files-and-records-from-the-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!