PHP code example of drandin / closure-table-comments

1. Go to this page and download the library: Download drandin/closure-table-comments library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

drandin / closure-table-comments example snippets


 \Drandin\ClosureTableComments\ClosureTableServiceProvider::class,

  use Drandin\ClosureTableComments\ClosureTableService;
  use Drandin\ClosureTableComments\Commentator;

  $commentator = new Commentator(new ClosureTableService());

  $comment = "Отличная статья. Спасибо за полезный материал.";
    
  $id = $commentator
          ->setSubjectId(5636)
          ->addCommentToRoot($comment, 7);

   use Drandin\ClosureTableComments\ClosureTableService;
   use Drandin\ClosureTableComments\Commentator;
 
   $commentator = new Commentator(new ClosureTableService());
   
   $comment = "А вот и нет, в статье есть ошибки.";
   
   $id = $commentator
        ->setSubjectId(2332)
        ->replyToComment(1, $comment, 43);
 

   use Drandin\ClosureTableComments\ClosureTableService;
   use Drandin\ClosureTableComments\Commentator;
 
   $commentator = new Commentator(new ClosureTableService());
   
   $comment = "Отличная статья. Благодарю автора.";
   
   $res = $commentator->editComment(1, $comment);
 

   use Drandin\ClosureTableComments\ClosureTableService;
   use Drandin\ClosureTableComments\Commentator;
 
   $commentator = new Commentator(new ClosureTableService());
   
   $res = $commentator->has(2);
 

   use Drandin\ClosureTableComments\ClosureTableService;
   use Drandin\ClosureTableComments\Commentator;
 
   $commentator = new Commentator(new ClosureTableService());
   
   $node = $commentator->getNode(2);
 

   use Drandin\ClosureTableComments\ClosureTableService;
   use Drandin\ClosureTableComments\Commentator;
 
   $commentator = new Commentator(new ClosureTableService());
   
   $nodes = $commentator
                ->setSubjectId(5636)
                ->getTreeBranch();

   use Drandin\ClosureTableComments\ClosureTableService;
   use Drandin\ClosureTableComments\Commentator;
 
   $commentator = new Commentator(new ClosureTableService());
   
   $nodes = $commentator
                ->setSubjectId(5636)
                ->getTreeBranch(2);

   use Drandin\ClosureTableComments\ClosureTableService;
   use Drandin\ClosureTableComments\Commentator;
 
   $commentator = new Commentator(new ClosureTableService());
   
   $tree = $commentator
                ->setSubjectId(5636)
                ->getTreeBranchArray();

   use Drandin\ClosureTableComments\ClosureTableService;
   use Drandin\ClosureTableComments\Commentator;
 
   $commentator = new Commentator(new ClosureTableService());
   
   $ids = $commentator->getBranchIds(23);

   use Drandin\ClosureTableComments\ClosureTableService;
   use Drandin\ClosureTableComments\Commentator;
 
   $commentator = new Commentator(new ClosureTableService());
   
   $level = $commentator->getLevel(23);

   use Drandin\ClosureTableComments\ClosureTableService;
   use Drandin\ClosureTableComments\Commentator;
 
   $commentator = new Commentator(new ClosureTableService());
   
   $res = $commentator->delete(64);

 php artisan vendor:publish --tag=config

 php artisan config:cache

 php artisan migrate