29 lines
690 B
PHP
29 lines
690 B
PHP
|
|
<?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);
|
||
|
|
}
|
||
|
|
}
|