-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
initial commit
0 parents
commit 1defe28
Showing
33 changed files
with
22,650 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
charset = utf-8 | ||
end_of_line = lf | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.json] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.sh] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,yaml,js,ts,vue,blade.php,lua}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[docker-compose{,.*}.{yaml,yml}] | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = false | ||
|
||
[Dockerfile,Makefile] | ||
indent_style = tab | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
APP_NAME=Laravel | ||
APP_ENV=testing | ||
APP_KEY=AckfSECXIvnK5r28GVIWUAxmbBSjTsmF | ||
APP_DEBUG=true | ||
APP_URL=http://localhost | ||
|
||
DB_CONNECTION="sqlite" | ||
DB_DATABASE=":memory:" | ||
|
||
REDIS_HOST=localhost | ||
REDIS_PASSWORD=null | ||
REDIS_PORT=6379 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
APP_NAME=Laravel | ||
APP_ENV=testing | ||
APP_KEY=AckfSECXIvnK5r28GVIWUAxmbBSjTsmF | ||
APP_DEBUG=true | ||
APP_URL=http://localhost | ||
|
||
DB_CONNECTION="sqlite" | ||
DB_DATABASE=":memory:" | ||
|
||
REDIS_HOST=localhost | ||
REDIS_PASSWORD=null | ||
REDIS_PORT=6379 | ||
|
||
LUNAR_API_USE_HASHIDS=false | ||
|
||
PAYMENT_DRIVER=stripe | ||
|
||
STRIPE_PUBLIC_KEY=pk_test_ | ||
STRIPE_SECRET_KEY=sk_test_ | ||
STRIPE_WEBHOOK_SECRET=whsec_ | ||
|
||
#PayPal API Mode | ||
PAYPAL_MODE=sandbox | ||
|
||
#PayPal Setting & API Credentials - sandbox | ||
PAYPAL_SANDBOX_CLIENT_ID= | ||
PAYPAL_SANDBOX_CLIENT_SECRET= | ||
PAYPAL_RETURN_URL="http://localhost:8000/paypal/return" | ||
PAYPAL_CANCEL_URL="http://localhost:8000/paypal/cancel" | ||
PAYPAL_WEBHOOK_ID= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Fix PHP code style issues | ||
|
||
on: | ||
push: | ||
paths: | ||
- "**.php" | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
php-code-styling: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
|
||
- name: Fix PHP code style issues | ||
uses: aglipanci/[email protected] | ||
|
||
- name: Commit changes | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Fix styling |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
php: [8.2] | ||
laravel: [10] | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup PHP, with composer and extensions | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, redis, bcmath | ||
tools: composer:v2 | ||
coverage: none | ||
ini-values: error_reporting=E_ALL | ||
|
||
- name: Set Laravel Version | ||
run: composer require "laravel/framework:^${{ matrix.laravel }}" --no-update | ||
|
||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
|
||
- name: Cache composer dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} | ||
restore-keys: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer- | ||
|
||
- name: Install dependencies | ||
uses: nick-fields/retry@v2 | ||
with: | ||
timeout_minutes: 5 | ||
max_attempts: 5 | ||
command: composer update --prefer-dist --no-interaction --no-progress | ||
|
||
- name: Execute tests | ||
run: composer test | ||
|
||
# - name: Execute tests with hashids turned on | ||
# run: composer test-hashids |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/legacy | ||
/vendor | ||
composer.phar | ||
.DS_Store | ||
/.idea | ||
.phpunit.result.cache | ||
.php-cs-fixer.cache | ||
/node_modules | ||
Session.vim | ||
phpstan.neon | ||
ray.php | ||
_ide_helper.php | ||
.phpactor.json | ||
.env.testing | ||
.lando.yml | ||
/.vscode/launch.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<?php | ||
|
||
$rules = [ | ||
'@PSR2' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'array_indentation' => true, | ||
'binary_operator_spaces' => [ | ||
'default' => 'single_space', | ||
], | ||
'blank_line_after_namespace' => true, | ||
'blank_line_after_opening_tag' => true, | ||
'blank_line_before_statement' => [ | ||
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], | ||
], | ||
'braces' => true, | ||
'cast_spaces' => true, | ||
'class_definition' => true, | ||
'concat_space' => [ | ||
'spacing' => 'none', | ||
], | ||
'declare_equal_normalize' => true, | ||
'elseif' => true, | ||
'encoding' => true, | ||
'full_opening_tag' => true, | ||
'fully_qualified_strict_types' => true, // added by Shift | ||
'function_declaration' => true, | ||
'function_typehint_space' => true, | ||
'heredoc_to_nowdoc' => true, | ||
'include' => true, | ||
'increment_style' => ['style' => 'post'], | ||
'indentation_type' => true, | ||
'linebreak_after_opening_tag' => true, | ||
'line_ending' => true, | ||
'magic_constant_casing' => true, | ||
'method_argument_space' => true, | ||
'native_function_casing' => true, | ||
'no_alias_functions' => true, | ||
'no_extra_blank_lines' => [ | ||
'tokens' => [ | ||
'extra', | ||
'throw', | ||
'use', | ||
'use_trait', | ||
], | ||
], | ||
'no_blank_lines_after_class_opening' => true, | ||
'no_blank_lines_after_phpdoc' => true, | ||
'no_closing_tag' => true, | ||
'no_empty_phpdoc' => true, | ||
'no_empty_statement' => true, | ||
'no_leading_import_slash' => true, | ||
'no_leading_namespace_whitespace' => true, | ||
'no_mixed_echo_print' => [ | ||
'use' => 'echo', | ||
], | ||
'no_multiline_whitespace_around_double_arrow' => true, | ||
'multiline_whitespace_before_semicolons' => [ | ||
'strategy' => 'no_multi_line', | ||
], | ||
'no_short_bool_cast' => true, | ||
'no_singleline_whitespace_before_semicolons' => true, | ||
'no_spaces_after_function_name' => true, | ||
'no_spaces_around_offset' => true, | ||
'no_spaces_inside_parenthesis' => true, | ||
'no_trailing_comma_in_list_call' => true, | ||
'no_trailing_comma_in_singleline_array' => true, | ||
'no_trailing_whitespace' => true, | ||
'no_trailing_whitespace_in_comment' => true, | ||
'no_unneeded_control_parentheses' => true, | ||
'no_unreachable_default_argument_value' => true, | ||
'no_unused_imports' => true, | ||
'no_useless_return' => true, | ||
'no_whitespace_before_comma_in_array' => true, | ||
'no_whitespace_in_blank_line' => true, | ||
'normalize_index_brace' => true, | ||
'not_operator_with_successor_space' => true, | ||
'object_operator_without_whitespace' => true, | ||
'ordered_imports' => ['sort_algorithm' => 'alpha'], | ||
'phpdoc_indent' => true, | ||
'phpdoc_no_access' => true, | ||
'phpdoc_no_package' => true, | ||
'phpdoc_no_useless_inheritdoc' => true, | ||
'phpdoc_scalar' => true, | ||
'phpdoc_single_line_var_spacing' => true, | ||
'phpdoc_summary' => true, | ||
'phpdoc_trim' => true, | ||
'phpdoc_types' => true, | ||
'phpdoc_var_without_name' => true, | ||
'psr_autoloading' => true, | ||
'self_accessor' => true, | ||
'short_scalar_cast' => true, | ||
'simplified_null_return' => true, | ||
'single_blank_line_at_eof' => true, | ||
'single_blank_line_before_namespace' => true, | ||
'single_class_element_per_statement' => true, | ||
'single_import_per_statement' => true, | ||
'single_line_after_imports' => true, | ||
'single_line_comment_style' => [ | ||
'comment_types' => ['hash'], | ||
], | ||
'single_quote' => true, | ||
'single_trait_insert_per_statement' => true, | ||
'space_after_semicolon' => true, | ||
'standardize_not_equals' => true, | ||
'switch_case_semicolon_to_colon' => true, | ||
'switch_case_space' => true, | ||
'ternary_operator_spaces' => true, | ||
'trailing_comma_in_multiline' => true, | ||
'trim_array_spaces' => true, | ||
'unary_operator_spaces' => true, | ||
'visibility_required' => [ | ||
'elements' => ['method', 'property'], | ||
], | ||
'whitespace_after_comma_in_array' => true, | ||
]; | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->notPath('bootstrap') | ||
->notPath('storage') | ||
->notPath('vendor') | ||
->in(getcwd()) | ||
->name('*.php') | ||
->notName('*.blade.php') | ||
->notName('index.php') | ||
->notName('server.php') | ||
->ignoreDotFiles(true) | ||
->ignoreVCS(true); | ||
|
||
$config = new PhpCsFixer\Config(); | ||
|
||
return $config | ||
->setFinder($finder) | ||
->setRules($rules) | ||
->setRiskyAllowed(true) | ||
->setUsingCache(true); | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Changelog | ||
|
||
## 0.8.1 | ||
|
||
## 0.8.0 | ||
|
||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Contributing | ||
|
||
Contributions are **welcome** and will be fully **credited**. | ||
|
||
Please read and understand the contribution guide before creating an issue or pull request. | ||
|
||
## Etiquette | ||
|
||
This project is open source, and as such, the maintainers give their free time to build and maintain the source code | ||
held within. They make the code freely available in the hope that it will be of use to other developers. It would be | ||
extremely unfair for them to suffer abuse or anger for their hard work. | ||
|
||
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the | ||
world that developers are civilized and selfless people. | ||
|
||
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient | ||
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. | ||
|
||
## Viability | ||
|
||
When requesting or submitting new features, first consider whether it might be useful to others. Open | ||
source projects are used by many developers, who may have entirely different needs to your own. Think about | ||
whether or not your feature is likely to be used by other users of the project. | ||
|
||
## Procedure | ||
|
||
Before filing an issue: | ||
|
||
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. | ||
- Check to make sure your feature suggestion isn't already present within the project. | ||
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. | ||
- Check the pull requests tab to ensure that the feature isn't already in progress. | ||
|
||
Before submitting a pull request: | ||
|
||
- Check the codebase to ensure that your feature doesn't already exist. | ||
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. | ||
|
||
## Requirements | ||
|
||
If the project maintainer has any additional requirements, you will find them listed here. | ||
|
||
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). | ||
|
||
- **Add tests!** - Your patch won't be accepted if it doesn't have tests. | ||
|
||
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. | ||
|
||
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. | ||
|
||
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. | ||
|
||
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. | ||
|
||
**Happy coding**! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) Jakub Theimer | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Lunar Rewards | ||
|
||
[](https://packagist.org/packages/dystcz/lunar-api) | ||
[](https://packagist.org/packages/dystcz/lunar-api) | ||
 | ||
|
||
## What's going on here? | ||
|
||
This is a reward system package for [Lunar](https://github.com/lunarphp/lunar) | ||
which allows your users to earn points for their purchases and redeem them for discounts. | ||
|
||
## Getting started guide | ||
|
||
### Requirements | ||
|
||
- PHP ^8.2 | ||
- Laravel 10 | ||
- [Lunar requirements](https://docs.lunarphp.io/core/installation.html#server-requirements) | ||
|
||
### Installation | ||
|
||
You can install the package via composer | ||
|
||
```bash | ||
composer require dystcz/lunar-rewards | ||
``` | ||
|
||
Publish config files | ||
|
||
> You will probably need them pretty bad | ||
```bash | ||
php artisan vendor:publish --provider="Dystcz\LunarRewards\LunarRewardsServiceProvider" --tag="lunar-rewards" | ||
``` | ||
|
||
Publish migrations | ||
|
||
> Only in case you want to customize the database schema | ||
```bash | ||
php artisan vendor:publish --provider="Dystcz\LunarRewards\LunarRewardsServiceProvider" --tag="lunar-rewards.migrations" | ||
``` | ||
|
||
### Testing | ||
|
||
```bash | ||
composer test | ||
``` | ||
|
||
### Compatible packages | ||
|
||
- [Lunar API](https://github.com/dystcz/lunar-api) (JSON:API layer for Lunar) | ||
|
||
### Changelog | ||
|
||
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details. | ||
|
||
### Security | ||
|
||
If you discover any security related issues, please email dev@dy.st instead of using the issue tracker. | ||
|
||
## Credits | ||
|
||
- [All Contributors](../../contributors) | ||
- [Lunar](https://github.com/lunarphp/lunar) for providing awesome e-commerce package | ||
- [Laravel JSON:API](https://github.com/laravel-json-api/laravel) | ||
which is a brilliant JSON:API layer for Laravel applications | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"name": "dystcz/lunar-rewards", | ||
"description": "Reward system for Laravel applications using Lunar", | ||
"version": "0.8.0", | ||
"keywords": [ | ||
"dystcz", | ||
"lunar", | ||
"lunar-api", | ||
"rewards", | ||
"points", | ||
"laravel", | ||
"php" | ||
], | ||
"homepage": "https://github.com/dystcz/lunar-rewards", | ||
"license": "MIT", | ||
"type": "library", | ||
"authors": [ | ||
{ | ||
"name": "Jakub Theimer", | ||
"email": "jakub@dy.st", | ||
"role": "Maintainer" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.2", | ||
"illuminate/support": "^10.0", | ||
"lunarphp/lunar": "^0.8" | ||
}, | ||
"suggest": { | ||
"dystcz/lunar-api": "For working with Lunar API" | ||
}, | ||
"require-dev": { | ||
"barryvdh/laravel-ide-helper": "^2.13", | ||
"laravel-json-api/testing": "^2.1", | ||
"laravel/pint": "^1.7", | ||
"dystcz/lunar-api": "^0.8", | ||
"orchestra/testbench": "^8.0", | ||
"pestphp/pest": "^2.0", | ||
"pestphp/pest-plugin-laravel": "^2.0", | ||
"rector/rector": "^0.15.23", | ||
"driftingly/rector-laravel": "^0.17.0", | ||
"spatie/laravel-ray": "^1.32" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Dystcz\\LunarRewards\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Dystcz\\LunarRewards\\Tests\\": "tests" | ||
} | ||
}, | ||
"scripts": { | ||
"post-autoload-dump": "@composer run prepare", | ||
"clear": "@php vendor/bin/testbench package:purge --ansi", | ||
"prepare": "@php vendor/bin/testbench package:discover --ansi", | ||
"test": "vendor/bin/pest", | ||
"test-hashids": "vendor/bin/pest -c phpunit.hashids.xml", | ||
"test-coverage": "vendor/bin/pest --coverage", | ||
"analyse": "vendor/bin/phpstan analyse", | ||
"format": "vendor/bin/pint" | ||
}, | ||
"config": { | ||
"sort-packages": true, | ||
"allow-plugins": { | ||
"pestphp/pest-plugin": true | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Dystcz\\LunarRewards\\LunarRewardsServiceProvider" | ||
], | ||
"aliases": { | ||
"LunarRewards": "Dystcz\\LunarRewards\\Facade\\LunarRewards" | ||
} | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
return [ | ||
// | ||
]; |
43 changes: 43 additions & 0 deletions
43
...ase/migrations/2024_03_25_174556_add_payment_option_fields_to_orders_and_carts_tables.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Config; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
// Orders | ||
Schema::table(Config::get('lunar.database.table_prefix').'orders', function (Blueprint $table) { | ||
$table->json('payment_breakdown')->nullable()->after('shipping_total'); | ||
$table->integer('payment_total')->default(0)->unsigned()->index()->after('payment_breakdown'); | ||
}); | ||
|
||
// Carts | ||
Schema::table(Config::get('lunar.database.table_prefix').'carts', function (Blueprint $table) { | ||
$table->string('payment_option')->nullable()->index()->after('order_id'); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
// Orders | ||
Schema::table(Config::get('lunar.database.table_prefix').'orders', function (Blueprint $table) { | ||
$table->dropColumn('payment_breakdown'); | ||
$table->dropColumn('payment_total'); | ||
}); | ||
|
||
// Carts | ||
Schema::table(Config::get('lunar.database.table_prefix').'carts', function (Blueprint $table) { | ||
$table->dropColumn('payment_option'); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
'addresses' => [ | ||
'company_in' => [ | ||
'string' => 'IČO společnosti musí být řetězec.', | ||
], | ||
'company_tin' => [ | ||
'string' => 'Pole DIČ společnosti musí být řetězec.', | ||
], | ||
'line_one' => [ | ||
'required' => 'Pole první řádek je povinné.', | ||
'string' => 'Pole první řádek musí být řetězec.', | ||
], | ||
'line_two' => [ | ||
'string' => 'Pole druhý řádek musí být řetězec.', | ||
], | ||
'line_three' => [ | ||
'string' => 'Pole třetí řádek musí být řetězec.', | ||
], | ||
'city' => [ | ||
'required' => 'Pole město je povinné.', | ||
'string' => 'Pole město musí být řetězec.', | ||
], | ||
'state' => [ | ||
'string' => 'Pole stát musí být řetězec.', | ||
], | ||
'postcode' => [ | ||
'required' => 'Pole PSČ je povinné.', | ||
'string' => 'Pole PSČ musí být řetězec.', | ||
], | ||
'delivery_instructions' => [ | ||
'string' => 'Pole instrukce pro doručení musí být řetězec.', | ||
], | ||
'contact_email' => [ | ||
'string' => 'Pole kontaktní e-mail musí být řetězec.', | ||
], | ||
'contact_phone' => [ | ||
'string' => 'Pole kontaktní telefon musí být řetězec.', | ||
], | ||
'shipping_default' => [ | ||
'boolean' => 'Pole výchozí doručení musí být logická hodnota.', | ||
], | ||
'billing_default' => [ | ||
'boolean' => 'Pole výchozí fakturace musí být logická hodnota.', | ||
], | ||
'meta' => [ | ||
'array' => 'Pole meta musí být pole.', | ||
], | ||
], | ||
|
||
'carts' => [ | ||
'create_user' => [ | ||
'boolean' => 'Pole vytvořit uživatele musí být logická hodnota.', | ||
], | ||
'meta' => [ | ||
'array' => 'Pole meta musí být pole.', | ||
], | ||
'coupon_code' => [ | ||
'required' => 'Pole kód kupónu je povinné.', | ||
'string' => 'Pole kód kupónu musí být řetězec.', | ||
'invalid' => 'Kupón není platný nebo byl použit příliš mnohokrát.', | ||
], | ||
'agree' => [ | ||
'accepted' => 'Musíte souhlasit s obchodními podmínkami.', | ||
], | ||
'shipping_option' => [ | ||
'required' => 'Prosím vyberte možnost doručení.', | ||
], | ||
], | ||
|
||
'cart_addresses' => [ | ||
'title' => [ | ||
'string' => 'Pole titul musí být řetězec.', | ||
], | ||
'first_name' => [ | ||
'required' => 'Pole jméno je povinné.', | ||
'string' => 'Pole jméno musí být řetězec.', | ||
], | ||
'last_name' => [ | ||
'required' => 'Pole příjmení je povinné.', | ||
'string' => 'Pole příjmení musí být řetězec.', | ||
], | ||
'company_name' => [ | ||
'string' => 'Pole název společnosti musí být řetězec.', | ||
], | ||
'company_in' => [ | ||
'string' => 'Pole IČO společnosti musí být řetězec.', | ||
], | ||
'company_tin' => [ | ||
'string' => 'Pole DIČ společnosti musí být řetězec.', | ||
], | ||
'line_one' => [ | ||
'required' => 'Pole první řádek je povinné.', | ||
'string' => 'Pole první řádek musí být řetězec.', | ||
], | ||
'line_two' => [ | ||
'string' => 'Pole druhý řádek musí být řetězec.', | ||
], | ||
'line_three' => [ | ||
'string' => 'Pole třetí řádek musí být řetězec.', | ||
], | ||
'city' => [ | ||
'required' => 'Pole město je povinné.', | ||
'string' => 'Pole město musí být řetězec.', | ||
], | ||
'state' => [ | ||
'string' => 'Pole stát musí být řetězec.', | ||
], | ||
'postcode' => [ | ||
'required' => 'Pole PSČ je povinné.', | ||
'string' => 'Pole PSČ musí být řetězec.', | ||
], | ||
'delivery_instructions' => [ | ||
'string' => 'Pole instrukce pro doručení musí být řetězec.', | ||
], | ||
'contact_email' => [ | ||
'string' => 'Pole kontaktní e-mail musí být řetězec.', | ||
], | ||
'contact_phone' => [ | ||
'string' => 'Pole kontaktní telefon musí být řetězec.', | ||
], | ||
'shipping_option' => [ | ||
'string' => 'Pole možnost doručení musí být řetězec.', | ||
], | ||
'address_type' => [ | ||
'required' => 'Pole typ adresy je povinné.', | ||
'string' => 'Pole typ adresy musí být řetězec.', | ||
'in' => 'Pole typ adresy musí být jedno z: :values.', | ||
], | ||
], | ||
|
||
'cart_lines' => [ | ||
'quantity' => [ | ||
'integer' => 'Pole množství musí být celé číslo.', | ||
], | ||
'purchasable_id' => [ | ||
'required' => 'Pole ID položky je povinné.', | ||
'integer' => 'Pole ID položky musí být celé číslo.', | ||
], | ||
'purchasable_type' => [ | ||
'required' => 'Pole typ položky je povinné.', | ||
'string' => 'Pole typ položky musí být řetězec.', | ||
], | ||
'meta' => [ | ||
'array' => 'Pole meta musí být pole.', | ||
], | ||
], | ||
|
||
'customers' => [ | ||
'title' => [ | ||
'string' => 'Pole titul musí být řetězec.', | ||
], | ||
'first_name' => [ | ||
'string' => 'Pole jméno musí být řetězec.', | ||
], | ||
'last_name' => [ | ||
'string' => 'Pole příjmení musí být řetězec.', | ||
], | ||
'company_name' => [ | ||
'string' => 'Pole název společnosti musí být řetězec.', | ||
], | ||
'vat_no' => [ | ||
'string' => 'DIČ společnosti musí být řetězec.', | ||
], | ||
'account_ref' => [ | ||
'string' => 'IČO společnosti musí být řetězec.', | ||
], | ||
], | ||
|
||
'orders' => [ | ||
'notes' => [ | ||
'string' => 'Pole poznámky musí být řetězec.', | ||
], | ||
], | ||
|
||
'payments' => [ | ||
'payment_method' => [ | ||
'required' => 'Pole způsob platby je povinné.', | ||
'string' => 'Pole způsob platby musí být řetězec.', | ||
'in' => 'Pole způsob platby musí být jedno z: :types.', | ||
], | ||
'amount' => [ | ||
'numeric' => 'Pole částka musí být číslo.', | ||
], | ||
'meta' => [ | ||
'array' => 'Pole meta musí být pole.', | ||
], | ||
], | ||
|
||
'shipping' => [ | ||
'set_shipping_option' => [ | ||
'shipping_option' => [ | ||
'required' => 'Prosím vyberte možnost doručení.', | ||
'string' => 'Pole možnost doručení musí být řetězec.', | ||
], | ||
], | ||
], | ||
|
||
'payments' => [ | ||
'set_payment_option' => [ | ||
'payment_option' => [ | ||
'required' => 'Prosím vyberte platební metodu.', | ||
'string' => 'Pole platební metoda musí být řetězec.', | ||
], | ||
], | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
'auth' => [ | ||
'email' => [ | ||
'required' => 'Please enter your email address.', | ||
'email' => 'Please enter a valid email address.', | ||
'unique' => 'This email address is already in use.', | ||
'max' => 'Your email address must be less than :max characters long.', | ||
], | ||
|
||
'password' => [ | ||
'required' => 'Please enter a password.', | ||
'min' => 'Your password must be at least :min characters long.', | ||
'confirmed' => 'Please confirm your password.', | ||
], | ||
], | ||
|
||
'addresses' => [ | ||
'company_in' => [ | ||
'string' => 'Company ID must be a string.', | ||
], | ||
'company_tin' => [ | ||
'string' => 'Company tax ID field must be a string.', | ||
], | ||
'line_one' => [ | ||
'required' => 'Line one field is required.', | ||
'string' => 'Line one field must be a string.', | ||
], | ||
'line_two' => [ | ||
'string' => 'Line two field must be a string.', | ||
], | ||
'line_three' => [ | ||
'string' => 'Line three field must be a string.', | ||
], | ||
'city' => [ | ||
'required' => 'City field is required.', | ||
'string' => 'City field must be a string.', | ||
], | ||
'state' => [ | ||
'string' => 'State field must be a string.', | ||
], | ||
'postcode' => [ | ||
'required' => 'Postcode field is required.', | ||
'string' => 'Postcode field must be a string.', | ||
], | ||
'delivery_instructions' => [ | ||
'string' => 'Delivery instructions field must be a string.', | ||
], | ||
'contact_email' => [ | ||
'string' => 'Contact email field must be a string.', | ||
], | ||
'contact_phone' => [ | ||
'string' => 'Contact phone field must be a string.', | ||
], | ||
'shipping_default' => [ | ||
'boolean' => 'Shipping default field must be a boolean.', | ||
], | ||
'billing_default' => [ | ||
'boolean' => 'Billing default field must be a boolean.', | ||
], | ||
'meta' => [ | ||
'array' => 'Meta field must be an array.', | ||
], | ||
], | ||
|
||
'carts' => [ | ||
'create_user' => [ | ||
'boolean' => 'Create user field must be a boolean.', | ||
], | ||
'meta' => [ | ||
'array' => 'Meta field must be an array.', | ||
], | ||
'coupon_code' => [ | ||
'required' => 'Coupon code field is required.', | ||
'string' => 'Coupon code field must be a string.', | ||
'invalid' => 'The coupon is not valid or has been used too many times', | ||
], | ||
'agree' => [ | ||
'accepted' => 'You must agree to the terms and conditions.', | ||
], | ||
'shipping_option' => [ | ||
'required' => 'Please select a shipping option.', | ||
], | ||
'payment_option' => [ | ||
'required' => 'Please select a payment option.', | ||
], | ||
], | ||
|
||
'cart_addresses' => [ | ||
'title' => [ | ||
'string' => 'Title field must be a string.', | ||
], | ||
'first_name' => [ | ||
'required' => 'First name field is required.', | ||
'string' => 'First name field must be a string.', | ||
], | ||
'last_name' => [ | ||
'required' => 'Last name field is required.', | ||
'string' => 'Last name field must be a string.', | ||
], | ||
'company_name' => [ | ||
'string' => 'Company name field must be a string.', | ||
], | ||
'company_in' => [ | ||
'string' => 'Company in field must be a string.', | ||
], | ||
'company_tin' => [ | ||
'string' => 'Company tin field must be a string.', | ||
], | ||
'line_one' => [ | ||
'required' => 'Line one field is required.', | ||
'string' => 'Line one field must be a string.', | ||
], | ||
'line_two' => [ | ||
'string' => 'Line two field must be a string.', | ||
], | ||
'line_three' => [ | ||
'string' => 'Line three field must be a string.', | ||
], | ||
'city' => [ | ||
'required' => 'City field is required.', | ||
'string' => 'City field must be a string.', | ||
], | ||
'state' => [ | ||
'string' => 'State field must be a string.', | ||
], | ||
'postcode' => [ | ||
'required' => 'Postcode field is required.', | ||
'string' => 'Postcode field must be a string.', | ||
], | ||
'delivery_instructions' => [ | ||
'string' => 'Delivery instructions field must be a string.', | ||
], | ||
'contact_email' => [ | ||
'string' => 'Contact email field must be a string.', | ||
], | ||
'contact_phone' => [ | ||
'string' => 'Contact phone field must be a string.', | ||
], | ||
'shipping_option' => [ | ||
'string' => 'Shipping option field must be a string.', | ||
], | ||
'address_type' => [ | ||
'required' => 'Address type field is required.', | ||
'string' => 'Address type field must be a string.', | ||
'in' => 'Address type field must be one of: :values.', | ||
], | ||
], | ||
|
||
'cart_lines' => [ | ||
'quantity' => [ | ||
'integer' => 'Quantity field must be an integer.', | ||
], | ||
'purchasable_id' => [ | ||
'required' => 'Purchasable id field is required.', | ||
'integer' => 'Purchasable id field must be an integer.', | ||
], | ||
'purchasable_type' => [ | ||
'required' => 'Purchasable type field is required.', | ||
'string' => 'Purchasable type field must be a string.', | ||
], | ||
'meta' => [ | ||
'array' => 'Meta field must be an array.', | ||
], | ||
], | ||
|
||
'customers' => [ | ||
'title' => [ | ||
'string' => 'Title field must be a string.', | ||
], | ||
'first_name' => [ | ||
'string' => 'First name field must be a string.', | ||
], | ||
'last_name' => [ | ||
'string' => 'Last name field must be a string.', | ||
], | ||
'company_name' => [ | ||
'string' => 'Company name field must be a string.', | ||
], | ||
'vat_no' => [ | ||
'string' => 'Company tax ID must be a string.', | ||
], | ||
'account_ref' => [ | ||
'string' => 'Company ID must be a string.', | ||
], | ||
], | ||
|
||
'orders' => [ | ||
'notes' => [ | ||
'string' => 'Notes field must be a string.', | ||
], | ||
], | ||
|
||
'payments' => [ | ||
'payment_method' => [ | ||
'required' => 'Payment method field is required.', | ||
'string' => 'Payment method field must be a string.', | ||
'in' => 'Payment method field must be one of: :types.', | ||
], | ||
'amount' => [ | ||
'numeric' => 'Amount field must be numeric.', | ||
], | ||
'meta' => [ | ||
'array' => 'Meta field must be an array.', | ||
], | ||
], | ||
|
||
'shipping' => [ | ||
'set_shipping_option' => [ | ||
'shipping_option' => [ | ||
'required' => 'Please select a shipping option.', | ||
'string' => 'Shipping option field must be a string.', | ||
], | ||
], | ||
], | ||
|
||
'payments' => [ | ||
'set_payment_option' => [ | ||
'payment_option' => [ | ||
'required' => 'Please select a payment method.', | ||
'string' => 'Payment method field must be a string.', | ||
], | ||
], | ||
], | ||
]; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
includes: | ||
- ./vendor/nunomaduro/larastan/extension.neon | ||
|
||
parameters: | ||
|
||
paths: | ||
- src | ||
|
||
# The level 9 is the highest level | ||
level: 5 | ||
|
||
ignoreErrors: | ||
- '#PHPDoc tag @var#' | ||
|
||
excludePaths: | ||
- ./*/*/FileToBeExcluded.php | ||
|
||
checkMissingIterableValueType: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
> | ||
<coverage/> | ||
<testsuites> | ||
<testsuite name="Unit"> | ||
<directory suffix="Test.php">./tests/Unit</directory> | ||
</testsuite> | ||
<testsuite name="Feature"> | ||
<directory suffix="Test.php">./tests/Feature</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<env name="APP_ENV" value="testing"/> | ||
<env name="BCRYPT_ROUNDS" value="4"/> | ||
<env name="CACHE_DRIVER" value="array"/> | ||
<env name="DB_CONNECTION" value="sqlite"/> | ||
<env name="DB_DATABASE" value=":memory:"/> | ||
<env name="LUNAR_API_USE_HASHIDS" value="true"/> | ||
</php> | ||
<source> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
> | ||
<coverage/> | ||
<testsuites> | ||
<testsuite name="Unit"> | ||
<directory suffix="Test.php">./tests/Unit</directory> | ||
</testsuite> | ||
<testsuite name="Feature"> | ||
<directory suffix="Test.php">./tests/Feature</directory> | ||
</testsuite> | ||
</testsuites> | ||
<php> | ||
<env name="APP_ENV" value="testing"/> | ||
<env name="BCRYPT_ROUNDS" value="4"/> | ||
<env name="CACHE_DRIVER" value="array"/> | ||
<env name="DB_CONNECTION" value="sqlite"/> | ||
<env name="DB_DATABASE" value=":memory:"/> | ||
</php> | ||
<source> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"preset": "laravel", | ||
"rules": { | ||
"explicit_string_variable": true | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector; | ||
use Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector; | ||
use Rector\Config\RectorConfig; | ||
use Rector\Set\ValueObject\SetList; | ||
use RectorLaravel\Rector\ClassMethod\AddGenericReturnTypeToRelationsRector; | ||
use RectorLaravel\Rector\ClassMethod\MigrateToSimplifiedAttributeRector; | ||
use RectorLaravel\Rector\FuncCall\FactoryFuncCallToStaticCallRector; | ||
use RectorLaravel\Rector\FuncCall\HelperFuncCallToFacadeClassRector; | ||
use RectorLaravel\Set\LaravelSetList; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->paths([ | ||
__DIR__.'/src', | ||
__DIR__.'/tinkerwell', | ||
]); | ||
|
||
$rectorConfig->importNames(); | ||
|
||
// register a single rule | ||
|
||
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class); | ||
$rectorConfig->rule(AddGenericReturnTypeToRelationsRector::class); | ||
$rectorConfig->rule(FactoryFuncCallToStaticCallRector::class); | ||
$rectorConfig->rule(HelperFuncCallToFacadeClassRector::class); | ||
$rectorConfig->rule(MigrateToSimplifiedAttributeRector::class); | ||
$rectorConfig->rule(SeparateMultiUseImportsRector::class); | ||
|
||
$rectorConfig->sets([ | ||
SetList::PHP_81, | ||
LaravelSetList::LARAVEL_100, | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Dystcz\LunarRewards\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
class LunarRewards extends Facade | ||
{ | ||
/** | ||
* Get the registered name of the component. | ||
* | ||
* @return string | ||
*/ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return 'lunar-rewards'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Dystcz\LunarRewards; | ||
|
||
class LunarRewards | ||
{ | ||
// | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
<?php | ||
|
||
namespace Dystcz\LunarRewards; | ||
|
||
use Illuminate\Foundation\Application; | ||
use Illuminate\Support\Facades\Config; | ||
use Illuminate\Support\Facades\Event; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class LunarRewardsServiceProvider extends ServiceProvider | ||
{ | ||
protected array $configFiles = [ | ||
'rewards', | ||
]; | ||
|
||
protected $root = __DIR__.'/..'; | ||
|
||
/** | ||
* Register the application services. | ||
*/ | ||
public function register(): void | ||
{ | ||
$this->registerConfig(); | ||
|
||
$this->loadTranslationsFrom( | ||
"{$this->root}/lang", | ||
'lunar-rewards', | ||
); | ||
|
||
$this->booting(function () { | ||
$this->registerPolicies(); | ||
}); | ||
|
||
// Register the main class to use with the facade. | ||
$this->app->singleton( | ||
'lunar-rewards', | ||
fn () => new LunarRewards, | ||
); | ||
} | ||
|
||
/** | ||
* Bootstrap the application services. | ||
*/ | ||
public function boot(): void | ||
{ | ||
$this->loadRoutesFrom("{$this->root}/routes/api.php"); | ||
$this->loadMigrationsFrom("{$this->root}/database/migrations"); | ||
|
||
$this->registerModels(); | ||
$this->registerObservers(); | ||
$this->registerEvents(); | ||
|
||
if ($this->app->runningInConsole()) { | ||
$this->publishConfig(); | ||
$this->publishTranslations(); | ||
$this->publishMigrations(); | ||
$this->registerCommands(); | ||
} | ||
} | ||
|
||
/** | ||
* Publish config files. | ||
*/ | ||
protected function publishConfig(): void | ||
{ | ||
foreach ($this->configFiles as $configFile) { | ||
$this->publishes([ | ||
"{$this->root}/config/{$configFile}.php" => config_path("lunar-rewards/{$configFile}.php"), | ||
], 'lunar-rewards'); | ||
} | ||
} | ||
|
||
/** | ||
* Publish translations. | ||
*/ | ||
protected function publishTranslations(): void | ||
{ | ||
$this->publishes([ | ||
"{$this->root}/lang" => $this->app->langPath('vendor/lunar-rewards'), | ||
], 'lunar-rewards.translations'); | ||
} | ||
|
||
/** | ||
* Register config files. | ||
*/ | ||
protected function registerConfig(): void | ||
{ | ||
foreach ($this->configFiles as $configFile) { | ||
$this->mergeConfigFrom( | ||
"{$this->root}/config/{$configFile}.php", | ||
"lunar-rewards.{$configFile}", | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* Publish migrations. | ||
*/ | ||
protected function publishMigrations(): void | ||
{ | ||
$this->publishes([ | ||
"{$this->root}/database/migrations/" => $this->app->databasePath('migrations'), | ||
], 'lunar-rewards.migrations'); | ||
} | ||
|
||
/** | ||
* Register commands. | ||
*/ | ||
protected function registerCommands(): void | ||
{ | ||
$this->commands([ | ||
// | ||
]); | ||
} | ||
|
||
/** | ||
* Register events. | ||
*/ | ||
protected function registerEvents(): void | ||
{ | ||
$events = [ | ||
// | ||
]; | ||
|
||
foreach ($events as $event => $listeners) { | ||
foreach ($listeners as $listener) { | ||
Event::listen($event, $listener); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Register observers. | ||
*/ | ||
protected function registerObservers(): void | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Swap models. | ||
*/ | ||
protected function registerModels(): void | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Register the application's policies. | ||
*/ | ||
public function registerPolicies(): void | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
env: | ||
- DB_CONNECTION="sqlite" | ||
- DB_DATABASE=":memory:" | ||
|
||
providers: | ||
- Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Dystcz\LunarRewards\Tests\Data; | ||
|
||
use Closure; | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Support\Collection; | ||
|
||
class TestInclude | ||
{ | ||
/** | ||
* @param Factory<Model> $factory | ||
*/ | ||
public function __construct( | ||
public string $type, | ||
public string $relation, | ||
public ?Closure $relationCallback = null, | ||
public ?Factory $factory = null, | ||
public ?string $factory_relation = null, | ||
public string $factory_relation_method = 'has', | ||
) { | ||
} | ||
|
||
/** | ||
* Get relation. | ||
*/ | ||
public function getRelation(Collection|Model $target): Collection|Model|null | ||
{ | ||
$relationCallback = $this->relationCallback; | ||
|
||
if ($target instanceof Model) { | ||
/** @var Model $target */ | ||
if ($relationCallback) { | ||
return $relationCallback($target); | ||
} | ||
|
||
return $target->{$this->relation}; | ||
} | ||
|
||
/** @var Collection $target */ | ||
if ($relationCallback) { | ||
return $relationCallback($target); | ||
} | ||
|
||
return $target->pluck($this->relation)->flatten(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
use Dystcz\LunarApi\Support\Models\Actions\GetModelKey; | ||
use Dystcz\LunarApi\Tests\Stubs\Lunar\TestUrlGenerator; | ||
use Illuminate\Support\Collection; | ||
use Illuminate\Support\Facades\App; | ||
use Illuminate\Support\Facades\Config; | ||
use Lunar\Base\BaseModel; | ||
use Lunar\Database\Factories\LanguageFactory; | ||
|
||
/** | ||
* Get server url. | ||
*/ | ||
function serverUrl(?string $path = null, bool $full = false): string | ||
{ | ||
$path = implode('/', [Config::get('lunar-api.general.route_prefix'), 'v1', ltrim($path, '/')]); | ||
|
||
if ($full) { | ||
return "http://localhost/{$path}"; | ||
} | ||
|
||
return $path; | ||
} | ||
|
||
/** | ||
* Decode hashed id. | ||
*/ | ||
function decodeHashedId(BaseModel $model, mixed $id): mixed | ||
{ | ||
/** @var \Vinkla\Hashids\Facades\Hashids $hashids */ | ||
$hashids = App::get('hashids'); | ||
|
||
return $hashids->connection((new GetModelKey)($model))->decode($id); | ||
} | ||
|
||
/** | ||
* Map models to response data. | ||
*/ | ||
function mapModelsToResponseData(string $schemaType, Collection $models): Collection | ||
{ | ||
return $models->map(fn ($model) => [ | ||
'type' => $schemaType, | ||
'id' => $model->getRouteKey(), | ||
]); | ||
} | ||
|
||
/** | ||
* Turn on url generator. | ||
*/ | ||
function generateUrls(): void | ||
{ | ||
LanguageFactory::new()->create(); | ||
|
||
/** @var TestCase $this */ | ||
Config::set('lunar.urls.generator', \Lunar\Generators\UrlGenerator::class); | ||
} | ||
|
||
/** | ||
* Turn off url generator. | ||
*/ | ||
function dontGenerateUrls(): void | ||
{ | ||
/** @var TestCase $this */ | ||
Config::set('lunar.urls.generator', TestUrlGenerator::class); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
<?php | ||
|
||
namespace Dystcz\LunarRewards\Tests; | ||
|
||
use Dystcz\LunarApi\Base\Facades\SchemaManifestFacade; | ||
use Dystcz\LunarApi\Tests\Stubs\Lunar\TestUrlGenerator; | ||
use Dystcz\LunarApi\Tests\Stubs\Users\JsonApi\V1\UserSchema; | ||
use Illuminate\Contracts\Debug\ExceptionHandler; | ||
use Illuminate\Foundation\Application; | ||
use Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables; | ||
use Illuminate\Support\Facades\App; | ||
use Illuminate\Support\Facades\Config; | ||
use LaravelJsonApi\Testing\MakesJsonApiRequests; | ||
use LaravelJsonApi\Testing\TestExceptionHandler; | ||
use Orchestra\Testbench\TestCase as Orchestra; | ||
|
||
abstract class TestCase extends Orchestra | ||
{ | ||
use MakesJsonApiRequests; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
Config::set('auth.providers.users', [ | ||
'driver' => 'eloquent', | ||
'model' => User::class, | ||
]); | ||
|
||
Config::set('lunar.urls.generator', TestUrlGenerator::class); | ||
|
||
activity()->disableLogging(); | ||
} | ||
|
||
/** | ||
* @param Application $app | ||
*/ | ||
protected function getPackageProviders($app): array | ||
{ | ||
return [ | ||
// Ray | ||
\Spatie\LaravelRay\RayServiceProvider::class, | ||
|
||
// Spatie Permissions | ||
\Spatie\Permission\PermissionServiceProvider::class, | ||
|
||
// Laravel JsonApi | ||
\LaravelJsonApi\Encoder\Neomerx\ServiceProvider::class, | ||
\LaravelJsonApi\Laravel\ServiceProvider::class, | ||
\LaravelJsonApi\Spec\ServiceProvider::class, | ||
|
||
// Lunar core | ||
\Lunar\LunarServiceProvider::class, | ||
\Spatie\MediaLibrary\MediaLibraryServiceProvider::class, | ||
\Spatie\Activitylog\ActivitylogServiceProvider::class, | ||
\Cartalyst\Converter\Laravel\ConverterServiceProvider::class, | ||
\Kalnoy\Nestedset\NestedSetServiceProvider::class, | ||
\Spatie\LaravelBlink\BlinkServiceProvider::class, | ||
|
||
// Lunar Api | ||
\Dystcz\LunarApi\LunarApiServiceProvider::class, | ||
\Dystcz\LunarApi\JsonApiServiceProvider::class, | ||
|
||
// Livewire | ||
\Lunar\LivewireTables\LivewireTablesServiceProvider::class, | ||
\Livewire\LivewireServiceProvider::class, | ||
|
||
// Lunar Hub | ||
\Lunar\Hub\AdminHubServiceProvider::class, | ||
|
||
// Lunar Rewards | ||
\Dystcz\LunarRewards\LunarRewardsServiceProvider::class, | ||
]; | ||
} | ||
|
||
/** | ||
* @param Application $app | ||
*/ | ||
public function getEnvironmentSetUp($app): void | ||
{ | ||
$app->useEnvironmentPath(__DIR__.'/..'); | ||
$app->bootstrapWith([LoadEnvironmentVariables::class]); | ||
|
||
/** | ||
* Lunar configuration. | ||
*/ | ||
Config::set('lunar.cart.auto_create', true); | ||
Config::set('lunar.payments.default', 'cash-in-hand'); | ||
|
||
/** | ||
* App configuration. | ||
*/ | ||
Config::set('database.default', 'sqlite'); | ||
Config::set('database.migrations', 'migrations'); | ||
Config::set('database.connections.sqlite', [ | ||
'driver' => 'sqlite', | ||
'database' => ':memory:', | ||
'prefix' => '', | ||
]); | ||
|
||
Config::set('database.connections.mysql', [ | ||
'driver' => 'mysql', | ||
'host' => 'mysql', | ||
'port' => '3306', | ||
'database' => 'lunar-rewards-testing', | ||
'username' => 'homestead', | ||
'password' => 'secret', | ||
]); | ||
|
||
/** | ||
* Schema configuration. | ||
*/ | ||
SchemaManifestFacade::registerSchema(UserSchema::class); | ||
} | ||
|
||
/** | ||
* Define database migrations. | ||
*/ | ||
protected function defineDatabaseMigrations(): void | ||
{ | ||
$this->loadLaravelMigrations(); | ||
|
||
// NOTE MySQL migrations do not play nice with Lunar testing for some reason | ||
// // artisan($this, 'lunar:install'); | ||
// // artisan($this, 'vendor:publish', ['--tag' => 'lunar']); | ||
// // artisan($this, 'vendor:publish', ['--tag' => 'lunar.migrations']); | ||
// | ||
// // artisan($this, 'migrate', ['--database' => 'mysql']); | ||
// | ||
// $this->beforeApplicationDestroyed( | ||
// fn () => artisan($this, 'migrate:rollback', ['--database' => 'mysql']) | ||
// ); | ||
} | ||
|
||
/** | ||
* Resolve application HTTP exception handler implementation. | ||
*/ | ||
protected function resolveApplicationExceptionHandler($app): void | ||
{ | ||
$app->singleton( | ||
ExceptionHandler::class, | ||
TestExceptionHandler::class | ||
); | ||
} | ||
} |