📜  laravel 有很多带有 id 的 PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:08.630000             🧑  作者: Mango

代码示例2
class Post extends Model
{
  public function comments()
  {
      return $this->hasMany(Comment::class, 'foreign_key', 'local_key');
 // local id is the main id Of post table such as : id
 // foreign id is the post table which is inside comment table such as: post_id
    //return $this->hasMany(Comment::class, 'post_id', 'id');  
    //return $this->hasMany(Comment::class, 'post_id'); 


  }
}