Eloquent 如何实现 LEFT OUTER JOIN 查询
请问一下如何用Eloquent实现LEFT OUTER JOIN查询:
Sql语句
SELECT A.id,A.name,B.name fatherName,A.add,A.code,A.`level` FROM FatherArticle A LEFT OUTER JOIN FatherArticle B ON A.fatherid=B.id
表结构迁移:
Schema::create('FatherArticle',function (Blueprint $table){
$table->uuid('id')->primary()->comment('文章分类ID');
$table->string('code','120')->comment('文章分类标示');
$table->string('name','225')->comment('文章分类名称');
$table->integer('level')->default('0')->comment('排序');
$table->integer('add')->comment('添加时间');
$table->string('fatherid')->comment('上级ID');\
$table->string('describe','')->nullable()->comment('分类描述');
});
请问大家如何实现的,刚用这套框架不久,之前看了“模型关联”不太明白原理,
推荐文章: