22 lines
363 B
PHP
22 lines
363 B
PHP
<?php
|
|
|
|
namespace App\Models\Traits;
|
|
|
|
use App\Models\Category;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
trait BelongsToCategory
|
|
{
|
|
|
|
/**
|
|
* 关联分类表
|
|
* @author 玄尘 2020-03-05
|
|
* @return BelongsTo
|
|
*/
|
|
public function category(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Category::class)->withDefault();
|
|
}
|
|
|
|
}
|