Skip to content

Commit

Permalink
Opensourcing
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen committed May 1, 2021
0 parents commit bfeec0e
Show file tree
Hide file tree
Showing 214 changed files with 23,760 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: 2 # use CircleCI 2.0

jobs: # a collection of steps
build: # runs not using Workflows must have a `build` job as entry point
docker: # run the steps with Docker
- image: circleci/php:7.2-cli-node-browsers@sha256:643520b7ff937bcae5910176c15f522addf69b237d19ad386be7f75f7533d794
steps: # a set of executable commands
- checkout

- run: sudo apt update --fix-missing || sudo apt update --fix-missing
- run: sudo apt install -y libsqlite3-dev zlib1g-dev libpng-dev libjpeg62-turbo-dev libfreetype6-dev
- run: sudo docker-php-ext-install zip
- run: sudo docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
- run: sudo -E docker-php-ext-install -j$(nproc) gd exif
- run: sudo composer self-update

# Composer cache
- restore_cache:
keys:
- composer-v1-{{ checksum "composer.lock" }}
- composer-v1-
- run: composer install -n --ignore-platform-reqs --prefer-dist
- save_cache:
key: composer-v1-{{ checksum "composer.lock" }}
paths:
- vendor

- run:
name: Setup Environment
command: |
cp .env.testing .env
php artisan key:generate
php artisan passport:keys
touch ./storage/logs/laravel.log
chmod 600 storage/oauth-private.key
chmod 600 storage/oauth-public.key
- run:
name: Run Unit Tests
command: ./vendor/bin/phpunit -d memory_limit=512M --log-junit logs/phpunit/junit.xml --testdox-html logs/phpunit/testdox.html

- store_artifacts:
path: ./logs/phpunit
destination: phpunit

- store_artifacts:
path: ./storage/logs
destination: logs
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
57 changes: 57 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_ADMIN_URL=
APP_CLIENT_URL=

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

PASSPORT_PGC_SECRET=


FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
FACEBOOK_REDIRECT="${APP_CLIENT_URL}/callback/facebook"
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT="${APP_CLIENT_URL}/callback/google"

57 changes: 57 additions & 0 deletions .env.heroku
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_ADMIN_URL=
APP_CLIENT_URL=

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

PASSPORT_PGC_SECRET=


FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
FACEBOOK_REDIRECT="${APP_CLIENT_URL}/callback/facebook"
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT="${APP_CLIENT_URL}/callback/google"

19 changes: 19 additions & 0 deletions .env.testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
APP_ENV=testing
PWA_URL=http://localhost:3000

APP_DEBUG=true
APP_KEY=27ceqUDGvdm77abRFSNQbFSVFIz4dGIH

LOG_CHANNEL=single

DB_CONNECTION=sqlite
DB_DATABASE=:memory:

CACHE_DRIVER=array
MAIL_DRIVER=array
QUEUE_CONNECTION=sync
SESSION_DRIVER=array

TELESCOPE_ENABLED=false

PASSPORT_PGC_SECRET=cecA1YWV5PDC8hFORGXexo3wH9NTGlFxGPgSDepQ
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.idea
/node_modules
/public/hot
/public/storage
/storage/*.key
/storage/tracks
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.vscode/launch.json
13 changes: 13 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
php:
preset: laravel
disabled:
- unused_use
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Stephen Martin

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.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: vendor/bin/heroku-php-apache2 public/
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

🛒🤖 VendorMachine™
===================
A free and opensource multi vendor Marketplace
--------------------------

Documentation and information is updated on https://github.com/squareborg/vendormachine-frontend



35 changes: 35 additions & 0 deletions app/Actions/Products/CreateProductAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\Actions\Products;

use App\Exceptions\Vendor\ManageProductsPermissionDeniedException;
use App\Models\Vendor;
use App\Models\User;
use App\Models\Products\Product;
use App\Events\ProductCreated;

final class CreateProductAction
{
public function __invoke(array $data): Product
{
$user = User::find($data['user_id']);
$vendor = Vendor::find($data['vendor_id']);
if ($user->can('manageProducts', $vendor)){
$vendor = Vendor::find($data['vendor_id']);
$product = $vendor->products()->create([
'name' => $data['name'],
'description' => $data['description'],
]);

$product->variants()->create([
'price' => $data['price']
]);

event(new ProductCreated($product));
return $product;
} else {
throw new ManageProductsPermissionDeniedException('User is not allowed to manage this vendors products');
}

}
}
23 changes: 23 additions & 0 deletions app/Actions/Products/UpdateProductAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace App\Actions\Products;

use App\DTO\Products\ProductData;
use App\Models\Products\Product;
use App\Events\Vendors\Products\ProductUpdated;

final class UpdateProductAction
{
public function __invoke(ProductData $productData, Product $product): product
{
$product->update([
'name' => $productData->name,
'description' => $productData->description
]);
$product->variants()->first()->update([
'price' => $productData->variants['data'][0]['price']
]);
event(new ProductUpdated($product));
return $product->refresh();
}
}
17 changes: 17 additions & 0 deletions app/Actions/Settings/UpdateSettingAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Actions\Settings;

use App\Models\Setting;
use App\DTO\Settings\SettingData;

final class UpdateSettingAction
{
public function __invoke(SettingData $data): Setting
{
return Setting::updateOrCreate(
['key' => $data->key],
['value' => $data->value]
);
}
}
26 changes: 26 additions & 0 deletions app/Actions/Users/CreateUserAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\Actions\Users;

use App\DTO\UserData;
use App\Models\User;
use App\Notifications\Auth\VerifyEmail;
use Spatie\Permission\Models\Role;

final class CreateUserAction
{
public function __invoke(UserData $userData): User
{
$user = User::create([
'name' => $userData->name,
'email' => $userData->email,
'password' => bcrypt($userData->password),
]);

$user->assignRole('user');
$user->generateVerificationToken();
$user->notify(new VerifyEmail());

return $user;
}
}
13 changes: 13 additions & 0 deletions app/Actions/Users/DeleteUserAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Actions\Users;

use App\Models\User;

final class DeleteUserAction
{
public function __invoke(User $user): void
{
$user->delete();
}
}
Loading

0 comments on commit bfeec0e

Please sign in to comment.