Код: Выделить всё
public static function followAllUsers($user_data) {
$responce = array();
$data = array();
foreach ($user_data['following_id'] as $key => $value) {
$following = UserBussinessLogic::checkAndValidateUser($value);
if ($following != true) {
$responce = Utility::Responce('invalid_user', FALSE, $value);
break;
} else {
if (FriendBussinessLogic::isAlreadyFollowed($user_data['id'], $value)) {
continue;
}
$data[] = array('follower_id' => $user_data['id'], 'following_id' => $value, 'created_at' => date('Y-m-d H:i:s'));
$followData['notifyAbleUsers'][] = $value;
}
}
if ($following) {
if (!empty($data)) {
if (Friend::insert($data)) {
$followData['created_at'] = date('Y-m-d H:i:s');
$followData['follower_id'] = $user_data['id'];
$responce = Utility::Responce('friend_followed', TRUE, $followData);
} else {
$responce = Utility::Responce('general_error', FALSE);
}
} else {
$responce = Utility::Responce('already_followed', TRUE);
}
}
return $responce;
}
Подробнее здесь: https://stackoverflow.com/questions/438 ... in-laravel