public function broadcast($recipients = array())
	{
		// Get everyone subscribed
		$subscriptions = Subscription::all()
			->whereEquals('scope', $this->get('scope'))
			->whereEquals('scope_id', $this->get('scope_id'))
			->rows();

		foreach ($subscriptions as $subscription)
		{
			$recipients[] = array(
				'scope'    => 'user',
				'scope_id' => $subscription->get('user_id')
			);
		}

		$sent = array();

		// Do we have any recipients?
		foreach ($recipients as $receiver)
		{
			// Default to type 'user'
			if (!is_array($receiver))
			{
				$receiver = array(
					'scope'    => 'user',
					'scope_id' => $receiver
				);
			}

			// Make sure we have expected data
			if (!isset($receiver['scope'])
			 || !isset($receiver['scope_id']))
			{
				$receiver = array_values($receiver);

				$receiver['scope']    = $receiver[0];
				$receiver['scope_id'] = $receiver[1];
			}

			$key = $receiver['scope'] . '.' . $receiver['scope_id'];

			// No duplicate sendings
			if (in_array($key, $sent))
			{
				continue;
			}

			// Create a recipient object that ties a user to an activity
			$recipient = Recipient::blank()->set([
				'scope'    => $receiver['scope'],
				'scope_id' => $receiver['scope_id'],
				'log_id'   => $this->get('id'),
				'state'    => Recipient::STATE_PUBLISHED
			]);

			if (!$recipient->save())
			{
				return false;
			}

			$sent[] = $key;
		}

		return true;
	}
public function broadcast($recipients = array())
	{
		// Get everyone subscribed
		$subscriptions = Subscription::all()
			->whereEquals('scope', $this->get('scope'))
			->whereEquals('scope_id', $this->get('scope_id'))
			->rows();

		foreach ($subscriptions as $subscription)
		{
			$recipients[] = array(
				'scope'    => 'user',
				'scope_id' => $subscription->get('user_id')
			);
		}

		$sent = array();

		// Do we have any recipients?
		foreach ($recipients as $receiver)
		{
			// Default to type 'user'
			if (!is_array($receiver))
			{
				$receiver = array(
					'scope'    => 'user',
					'scope_id' => $receiver
				);
			}

			// Make sure we have expected data
			if (!isset($receiver['scope'])
			 || !isset($receiver['scope_id']))
			{
				$receiver = array_values($receiver);

				$receiver['scope']    = $receiver[0];
				$receiver['scope_id'] = $receiver[1];
			}

			$key = $receiver['scope'] . '.' . $receiver['scope_id'];

			// No duplicate sendings
			if (in_array($key, $sent))
			{
				continue;
			}

			// Create a recipient object that ties a user to an activity
			$recipient = Recipient::blank()->set([
				'scope'    => $receiver['scope'],
				'scope_id' => $receiver['scope_id'],
				'log_id'   => $this->get('id'),
				'state'    => Recipient::STATE_PUBLISHED
			]);

			if (!$recipient->save())
			{
				return false;
			}

			$sent[] = $key;
		}

		return true;
	}
public function broadcast ( $ recipients = array ( ) ) { // Get everyone subscribed $ subscriptions = Subscription :: all ( ) -> whereEquals ( 'scope' , $ this -> get ( 'scope' ) ) -> whereEquals ( 'scope_id' , $ this -> get ( 'scope_id' ) ) -> rows ( ) ; foreach ( $ subscriptions as $ subscription ) { $ recipients [ ] = array ( 'scope' => 'user' , 'scope_id' => $ subscription -> get ( 'user_id' ) ) ; } $ sent = array ( ) ; // Do we have any recipients? foreach ( $ recipients as $ receiver ) { // Default to type 'user' if ( ! is_array ( $ receiver ) ) { $ receiver = array ( 'scope' => 'user' , 'scope_id' => $ receiver ) ; } // Make sure we have expected data if ( ! isset ( $ receiver [ 'scope' ] ) || ! isset ( $ receiver [ 'scope_id' ] ) ) { $ receiver = array_values ( $ receiver ) ; $ receiver [ 'scope' ] = $ receiver [ 0 ] ; $ receiver [ 'scope_id' ] = $ receiver [ 1 ] ; } $ key = $ receiver [ 'scope' ] . '.' . $ receiver [ 'scope_id' ] ; // No duplicate sendings if ( in_array ( $ key , $ sent ) ) { continue ; } // Create a recipient object that ties a user to an activity $ recipient = Recipient :: blank ( ) -> set ( [ 'scope' => $ receiver [ 'scope' ] , 'scope_id' => $ receiver [ 'scope_id' ] , 'log_id' => $ this -> get ( 'id' ) , 'state' => Recipient :: STATE_PUBLISHED ] ) ; if ( ! $ recipient -> save ( ) ) { return false ; } $ sent [ ] = $ key ; } return true ; }
Send an activity to recipients

@param   array  $recipients
@return  bool
Send an activity to recipients