Skip to content

Commit 2d432e6

Browse files
committed
first commit
0 parents  commit 2d432e6

File tree

135 files changed

+10027
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+10027
-0
lines changed

.gitattributes

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text eol=lf
3+
4+
# Explicitly declare text files you want to always be normalized and converted
5+
# to native line endings on checkout.
6+
*.c text
7+
*.h text
8+
9+
# Declare files that will always have CRLF line endings on checkout.
10+
*.sln text eol=crlf
11+
12+
# Denote all files that are truly binary and should not be modified.
13+
*.png binary
14+
*.jpg binary
15+
*.otf binary
16+
*.eot binary
17+
*.svg binary
18+
*.ttf binary
19+
*.woff binary
20+
*.woff2 binary
21+
22+
*.css linguist-vendored
23+
*.scss linguist-vendored
24+
*.js linguist-vendored
25+
CHANGELOG.md export-ignore

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/vendor
2+
composer.phar
3+
composer.lock
4+
.DS_Store

.scrutinizer.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
checks:
2+
php: true
3+
filter:
4+
excluded_paths: [vendor/*, tests/*]
5+
coding_style:
6+
php: { }
7+
tools:
8+
external_code_coverage: true
9+
php_code_coverage: true

.styleci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
preset: psr2
2+
3+
enabled:
4+
- concat_with_spaces

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: php
2+
3+
php:
4+
- '7.1'
5+
- '7.2'
6+
- '7.3'
7+
8+
sudo: false
9+
10+
before_install:
11+
# turn off XDebug
12+
- phpenv config-rm xdebug.ini || return
13+
14+
before_script:
15+
- composer install --no-interaction --prefer-source
16+
17+
script:
18+
- vendor/bin/phpunit

LICENSE.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Pingpong Labs
4+
5+
Copyright (c) 2016 Nicolas Widart
6+
7+
Copyright (c) 2019 Akaunting
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Module management package for Laravel
2+
3+
[![Version](https://poser.pugx.org/akaunting/module/v/stable.svg)](https://github.com/akaunting/module/releases)
4+
![Downloads](https://poser.pugx.org/akaunting/module/d/total.svg)
5+
![Build Status](https://travis-ci.com/akaunting/module.svg)
6+
[![StyleCI](https://styleci.io/repos/180799968/shield?style=flat&branch=master)](https://styleci.io/repos/180799968)
7+
[![Quality](https://scrutinizer-ci.com/g/akaunting/module/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/akaunting/module)
8+
[![License](https://poser.pugx.org/akaunting/module/license.svg)](LICENSE.md)
9+
10+
This package intends to make your Laravel app extendible via modules. A module is kinda small Laravel app, shipping with its own views, controllers, models etc.
11+
12+
## Getting Started
13+
14+
### 1. Install
15+
16+
Run the following command:
17+
18+
```bash
19+
composer require akaunting/module
20+
```
21+
22+
### 2. Register
23+
24+
Service provider and facade will be registered automatically. If you want to register them manually in `config/app.php`:
25+
26+
```php
27+
Akaunting\Module\Facade::class,
28+
Akaunting\Module\Providers\Laravel::class,
29+
```
30+
31+
### 3. Publish
32+
33+
Publish config file.
34+
35+
```bash
36+
php artisan vendor:publish --tag=module
37+
```
38+
39+
### 4. Configure
40+
41+
You can change the configuration from `config/module.php` file
42+
43+
### 5. Autoloading
44+
45+
By default, the module classes are not loaded automatically. You can autoload your modules using `psr-4`. For example:
46+
47+
``` json
48+
{
49+
"autoload": {
50+
"psr-4": {
51+
"App\\": "app/",
52+
"Modules\\": "modules/"
53+
}
54+
}
55+
}
56+
```
57+
58+
**Tip: don't forget to run `composer dump-autoload` afterwards.**
59+
60+
## Usage
61+
62+
Check out the [wiki](../../wiki) about the usage and further documentation.
63+
64+
## Changelog
65+
66+
Please see [Releases](../../releases) for more information what has changed recently.
67+
68+
## Contributing
69+
70+
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
71+
72+
## Credits
73+
74+
- [Denis Duliçi](https://github.com/denisdulici)
75+
- [Nicolas Widart](https://github.com/nwidart)
76+
- [All Contributors](../../contributors)
77+
78+
## License
79+
80+
The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.

composer.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "akaunting/module",
3+
"description": "Module management package for Laravel.",
4+
"keywords": ["laravel", "module", "rad", "akaunting"],
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Denis Duliçi",
9+
"email": "[email protected]",
10+
"homepage": "https://akaunting.com",
11+
"role": "Developer"
12+
}
13+
],
14+
"require": {
15+
"php": ">=7.1"
16+
},
17+
"require-dev": {
18+
"phpunit/phpunit": "~7.0",
19+
"mockery/mockery": "~1.0",
20+
"orchestra/testbench": "^3.8",
21+
"friendsofphp/php-cs-fixer": "^2.14",
22+
"spatie/phpunit-snapshot-assertions": "^2.1.0",
23+
"phpstan/phpstan": "^0.9.2"
24+
},
25+
"autoload": {
26+
"psr-4": {
27+
"Akaunting\\Module\\": "./src"
28+
},
29+
"files": [
30+
"src/helpers.php"
31+
]
32+
},
33+
"autoload-dev": {
34+
"psr-4": {
35+
"Akaunting\\Module\\Tests\\": "tests",
36+
"Modules\\Recipe\\": "tests/stubs/valid/Recipe"
37+
}
38+
},
39+
"extra": {
40+
"laravel": {
41+
"providers": [
42+
"Akaunting\\Module\\Providers\\Laravel"
43+
],
44+
"aliases": {
45+
"Module": "Akaunting\\Module\\Facade"
46+
}
47+
}
48+
},
49+
"minimum-stability": "dev",
50+
"prefer-stable": true
51+
}
52+

phpunit.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="vendor/autoload.php"
3+
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
verbose="true"
7+
convertErrorsToExceptions="true"
8+
convertNoticesToExceptions="true"
9+
convertWarningsToExceptions="true"
10+
processIsolation="false"
11+
stopOnFailure="false"
12+
>
13+
<testsuites>
14+
<testsuite name="Akaunting Module Test Suite">
15+
<directory>tests</directory>
16+
</testsuite>
17+
</testsuites>
18+
<filter>
19+
<whitelist>
20+
<directory suffix=".php">src/</directory>
21+
</whitelist>
22+
</filter>
23+
<logging>
24+
<log type="tap" target="build/report.tap"/>
25+
<log type="junit" target="build/report.junit.xml"/>
26+
<log type="coverage-html" target="build/coverage"/>
27+
<log type="coverage-text" target="build/coverage.txt"/>
28+
<log type="coverage-clover" target="build/logs/clover.xml"/>
29+
</logging>
30+
</phpunit>

src/Collection.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace Akaunting\Module;
4+
5+
use Illuminate\Contracts\Support\Arrayable;
6+
use Illuminate\Support\Collection as BaseCollection;
7+
8+
class Collection extends BaseCollection
9+
{
10+
/**
11+
* Get items collections.
12+
*
13+
* @return array
14+
*/
15+
public function getItems()
16+
{
17+
return $this->items;
18+
}
19+
20+
/**
21+
* Get the collection of items as a plain array.
22+
*
23+
* @return array
24+
*/
25+
public function toArray()
26+
{
27+
return array_map(function ($value) {
28+
if ($value instanceof Module) {
29+
$attributes = $value->json()->getAttributes();
30+
$attributes["path"] = $value->getPath();
31+
32+
return $attributes;
33+
}
34+
35+
return $value instanceof Arrayable ? $value->toArray() : $value;
36+
}, $this->items);
37+
}
38+
}

0 commit comments

Comments
 (0)