예제 #1
0
 /**
  * Get Messages that are not linked to the Layout ID provided.
  *
  * @param  \Layout ID
  */
 public function getUnlinkedMessages($elementId)
 {
     //$unlinkedMessages = Message::all();
     //return $unlinkedMessages;
     //Find all elements related to a Layout
     $linkedMessages = ElementsController::getMessages($elementId);
     //Get the messages that are related to id
     $linkedMessagesId = $linkedMessages->lists('id');
     if (count($linkedMessagesId) == 0) {
         //If there is no related elements, return all available elements.
         return Message::all();
     } else {
         //If there is related elements, find the ones that are not related
         return Message::whereNotIn('id', $linkedMessagesId)->get();
     }
 }