ruslander-rulez/laravel-buisiness-logic-encapsulator

There is no license information available for the latest version (v1.0) of this package.

Encapsulating buisiness logic in Laravel projects

v1.0 2019-11-26 21:10 UTC

This package is not auto-updated.

Last update: 2024-09-26 19:11:58 UTC


README

This package is created for close business logic in the class. You can use closed business logic in different places of your project (views, controllers, jobs, tests etc.).

##Usage Install through composer

composer require  ruslander-rulez/laravel-buisiness-logic-encapsulator

Create new class

<?php
namespace Some\Namespace;

use  RuslanderRulez\Encapsulator\AbstractCommand;

class SomeName extents AbstractCommand
{
    private $input1;
    
    private $input2;

    private $someInjection;
    
    public function __construct($inputVariable1, $inputVariable2, SomeInjection $someInjection)
    {
        $this->input1 = $inputVariable1;
        $this->input2 = $inputVariable2;
        
        $this->someInjection = $someInjection;
    }
    
    public function handle()
    {
        /*
        SOME LOGIC
        */
    
        return $this->input1 === $this->input2;
    }
    /**
     * @retunn boolean
     **/
    public function executeFromParams($inputVariable1, $inputVariable2)
    {
        return self::execute(compact("inputVariable1", "inputVariable2"));
    }
}

Use created class in where your need

//some code here

$result  = SomeName::executeFromParams($value1, $value2);

//some code here

if ($result) {
    //some code here
}
    //some code here