findByName() public method

Find a category by name.
public findByName ( $name ) : mixed
$name
return mixed
Ejemplo n.º 1
0
 /**
  * Send group notifications.
  *
  * @param  StoreNotification $sender
  * @return mixed
  */
 public function send(StoreNotification $sender)
 {
     // Get group
     $group = $this->notifynderGroup->findByName($this->nameGroup);
     // Categories
     $categoriesAssociated = $group->categories;
     // Send a notification for each category
     foreach ($categoriesAssociated as $category) {
         // Category name
         $categoryModel = $this->notifynderCategory->findByName($category->name);
         $notification = array_merge(['category_id' => $categoryModel->id], $this->info);
         $sender->storeSingle($notification);
     }
     return $group;
 }
Ejemplo n.º 2
0
 /**
  * Set Category and covert it, to the id
  * if name of it given
  *
  * @param $category
  * @return $this
  */
 public function category($category)
 {
     if (!is_numeric($category)) {
         $category = $this->notifynderCategory->findByName($category)->id;
     }
     $this->setBuilderData('category_id', $category);
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * Set the category of the
  * notification
  *
  * @param $name
  * @return $this
  */
 public function category($name)
 {
     // Check if the category is lazy loaded
     if ($this->isLazyLoaded($name)) {
         // Yes it is, split out the value from the array
         $this->defaultCategory = $this->getCategoriesContainer($name);
         // set category on the builder
         parent::category($this->defaultCategory->id);
         return $this;
     }
     // Otherwise ask to the db and give me the right category
     // associated with this name. If the category is not found
     // it throw CategoryNotFoundException
     $category = $this->notifynderCategory->findByName($name);
     $this->defaultCategory = $category;
     // Set the category on the array
     $this->setCategoriesContainer($name, $category);
     // set category on the builder
     parent::category($category->id);
     return $this;
 }