love_php/app/Models/LinkingBlacklist.php

29 lines
690 B
PHP
Raw Normal View History

2026-04-02 09:20:51 +08:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Base;
class LinkingBlacklist extends Base
{
protected $fillable = [];
protected $guarded = [];
public function otherUser()
{
return $this->hasOne(User::class, 'id', 'other_user_id');
}
/**
* 获取我拉黑的用户和拉黑我的用户ids
* @param $user_id
* @return mixed
*/
public function getBlackIds($user_id)
{
$ids = self::where('user_id', $user_id)->pluck('other_user_id')->toArray();
$other_ids = self::where('other_user_id', $user_id)->pluck('user_id')->toArray();
return array_merge($ids, $other_ids);
}
}