Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我很困惑播种和在 laravel 中使用模型有什么区别,两者都将数据保存到数据库中。为什么不只使用Model?或为什么不种子?他们何时以及为何使用?
答案将不胜感激。
种子用于一次将静态或测试放入数据库。每次运行播种机时,您的数据表都会被截断并再次播种。
然而,模型是动态的,它们可以直接从表单、API 或文件等接收来自控制器的数据。
PS:您也可以使用文件、API 进行播种,但每次将新文件放入同一张表时,旧文件都会被截断