企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
当前是BPost表模型: ``` <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use \App\Models\Model; class BPost extends Model { use HasFactory; protected $table = "b_posts"; /* * BPost表文章用户id对应的用户数据 */ public function bUser() { return $this->belongsTo('App\Models\BUser', 'b_user_id', 'id'); } /* * 当前文章的所有分类 */ public function categories() { return $this->belongsToMany(\App\Models\BPostCategory::class, 'b_post_category_relationships', 'b_post_id', 'b_category_id'); // return $this->belongsToMany(\App\Models\BPostCategory::class, 'b_post_category_relationships', 'b_post_id', 'b_category_id')->withPivot(['b_post_id', 'b_category_id']); } /* * 文章是否有分类 */ public function hascategory($category) { return $this->categories->contains($category); } } ```