【问题标题】:Laravel - How to know which models are related to a specific model?Laravel - 如何知道哪些模型与特定模型相关?
【发布时间】:2021-11-19 11:54:38
【问题描述】:

我想知道与我的表相关的模型。

有没有这样的方法?

        $model    = new $model;
        $table    = $model->getTable();
        $columns  = Schema::getColumnListing($table);

比如这样?

       $model->relationships()

提前谢谢你!

【问题讨论】:

标签: laravel eloquent relationship laravel-7


【解决方案1】:

开箱即用没有办法做到这一点,您必须想出自己的解决方案。你可以在这里试试这个:https://laracasts.com/discuss/channels/eloquent/get-all-model-relationships

【讨论】:

  • 哦,谢谢!它有效!
猜你喜欢
  • 2020-10-11
  • 1970-01-01
  • 2021-04-20
  • 1970-01-01
  • 2020-10-18
  • 2018-05-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多