PHP code example of bpartner / tasks

1. Go to this page and download the library: Download bpartner/tasks 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/ */

    

bpartner / tasks example snippets

 php
namespace App\Test;

use Bpartner\Tasks\Tasks;

class Task extends Tasks
{
     /**
     * @param \Illuminate\Support\Fluent $object        #for Laravel
     *
     * @return mixed
     */
    public function __invoke($object)
    {
        // TODO: Implement __invoke() method.
    }
}
 php
use Illuminate\Support\Fluent;
use Illuminate\Http\Request;

class Controller
{
    use CallableTrait;

    public function index(Request $request)
    {
        $data = new Fluent($request->all());

        return $this->run(\App\Test\Tasks::class, $data); 
    }
}
 php
namespace App\Test;

use Bpartner\Tasks\Tasks;
use Bpartner\Tasks\PipelineTaskTrait;

class Task extends Tasks
{
    use PipelineTaskTrait;

     /**
     * @param \Illuminate\Support\Fluent $object 
     *
     * @return mixed
     */
    public function __invoke($object)
    {
        // TODO: Implement __invoke() method.
    }

    /**
     * @param \Illuminate\Support\Fluent $content
     * @param \Closure                   $next
     *
     * @return mixed
     */
    public function handle(Fluent $content, Closure $next): Fluent
    {
        //Check or modify $content

        return $next($content);
    }

}

//----------------------------------------------

use Illuminate\Support\Fluent;
use Illuminate\Http\Request;

class Controller
{
    use CallableTrait;

    public function index(Request $request)
    {
        $data = new Fluent($request->all());
        $pipes = [
            \App\Test\Task::class,
            \App\Test\Task2::class
        ];

        return $this->runPipe($data, $pipes); 
    }
}