本文整理汇总了PHP中Relationship::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Relationship::where方法的具体用法?PHP Relationship::where怎么用?PHP Relationship::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Relationship
的用法示例。
在下文中一共展示了Relationship::where方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: home_timeline
/**
* Returns a collection of the most recent Post by the authenticating user and the users they follow
* @return Response
*/
public function home_timeline($id)
{
//get all follower where user id = follower_id
$followers = Relationship::where('follower_id', $id)->get(array('following_id'));
if ($followers->count() > 0) {
$follower_id = array();
array_push($follower_id, $id);
foreach ($followers as $follower) {
array_push($follower_id, $follower->following_id);
}
return Post::getPost($follower_id, $this->page, $this->per_page, $this->type);
} else {
return Response::json(array('status' => '0', 'message' => 'No user found'));
}
}
示例2: friends_deprecated2
/**
* Display friends from given user id.
*
* @param int $id
* @return Response
*/
public function friends_deprecated2($id)
{
$followings = Relationship::where('follower_id', $id)->where('following_id', '!=', $id)->where('active', '=', '1')->get(array('following_id'));
$folllowings_id = array();
foreach ($followings as $following) {
array_push($folllowings_id, $following->following_id);
}
$accounts = Relationship::whereIn('following_id', $folllowings_id)->where('follower_id', '=', $id)->where('active', '=', '1')->take($this->per_page)->skip($this->ofset)->get();
$total_account = Relationship::whereIn('following_id', $folllowings_id)->where('follower_id', '=', $id)->count();
foreach ($accounts as $account) {
$account->following_account->birthday;
$account->following_account->gender;
$account->following_account->avatar;
$account->following_account->cover;
$account->following_account->is_following = Helpers::SK_isFollowing($account->following_account->id, $id);
array_push($this->users, $account->following_account);
}
$response = array('status' => '1', 'page' => $this->page, 'per_page' => $this->per_page, 'pages' => ceil(count($this->users) / $this->per_page), 'total' => count($this->users), 'users' => $this->users);
return Response::json($response);
}
示例3: scopeBlockRelationship
public function scopeBlockRelationship($quest, $sender, $target)
{
//check if relationship already exists
$results = DB::table('relationship')->select('*')->where('relationship_sender', '=', $target)->where('relationship_target', '=', $sender)->first();
// if it's pending from someone requesting, then change to active
if ($results) {
Relationship::where('relationship_id', '=', $results->relationship_id)->update(array('relationship_status' => 'block'));
}
$relationship = new Relationship();
$relationship->relationship_target = $target;
$relationship->relationship_sender = $sender;
$relationship->relationship_status = 'block';
$relationship->save();
}
示例4: getRelationshipList
/**
* Función responsable de obtener el listado de parentescos civiles
* disponibles para el país actual.
*
* @return array, lista de parentescos civiles encontrados.
*/
public function getRelationshipList($countryId = '')
{
if (empty($countryId)) {
$countryId = Config::get('constants.APP.COUNTRY_CODES.CO');
}
$relationshipList = Relationship::where('countryId', $countryId)->orderBy(Config::get('constants.RELATIONSHIP.ATTRS.RELATIONSHIP_ID'))->get();
return $relationshipList;
}