From fcd50f5dbe8275405ff8965a93306fbf2a4bf491 Mon Sep 17 00:00:00 2001 From: Ramakant Date: Thu, 17 Mar 2022 22:52:01 +0530 Subject: [PATCH] A new start --- .gitattributes | 7 ++ .github/FUNDING.yml | 12 +++ .github/ISSUE_TEMPLATE/config.yml | 11 +++ .github/workflows/php-cs-fixer.yml | 29 ++++++++ .github/workflows/run-tests.yml | 51 +++++++++++++ .gitignore | 2 + .php-cs-fixer.php | 115 +++++++++++++++++++++++++++++ CHANGELOG.md | 4 + CONTRIBUTING.md | 1 + LICENSE.md | 21 ++++++ README.md | 85 +++++++++++++++++++++ UPGRADING.md | 2 + composer.json | 92 +++++++++++++++++++++++ config/voyager-crm.php | 27 +++++++ phpcs.xml | 75 +++++++++++++++++++ phpunit.xml | 13 ++++ renovate.json5 | 85 +++++++++++++++++++++ resources/lang/.gitkeep | 0 resources/views/.gitkeep | 0 routes/api.php | 23 ++++++ routes/web.php | 13 ++++ src/VoyagerCrmServiceProvider.php | 101 +++++++++++++++++++++++++ src/helper.php | 11 +++ tests/TestCase.php | 64 ++++++++++++++++ 24 files changed, 844 insertions(+) create mode 100755 .gitattributes create mode 100644 .github/FUNDING.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/workflows/php-cs-fixer.yml create mode 100644 .github/workflows/run-tests.yml create mode 100644 .gitignore create mode 100644 .php-cs-fixer.php create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 UPGRADING.md create mode 100644 composer.json create mode 100644 config/voyager-crm.php create mode 100644 phpcs.xml create mode 100644 phpunit.xml create mode 100644 renovate.json5 create mode 100644 resources/lang/.gitkeep create mode 100644 resources/views/.gitkeep create mode 100644 routes/api.php create mode 100644 routes/web.php create mode 100644 src/VoyagerCrmServiceProvider.php create mode 100644 src/helper.php create mode 100644 tests/TestCase.php diff --git a/.gitattributes b/.gitattributes new file mode 100755 index 0000000..01a3bfd --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +* text=auto +*.css linguist-vendored +*.scss linguist-vendored +*.js linguist-vendored +CHANGELOG.md export-ignore +composer.lock -merge +package-lock.json -merge diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..23bf884 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: ramakant +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..4a16219 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,11 @@ +blank_issues_enabled: false +contact_links: + - name: Ask a Question + url: https://github.com/rxcod9/joy-voyager-crm/discussions/new?category=q-a + about: Ask the community for help + - name: Feature Request + url: https://github.com/rxcod9/joy-voyager-crm/discussions/new?category=ideas + about: Share ideas for new features + - name: Bug Report + url: https://github.com/rxcod9/joy-voyager-crm/issues/new + about: Report a reproducable bug diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..15c7524 --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,29 @@ +name: Check & fix styling + +on: [push] + +jobs: + style: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Fix style + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --config=.php-cs-fixer.php --allow-risky=yes + + - name: Extract branch name + shell: bash + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + id: extract_branch + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4.13.1 + with: + commit_message: Fix styling + branch: ${{ steps.extract_branch.outputs.branch }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..e4d7149 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,51 @@ +name: run-tests + +on: + push: + pull_request: + schedule: + - cron: '0 0 * * *' + +jobs: + run-tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: [7.4] + laravel: [8.*, 7.*] + dependency-version: [prefer-lowest, prefer-stable] + include: + - laravel: 8.* + testbench: 6.* + - laravel: 7.* + testbench: 5.* + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} + + steps: + - name: Update apt + run: sudo apt-get update --fix-missing + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: none + + - name: Setup Problem Matches + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..076d2cd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +vendor/* +.php-cs-fixer.cache diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..8adae82 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,115 @@ +notPath('spark') + ->notPath('bootstrap') + ->notPath('storage') + ->notPath('vendor') + ->in(__DIR__ . '/src') + ->in(__DIR__ . '/tests') + ->name('*.php') + ->name('_ide_helper') + ->notName('*.blade.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +$config = new PhpCsFixer\Config(); +return $config->setRules([ + '@PSR2' => true, + 'array_indentation' => true, + 'array_syntax' => ['syntax' => 'short'], + 'combine_consecutive_unsets' => true, + 'class_attributes_separation' => ['elements' => ['method' => 'one']], + 'multiline_whitespace_before_semicolons' => true, + 'single_quote' => true, + 'binary_operator_spaces' => [ + 'operators' => [ + '=>' => 'align_single_space_minimal', + '=' => 'align_single_space_minimal', + ], + ], + // 'blank_line_after_opening_tag' => true, + // 'blank_line_before_return' => true, + 'braces' => [ + 'allow_single_line_closure' => true, + ], + // 'cast_spaces' => true, + // 'class_definition' => array('singleLine' => true), + 'concat_space' => ['spacing' => 'one'], + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'single_line_comment_style' => ['comment_types' => ['hash']], + 'include' => true, + 'lowercase_cast' => true, + // 'native_function_casing' => true, + // 'new_with_braces' => true, + // 'no_blank_lines_after_class_opening' => true, + // 'no_blank_lines_after_phpdoc' => true, + // 'no_empty_comment' => true, + // 'no_empty_phpdoc' => true, + // 'no_empty_statement' => true, + 'no_extra_blank_lines' => [ + 'tokens' => [ + 'case', + 'continue', + 'curly_brace_block', + 'default', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'switch', + 'throw', + 'use', + 'use_trait', + ], + ], + // 'no_leading_import_slash' => true, + // 'no_leading_namespace_whitespace' => true, + // 'no_mixed_echo_print' => array('use' => 'echo'), + 'no_multiline_whitespace_around_double_arrow' => true, + // 'no_short_bool_cast' => true, + // 'no_singleline_whitespace_before_semicolons' => true, + 'no_spaces_around_offset' => true, + // 'no_trailing_comma_in_list_call' => true, + // 'no_trailing_comma_in_singleline_array' => true, + // 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + // 'ordered_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + // 'normalize_index_brace' => true, + 'object_operator_without_whitespace' => true, + // 'php_unit_fqcn_annotation' => true, + 'phpdoc_align' => true, + // 'phpdoc_annotation_without_dot' => true, + // 'phpdoc_indent' => true, + // 'phpdoc_inline_tag' => true, + // 'phpdoc_no_access' => true, + // 'phpdoc_no_alias_tag' => true, + // 'phpdoc_no_empty_return' => true, + // 'phpdoc_no_package' => true, + 'phpdoc_no_useless_inheritdoc' => true, + // 'phpdoc_return_self_reference' => true, + // 'phpdoc_scalar' => true, + // 'phpdoc_separation' => true, + // 'phpdoc_single_line_var_spacing' => true, + // 'phpdoc_summary' => true, + // 'phpdoc_to_comment' => true, + // 'phpdoc_trim' => true, + // 'phpdoc_types' => true, + // 'phpdoc_var_without_name' => true, + // 'increment_style' => ['style' => 'pre'], + // 'return_type_declaration' => true, + // 'self_accessor' => true, + // 'short_scalar_cast' => true, + 'single_blank_line_before_namespace' => true, + // 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + // 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + // 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, +]) +->setFinder($finder); diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7180c38 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +# Changelog + +## 1.0.0 +- initial release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..4d218d9 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1 @@ +# Contributing \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..e3a6e48 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Ramakant Gangwar + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ceaa2a4 --- /dev/null +++ b/README.md @@ -0,0 +1,85 @@ +# Joy VoyagerCrm + +This [Laravel](https://laravel.com/)/[Voyager](https://voyager.devdojo.com/) module adds VoyagerCrm support to Voyager. + +By 🐼 [Ramakant Gangwar](https://github.com/rxcod9). + +[![Screenshot](https://raw.githubusercontent.com/rxcod9/joy-voyager-crm/main/cover.jpg)](https://joy-voyager-crm.herokuapp.com) + +[![Latest Version](https://img.shields.io/github/v/release/rxcod9/joy-voyager-crm?style=flat-square)](https://github.com/rxcod9/joy-voyager-crm/releases) +![GitHub Workflow Status](https://img.shields.io/github/workflow/status/rxcod9/joy-voyager-crm/run-tests?label=tests) +[![Total Downloads](https://img.shields.io/packagist/dt/joy/voyager-crm.svg?style=flat-square)](https://packagist.org/packages/joy/voyager-crm) + +--- + +## Prerequisites + +* Composer Installed +* [Install Laravel](https://laravel.com/docs/installation) +* [Install Voyager](https://github.com/the-control-group/voyager) + +--- + +## Installation + +```bash +# 1. Require this Package in your fresh Laravel/Voyager project +composer require joy/voyager-crm + +# 2. Publish +php artisan vendor:publish --provider="Joy\VoyagerCrm\VoyagerCrmServiceProvider" --force +``` + +--- + + + + + +## Working Example + +You can try laravel demo here [https://joy-voyager-crm.herokuapp.com/api/documentation](https://joy-voyager-crm.herokuapp.com/api/documentation). + +## Documentation + +Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving the joy voyager-crm? Feel free to [create an issue on GitHub](https://github.com/rxcod9/joy-voyager-crm/issues), we'll try to address it as soon as possible. + +If you've found a bug regarding security please mail [gangwar.ramakant@gmail.com](mailto:gangwar.ramakant@gmail.com) instead of using the issue tracker. + +## Testing + +You can run the tests with: + +```bash +vendor/bin/phpunit +``` + +## Upgrading + +Please see [UPGRADING](UPGRADING.md) for details. + +### 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 [gangwar.ramakant@gmail.com](mailto:gangwar.ramakant@gmail.com) instead of using the issue tracker. + +## Credits + +- [Ramakant Gangwar](https://github.com/rxcod9) + +## License + +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. diff --git a/UPGRADING.md b/UPGRADING.md new file mode 100644 index 0000000..f9c5815 --- /dev/null +++ b/UPGRADING.md @@ -0,0 +1,2 @@ +# Upgrading + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..1993681 --- /dev/null +++ b/composer.json @@ -0,0 +1,92 @@ +{ + "name": "joy/voyager-crm", + "description": "This Laravel/Voyager module adds VoyagerCrm support to Voyager.", + "keywords": [ + "joy", + "voyager-crm", + "joy-voyager-crm", + "voyager-voyager-crm", + "cms", + "voyager", + "laravel" + ], + "homepage": "https://github.com/rxcod9/joy-voyager-crm", + "license": "MIT", + "authors": [{ + "name": "Ramakant Gangwar", + "email": "gangwar.ramakant@gmail.com", + "homepage": "https://github.com/rxcod9", + "role": "Tech Lead & Architect" + }], + "require": { + "php": "^7.3|^8.0", + "illuminate/support": "^7|^8", + "joy/voyager-core": "^1.0", + "joy/voyager-bread-contact": "^1.0", + "joy/voyager-bread-lead": "^1.0", + "joy/voyager-bread-target": "^1.0", + "joy/voyager-bread-account": "^1.0", + "joy/voyager-bread-opportunity": "^1.0", + "joy/voyager-bread-product": "^1.0", + "joy/voyager-bread-product-category": "^1.0", + "joy/voyager-bread-quote": "^1.0", + "joy/voyager-bread-invoice": "^1.0", + "joy/voyager-bread-contract": "^1.0", + "joy/voyager-bread-line-item": "^1.0", + "joy/voyager-bread-group": "^1.0", + "joy/voyager-bread-pdf-template": "^1.0", + "joy/voyager-bread-case": "^1.0", + "joy/voyager-bread-note": "^1.0", + "joy/voyager-bread-call": "^1.0", + "joy/voyager-bread-email": "^1.0", + "joy/voyager-bread-meeting": "^1.0", + "joy/voyager-bread-task": "^1.0", + "joy/voyager-bread-project": "^1.0", + "joy/voyager-bread-project-task": "^1.0", + "joy/voyager-bread-campaign": "^1.0", + "joy/voyager-bread-target-list": "^1.0", + "joy/voyager-bread-email-template": "^1.0", + "joy/voyager-bread-document": "^1.0", + "joy/voyager-bread-event": "^1.0", + "joy/voyager-bread-location": "^1.0", + "tcg/voyager": "^1.4" + }, + "require-dev": { + "ext-pdo_sqlite": "*", + "ext-zip": "*", + "friendsofphp/php-cs-fixer": "^3.0", + "guzzlehttp/guzzle": "^6.3|^7.0", + "mockery/mockery": "^1.3", + "orchestra/testbench": "^5.0|^6.0", + "phpunit/phpunit": "^9.1" + }, + "autoload": { + "psr-4": { + "Joy\\VoyagerCrm\\": "src" + }, + "files": [ + "src/helper.php" + ] + }, + "scripts": { + "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes", + "test": "vendor/bin/phpunit" + }, + "autoload-dev": { + "psr-4": { + "Joy\\VoyagerCrm\\Tests\\": "tests" + } + }, + "extra": { + "laravel": { + "providers": [ + "Joy\\VoyagerCrm\\VoyagerCrmServiceProvider" + ] + } + }, + "config": { + "sort-packages": true + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/config/voyager-crm.php b/config/voyager-crm.php new file mode 100644 index 0000000..661c42e --- /dev/null +++ b/config/voyager-crm.php @@ -0,0 +1,27 @@ + env('VOYAGER_CRM_CONFIG_KEY', 'joy-voyager-crm'), + + /* + * The route_prefix for voyager-crm package. + */ + 'route_prefix' => env('VOYAGER_CRM_ROUTE_PREFIX', 'joy-voyager-crm'), + + /* + |-------------------------------------------------------------------------- + | Controllers config + |-------------------------------------------------------------------------- + | + | Here you can specify voyager controller settings + | + */ + + 'controllers' => [ + 'namespace' => 'Joy\\VoyagerCrm\\Http\\Controllers', + ], +]; diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..3f2e7b2 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,75 @@ + + + + + The Laravel Coding Standards + + + src + tests + + + */database/* + */cache/* + */*.js + */*.css + */*.xml + */*.blade.php + */autoload.php + */storage/* + */docs/* + */vendor/* + */migrations/* + + + + + + + + + + + resources/lang/*/* + config/* + + + + + + diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..f3504c9 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,13 @@ + + + + + src/ + + + + + tests + + + \ No newline at end of file diff --git a/renovate.json5 b/renovate.json5 new file mode 100644 index 0000000..4e6daa9 --- /dev/null +++ b/renovate.json5 @@ -0,0 +1,85 @@ +// Note: we use JSON5 to be able to use comments +// This file is a suggestion for how to customize the default "config:base" preset. The sections below reference +// numbered tips from the cheat sheet in this article: https://www.augmentedmind.de/2021/07/25/renovate-bot-cheat-sheet/ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base", + ":preserveSemverRanges" + ], + // Configure PR assignees (#4) + "assignees": [ + "rxcod9" + ], + "packageRules": [ + // Disable updates for specific dependencies (#3) + { + "matchPackageNames": [ + "neutrino" + ], + "enabled": false + }, + // Avoid spam via automatic merging (#6) + { + "description": "Automatically merge minor and patch-level updates", + "matchUpdateTypes": [ + "minor", + "patch", + "digest" + ], + "automerge": true, + // Force Renovate to not create a PR (but merge its branches directly), to avoid PR-related email spam + "automergeType": "branch" + // remove this line if you DO want emails (spam) + }, + // Keep up to date with Renovate Bot's development (#11) + { + "description": "Disables the creation of branches/PRs for any minor/patch updates etc. of Renovate bot", + "matchPaths": [ + "renovate-update-notification/Dockerfile" + ], + "matchUpdateTypes": [ + "minor", + "patch", + "pin", + "digest", + "rollback" + ], + "enabled": false + }, + { + "description": "Causes the bot to create a PR (and thus, an email notification), whenever there is a new major Renovate version", + "matchPaths": [ + "renovate-update-notification/Dockerfile" + ], + "matchUpdateTypes": [ + "major" + ], + // you can also set automerge to true - emails for the PRs will already have been sent anyway, so there is + // no strict reason to keep the PR open - unless you want to associate it with updates you make to renovate.json5 + "automerge": false, + // just re-states the default and ensures that PRs are really created - you can remove this line + // if you did not change "prCreation" elsewhere to some non-default value + "prCreation": "immediate", + } + ], + // Disable updates for specific programming languages (#3) + "golang": { + "enabled": false + }, + // Avoid spam via scheduling and grouping (#5): avoid interference during working hours - applies globally to all deps! + "schedule": [ + "after 10pm every weekday", + "before 5am every weekday", + "every weekend" + ], + // Speed up the automatic merging process (e.g. GitLab) (#6) + "platformAutomerge": true, + // Fix default branch rebasing - always rebase still-open temporary branches, whenever its source branch has changed (#8) + "rebaseWhen": "behind-base-branch", + // Handle pulled dependency updates (#9) + "rollbackPrs": true, + // Improve overview of open PRs (caused by Renovate Bot) (#10) + "dependencyDashboard": true, + "dependencyDashboardAutoclose": true, + } \ No newline at end of file diff --git a/resources/lang/.gitkeep b/resources/lang/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/resources/views/.gitkeep b/resources/views/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/routes/api.php b/routes/api.php new file mode 100644 index 0000000..25059e3 --- /dev/null +++ b/routes/api.php @@ -0,0 +1,23 @@ + 'joy-voyager-crm.'], function () { + // event(new Routing()); @deprecated + + $namespacePrefix = '\\' . config('joy-voyager-crm.controllers.namespace') . '\\'; + + // event(new RoutingAfter()); @deprecated +}); diff --git a/routes/web.php b/routes/web.php new file mode 100644 index 0000000..8523566 --- /dev/null +++ b/routes/web.php @@ -0,0 +1,13 @@ + + * @copyright 2021 Copyright (c) Ramakant Gangwar (https://github.com/rxcod9) + * @license http://github.com/rxcod9/joy-voyager-crm/blob/main/LICENSE New BSD License + * @link https://github.com/rxcod9/joy-voyager-crm + */ +class VoyagerCrmServiceProvider extends ServiceProvider +{ + /** + * Boot + * + * @return void + */ + public function boot() + { + $this->registerPublishables(); + + $this->loadViewsFrom(__DIR__ . '/../resources/views', 'joy-voyager-crm'); + + $this->mapApiRoutes(); + + $this->mapWebRoutes(); + + $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); + + $this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'joy-voyager-crm'); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + */ + protected function mapWebRoutes(): void + { + Route::middleware('web') + ->group(__DIR__ . '/../routes/web.php'); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + */ + protected function mapApiRoutes(): void + { + Route::prefix(config('joy-voyager-crm.route_prefix', 'api')) + ->middleware('api') + ->group(__DIR__ . '/../routes/api.php'); + } + + /** + * Register any application services. + * + * @return void + */ + public function register() + { + $this->mergeConfigFrom(__DIR__ . '/../config/voyager-crm.php', 'joy-voyager-crm'); + + $this->registerCommands(); + } + + /** + * Register publishables. + * + * @return void + */ + protected function registerPublishables(): void + { + $this->publishes([ + __DIR__ . '/../config/voyager-crm.php' => config_path('joy-voyager-crm.php'), + ], 'config'); + + $this->publishes([ + __DIR__ . '/../resources/views' => resource_path('views/vendor/joy-voyager-crm'), + ], 'views'); + + $this->publishes([ + __DIR__ . '/../resources/lang' => resource_path('lang/vendor/joy-voyager-crm'), + ], 'translations'); + } + + protected function registerCommands(): void + { + // + } +} diff --git a/src/helper.php b/src/helper.php new file mode 100644 index 0000000..d38e680 --- /dev/null +++ b/src/helper.php @@ -0,0 +1,11 @@ +loadEnvironmentVariables(); + + parent::setUp(); + + $this->setUpDatabase($this->app); + } + + protected function loadEnvironmentVariables() + { + if (!file_exists(__DIR__ . '/../.env')) { + return; + } + + $dotEnv = Dotenv::createImmutable(__DIR__ . '/..'); + + $dotEnv->load(); + } + + /** + * @param \Illuminate\Foundation\Application $app + * + * @return array + */ + protected function getPackageProviders($app) + { + $serviceProviders = [ + VoyagerCrmServiceProvider::class, + ]; + + return $serviceProviders; + } + + /** + * @param \Illuminate\Foundation\Application $app + */ + protected function getEnvironmentSetUp($app) + { + config()->set('database.default', 'sqlite'); + config()->set('database.connections.sqlite', [ + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', + ]); + } + + /** + * @param \Illuminate\Foundation\Application $app + */ + protected function setUpDatabase($app) + { + } +}