Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2024-06-14 (3 months ago) | Not yet rated by the users | Total: 29 | All time: 11,144 This week: 47 |
Version | License | PHP version | Categories | |||
strategy-pattern-exa 1.0 | MIT/X Consortium ... | 7 | Libraries, Design Patterns, PHP 7 |
Description | Author | |||||||||||||||||||||||
This package can add a competition strategy to model classes. Innovation Award |
|
It is the implementation of the backend of a competition management system, where the administrators can create different predefined competitions, and the backend logic and also the UI will differ from strategy to strategy.
The App\Models\Contest
has a strategy
property stored in the database, and set by the Administrators on contest creation,
which holds the key of the applied strategy. This adds the functionality and UI logic to the contest.
The relevant part of the Contest model is as follows:
<?php
namespace App\Models;
use App\Extensions\Contests\ContestStrategy;
use App\Extensions\Contests\ContestStrategyMap;
use Illuminate\Database\Eloquent\Model;
class Contest extends Model
{
public function getStrategy(): ContestStrategy
{
$map = ContestStrategyMap::create();
return $map->getStrategyForKey($this->strategy, $this);
}
}
The details of the functionalities of each of the strategy are stored in the App/Extensions/Contests/Strategies/*/Features
folders in various classes like ValidationRules
, ViewSection
, etc., and loaded through the code as follows:
$validationRules = $contest->getStrategy()->executeFeature('validation-rules');
// or
$contestViewSection = $contest->getStrategy()->executeFeature('view-section');
$listElement = $contestViewSection?->getSectionByKey('list-element', compact($product));
Also, the NoFeatureImplementedForStrategyException
it is handled in app/Exceptions/Handler.php
.
Files (12) |
File | Role | Description | ||
---|---|---|---|---|
Strategies (3 files, 2 directories) | ||||
AbstractContestStrategy.php | Class | Class source | ||
ContestStrategyMap.php | Class | Class source | ||
HasContestInterface.php | Class | Class source | ||
readme.md | Doc. | Documentation | ||
StrategyFeatureInterface.php | Class | Class source |
Files (12) | / | Strategies |
File | Role | Description | ||
---|---|---|---|---|
beverage (1 directory) | ||||
nektaria (1 directory) | ||||
AbstractStrategyFeature.php | Class | Class source | ||
Beverage.php | Class | Class source | ||
Nektaria.php | Class | Class source |
Files (12) | / | Strategies | / | beverage | / | Features |
File | Role | Description |
---|---|---|
ValidationRules.php | Class | Class source |
ViewSection.php | Class | Class source |
Files (12) | / | Strategies | / | nektaria | / | Features |
File | Role | Description |
---|---|---|
ValidationRules.php | Class | Class source |
ViewSection.php | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.