lbhurtado / tactician
Extending joselfonseca/laravel-tactician
Installs: 1 256
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ~7.2||^8.0.1
- illuminate/support: ^8.0||^9.0
- jagarsoft/laravel-tactician: ^1.0
- opis/events: @dev
Requires (Dev)
- orchestra/testbench: ^6.4
- phpunit/phpunit: ^9.3.3
README
This is just an extension of joselfonseca/laravel-tactician package implementing the ActionAbstract class.
Installation
You can install the package via composer:
composer require lbhurtado/tactician
Usage
use LBHurtado\Tactician\Classes\ActionAbstract; use LBHurtado\Tactician\Contracts\ActionInterface; class CreateSMSAction extends ActionAbstract implements ActionInterface { protected $fields = ['from', 'to', 'message']; protected $command = CreateSMSCommand::class; protected $handler = CreateSMSHandler::class; protected $middlewares = [ CreateSMSValidator::class, CreateSMSResponder::class, ]; public function setup() { // TODO: Implement setup() method. } }
use LBHurtado\Tactician\Contracts\CommandInterface; class CreateSMSCommand implements CommandInterface { public $from; public $to; public $message; public function __construct($from, $to, $message) { $this->from = $from; $this->to = $to; $this->message = $message; } public function getProperties():array { return [ 'from' => $this->from, 'to' => $this->to, 'message' => $this->message, ]; } }
use LBHurtado\Tactician\Contracts\CommandInterface; use LBHurtado\Tactician\Contracts\HandlerInterface; class CreateSMSHandler implements HandlerInterface { protected $smss; public function __construct(SMSRepository $smss) { $this->smss = $smss; } public function handle(CommandInterface $command) { $this->smss->create([ 'from' => $command->from, 'to' => $command->to, 'message' => $command->message, ]); } }
use League\Tactician\Middleware; class CreateSMSResponder implements Middleware { public function execute($command, callable $next) { $next($command); return (new CreateSMSResource($command)) ->response() ->setStatusCode(200) ; } }
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email lester@hurtado.ph instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.