Skip to content

Commit 34de606

Browse files
- [x] add aammui/role-permission
1 parent f72b327 commit 34de606

File tree

102 files changed

+2562
-960
lines changed

Some content is hidden

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

102 files changed

+2562
-960
lines changed

.github/workflows/php-cs-fixer.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Check & fix styling
2+
3+
on: [push]
4+
5+
jobs:
6+
style:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v1
12+
- name: Fix style
13+
uses: docker://oskarstark/php-cs-fixer-ga
14+
with:
15+
args: --config=.php-cs-fixer.dist.php --allow-risky=yes
16+
- name: Extract branch name
17+
shell: bash
18+
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
19+
id: extract_branch
20+
- name: Commit changes
21+
uses: stefanzweifel/[email protected]
22+
with:
23+
commit_message: Fix styling
24+
branch: ${{ steps.extract_branch.outputs.branch }}
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/psalm.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Psalm
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.php'
7+
- 'psalm.xml.dist'
8+
9+
jobs:
10+
psalm:
11+
name: psalm
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Setup PHP
17+
uses: shivammathur/setup-php@v2
18+
with:
19+
php-version: '8.0'
20+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
21+
coverage: none
22+
23+
- name: Cache composer dependencies
24+
uses: actions/cache@v2
25+
with:
26+
path: vendor
27+
key: composer-${{ hashFiles('composer.lock') }}
28+
29+
- name: Run composer install
30+
run: composer install -n --prefer-dist
31+
32+
- name: Run psalm
33+
run: ./vendor/bin/psalm --output-format=github

.github/workflows/run-tests.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: "Run Tests - Current"
2+
3+
on: [ push, pull_request ]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: true
10+
matrix:
11+
php: [ 8.0, 7.4]
12+
laravel: [ 8.* ]
13+
dependency-version: [ prefer-stable ]
14+
include:
15+
- laravel: 8.*
16+
testbench: 6.*
17+
18+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
19+
20+
steps:
21+
- name: Update apt
22+
run: sudo apt-get update --fix-missing
23+
24+
- name: Checkout code
25+
uses: actions/checkout@v2
26+
27+
- name: Cache dependencies
28+
uses: actions/cache@v2
29+
with:
30+
path: ~/.composer/cache/files
31+
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
32+
33+
- name: Setup PHP
34+
uses: shivammathur/setup-php@v2
35+
with:
36+
php-version: ${{ matrix.php }}
37+
extensions: mbstring, zip
38+
coverage: none
39+
40+
- name: Install dependencies
41+
run: |
42+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "symfony/console:>=4.3.4" --no-interaction --no-update
43+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
44+
- name: Execute tests
45+
run: vendor/bin/phpunit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ yarn-error.log
1414
.env
1515

1616
.phpunit.result.cache
17+
.php-cs-fixer.cache

.php-cs-fixer.dist.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
$finder = Symfony\Component\Finder\Finder::create()
4+
->in([
5+
__DIR__.'/app',
6+
__DIR__.'/tests',
7+
])
8+
->name('*.php')
9+
->notName('*.blade.php')
10+
->ignoreDotFiles(true)
11+
->ignoreVCS(true);
12+
13+
return (new PhpCsFixer\Config())
14+
->setRules([
15+
'@PSR2' => true,
16+
'array_syntax' => ['syntax' => 'short'],
17+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
18+
'no_unused_imports' => true,
19+
'not_operator_with_successor_space' => true,
20+
'trailing_comma_in_multiline' => true,
21+
'phpdoc_scalar' => true,
22+
'unary_operator_spaces' => true,
23+
'binary_operator_spaces' => true,
24+
'blank_line_before_statement' => [
25+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
26+
],
27+
'phpdoc_single_line_var_spacing' => true,
28+
'phpdoc_var_without_name' => true,
29+
'method_argument_space' => [
30+
'on_multiline' => 'ensure_fully_multiline',
31+
'keep_multiple_spaces_after_comma' => true,
32+
],
33+
'single_trait_insert_per_statement' => true,
34+
])
35+
->setFinder($finder);

app/Application/Admin/Controllers/DashboardController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace App\Application\Admin\Controllers;
44

5-
use App\Http\Controllers\Controller;
5+
use App\Core\Http\Controllers\Controller;
66

77
/**
88
* Class AdminController

app/Http/Controllers/PageController.php renamed to app/Application/Front/Controllers/PageController.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
<?php
22

3-
namespace App\Http\Controllers;
3+
namespace App\Application\Front\Controllers;
44

5-
use Illuminate\Http\Request;
5+
use App\Core\Http\Controllers\Controller;
6+
use App\Domain\Inventory\Models\Product;
67
use App\User;
7-
use App\Models\Product;
88

9+
/**
10+
* Class PageController
11+
*
12+
* @package App\Application\Front\Controllers
13+
*/
914
class PageController extends Controller
1015
{
1116
public function index()
1217
{
13-
$user = \App\User::with('profileImage', 'profile')->limit(10)->get();
18+
$user = User::with('profileImage', 'profile')->limit(10)->get();
19+
1420
$data = Product::with('medias')
1521
->with('price')
1622
->limit(20)
@@ -27,13 +33,16 @@ public function shop($slug, $id)
2733
->with('coverImage')
2834
->with('profileImage')
2935
->firstOrFail();
36+
3037
return view('front/shop/details', compact('shop'));
3138
}
3239

3340
public function product($name, $id)
3441
{
35-
$data = \App\Models\Product::where(['id' => $id])
36-
->with('price')->first();
42+
$data = Product::where(['id' => $id])
43+
->with('price')
44+
->first();
45+
3746
$data->views += 1;
3847
$data->save();
3948

app/Console/Kernel.php renamed to app/Core/Console/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace App\Console;
3+
namespace App\Core\Console;
44

55
use Illuminate\Console\Scheduling\Schedule;
66
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

app/Core/Constants/TableName.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace App\Core\Constants;
4+
5+
/**
6+
* Class TableName
7+
*
8+
* @package App\Core\Constants
9+
*/
10+
interface TableName
11+
{
12+
// Inventory related tables.
13+
public const PRODUCT = "products";
14+
public const CATEGORY = "categories";
15+
}

app/Exceptions/Handler.php renamed to app/Core/Exceptions/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace App\Exceptions;
3+
namespace App\Core\Exceptions;
44

55
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
66
use Throwable;
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

3-
namespace App\Http\Controllers;
3+
namespace App\Core\Http\Controllers;
44

5+
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
56
use Illuminate\Foundation\Bus\DispatchesJobs;
6-
use Illuminate\Routing\Controller as BaseController;
77
use Illuminate\Foundation\Validation\ValidatesRequests;
8-
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
8+
use Illuminate\Routing\Controller as BaseController;
99

1010
class Controller extends BaseController
1111
{
12-
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
12+
use AuthorizesRequests;
13+
use DispatchesJobs;
14+
use ValidatesRequests;
1315
}

app/Http/Kernel.php renamed to app/Core/Http/Kernel.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22

3-
namespace App\Http;
3+
namespace App\Core\Http;
44

5+
use Aammui\RolePermission\Middleware\Role;
56
use Illuminate\Foundation\Http\Kernel as HttpKernel;
67

78
class Kernel extends HttpKernel
@@ -14,11 +15,13 @@ class Kernel extends HttpKernel
1415
* @var array
1516
*/
1617
protected $middleware = [
17-
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
18+
// \App\Http\Middleware\TrustHosts::class,
19+
\App\Core\Http\Middleware\TrustProxies::class,
20+
\Fruitcake\Cors\HandleCors::class,
21+
\App\Core\Http\Middleware\PreventRequestsDuringMaintenance::class,
1822
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
19-
\App\Http\Middleware\TrimStrings::class,
23+
\App\Core\Http\Middleware\TrimStrings::class,
2024
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
21-
\App\Http\Middleware\TrustProxies::class,
2225
];
2326

2427
/**
@@ -28,12 +31,12 @@ class Kernel extends HttpKernel
2831
*/
2932
protected $middlewareGroups = [
3033
'web' => [
31-
\App\Http\Middleware\EncryptCookies::class,
34+
\App\Core\Http\Middleware\EncryptCookies::class,
3235
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
3336
\Illuminate\Session\Middleware\StartSession::class,
3437
// \Illuminate\Session\Middleware\AuthenticateSession::class,
3538
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
36-
\App\Http\Middleware\VerifyCsrfToken::class,
39+
\App\Core\Http\Middleware\VerifyCsrfToken::class,
3740
\Illuminate\Routing\Middleware\SubstituteBindings::class,
3841
],
3942

@@ -51,14 +54,14 @@ class Kernel extends HttpKernel
5154
* @var array
5255
*/
5356
protected $routeMiddleware = [
54-
'role' => \App\Http\Middleware\Role::class,
57+
"role" => Role::class,
5558
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
5659
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
5760
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
5861
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
5962
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
6063
'can' => \Illuminate\Auth\Middleware\Authorize::class,
61-
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
64+
'guest' => \App\Core\Http\Middleware\RedirectIfAuthenticated::class,
6265
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
6366
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
6467
];
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace App\Core\Http\Middleware;
4+
5+
use Illuminate\Auth\Middleware\Authenticate as Middleware;
6+
7+
/**
8+
* Class Authenticate
9+
*
10+
* @package App\Core\Http\Middleware
11+
*/
12+
class Authenticate extends Middleware
13+
{
14+
/**
15+
* Get the path the user should be redirected to when they are not authenticated.
16+
*
17+
* @param \Illuminate\Http\Request $request
18+
*
19+
* @return string|null
20+
*/
21+
protected function redirectTo($request)
22+
{
23+
if (! $request->expectsJson()) {
24+
return route('login');
25+
}
26+
}
27+
}

app/Http/Middleware/EncryptCookies.php renamed to app/Core/Http/Middleware/EncryptCookies.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace App\Http\Middleware;
3+
namespace App\Core\Http\Middleware;
44

55
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
66

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace App\Core\Http\Middleware;
4+
5+
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
6+
7+
class PreventRequestsDuringMaintenance extends Middleware
8+
{
9+
/**
10+
* The URIs that should be reachable while maintenance mode is enabled.
11+
*
12+
* @var array
13+
*/
14+
protected $except = [
15+
//
16+
];
17+
}

app/Http/Middleware/RedirectIfAuthenticated.php renamed to app/Core/Http/Middleware/RedirectIfAuthenticated.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace App\Http\Middleware;
3+
namespace App\Core\Http\Middleware;
44

55
use Closure;
66
use Illuminate\Support\Facades\Auth;

app/Http/Middleware/TrimStrings.php renamed to app/Core/Http/Middleware/TrimStrings.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace App\Http\Middleware;
3+
namespace App\Core\Http\Middleware;
44

55
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
66

@@ -12,6 +12,7 @@ class TrimStrings extends Middleware
1212
* @var array
1313
*/
1414
protected $except = [
15+
'current_password',
1516
'password',
1617
'password_confirmation',
1718
];

0 commit comments

Comments
 (0)