category() public method

Set Category and covert it, to the id if name of it given.
public category ( $category )
$category
Beispiel #1
0
 /** @test */
 function it_send_with_an_custom_sender()
 {
     $this->senders->extend('sendCustom', function ($notification, $app) {
         return new CustomDefaultSender($notification, $app->make('notifynder'));
     });
     $category_name = 'my.category';
     $this->createCategory(['name' => $category_name]);
     $singleNotification = $this->builder->category($category_name)->to(1)->from(2)->url('www.notifynder.io')->toArray();
     $this->senders->sendCustom($singleNotification);
     $this->assertCount(1, Notification::all());
 }
 /**
  * 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;
 }