Định nghĩa Inverse của quan hệ One To Many (ok)
https://viblo.asia/p/eloquent-relationships-in-laravel-phan-1-PdbGnoEdeyA
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Comment extends Model
{
/**
* Get the post that owns the comment.
*/
public function post()
{
return $this->belongsTo('App\Post');
}
}$comment = App\Comment::find(1);
echo $comment->post->title;Last updated