Example #1
0
 /**
  * Button Response from DataTable request to publish status.
  *
  * @param  \Yajra\CMS\Entities\Category $category
  * @return \Illuminate\Http\JsonResponse
  */
 public function publish(Category $category)
 {
     $category->togglePublishedState();
     $category->getDescendants()->each(function (Category $cat) use($category) {
         $cat->published = $category->published;
         $cat->save();
     });
     return $this->notifySuccess(sprintf('Category successfully %s!', $category->published ? 'published' : 'unpublished'));
 }