├── .editorconfig
├── .env.example
├── .gitattributes
├── .gitignore
├── _ide_helper.php
├── app
├── Console
│ ├── Commands
│ │ └── ProjectRebuild.php
│ └── Kernel.php
├── Exceptions
│ └── Handler.php
├── Http
│ ├── Controllers
│ │ ├── Api
│ │ │ └── v1
│ │ │ │ ├── Cart
│ │ │ │ └── CartController.php
│ │ │ │ ├── Category
│ │ │ │ └── CategoryController.php
│ │ │ │ ├── Order
│ │ │ │ └── OrderController.php
│ │ │ │ ├── Product
│ │ │ │ └── ProductController.php
│ │ │ │ ├── Review
│ │ │ │ └── ReviewController.php
│ │ │ │ ├── Shipping
│ │ │ │ └── ShippingMethodController.php
│ │ │ │ └── User
│ │ │ │ └── UserController.php
│ │ ├── Controller.php
│ │ └── HomeController.php
│ ├── Foundation
│ │ └── CustomFormRequest.php
│ ├── Kernel.php
│ ├── Middleware
│ │ ├── Authenticate.php
│ │ ├── CheckClientSecret.php
│ │ ├── CheckForMaintenanceMode.php
│ │ ├── EncryptCookies.php
│ │ ├── RedirectIfAuthenticated.php
│ │ ├── TrimStrings.php
│ │ ├── TrustProxies.php
│ │ └── VerifyCsrfToken.php
│ ├── Requests
│ │ ├── Auth
│ │ │ └── RegisterRequest.php
│ │ └── User
│ │ │ ├── ForgotPasswordRequest.php
│ │ │ ├── LoginRequest.php
│ │ │ ├── RegisterRequest.php
│ │ │ ├── SaveBillingAddressRequest.php
│ │ │ ├── SaveDeliveryAddressRequest.php
│ │ │ └── SaveRequest.php
│ ├── Resources
│ │ ├── Category
│ │ │ ├── CategoryCollection.php
│ │ │ └── CategoryResource.php
│ │ ├── Order
│ │ │ ├── OrderCollection.php
│ │ │ └── OrderResource.php
│ │ ├── Product
│ │ │ ├── Image
│ │ │ │ ├── ProductImageCollection.php
│ │ │ │ └── ProductImageResource.php
│ │ │ ├── ProductCollection.php
│ │ │ └── ProductResource.php
│ │ ├── Review
│ │ │ ├── ReviewCollection.php
│ │ │ └── ReviewResource.php
│ │ ├── Shipping
│ │ │ ├── ShippingMethodsCollection.php
│ │ │ └── ShippingMethodsResource.php
│ │ └── User
│ │ │ └── UserResource.php
│ └── helpers.php
├── Models
│ ├── Cache
│ │ └── CacheProfile.php
│ ├── OauthClient.php
│ ├── Post.php
│ ├── Product.php
│ └── User.php
├── Policies
│ └── UserPolicy.php
├── Providers
│ ├── AppServiceProvider.php
│ ├── AuthServiceProvider.php
│ ├── BroadcastServiceProvider.php
│ ├── EventServiceProvider.php
│ └── RouteServiceProvider.php
├── Services
│ ├── Auth
│ │ ├── PasswordService.php
│ │ └── RegisterService.php
│ ├── WoocommerceCartService.php
│ ├── WoocommerceService.php
│ └── WordpressService.php
└── Traits
│ └── PassportToken.php
├── artisan
├── bootstrap
├── app.php
└── cache
│ └── .gitignore
├── composer.json
├── composer.lock
├── config
├── app.php
├── auth.php
├── broadcasting.php
├── cache.php
├── corcel.php
├── database.php
├── filesystems.php
├── hashing.php
├── logging.php
├── mail.php
├── queue.php
├── responsecache.php
├── services.php
├── session.php
├── view.php
└── wordpress.php
├── database
├── .gitignore
├── factories
│ └── UserFactory.php
├── migrations
│ ├── 2014_10_12_100000_create_password_resets_table.php
│ ├── 2019_02_04_133147_create_sessions_table.php
│ └── 2019_02_11_092112_create_cache_table.php
└── seeds
│ └── DatabaseSeeder.php
├── package.json
├── phpunit.xml
├── public
├── css
│ └── app.css
├── favicon.ico
├── index.php
├── js
│ └── app.js
├── robots.txt
├── svg
│ ├── 403.svg
│ ├── 404.svg
│ ├── 500.svg
│ └── 503.svg
└── web.config
├── readme.md
├── resources
├── js
│ ├── app.js
│ ├── bootstrap.js
│ └── components
│ │ └── ExampleComponent.vue
├── lang
│ └── en
│ │ ├── auth.php
│ │ ├── pagination.php
│ │ ├── passwords.php
│ │ └── validation.php
├── sass
│ ├── _variables.scss
│ └── app.scss
└── views
│ ├── auth
│ ├── login.blade.php
│ ├── passwords
│ │ ├── email.blade.php
│ │ └── reset.blade.php
│ ├── register.blade.php
│ └── verify.blade.php
│ ├── home.blade.php
│ ├── layouts
│ └── app.blade.php
│ ├── vendor
│ └── l5-swagger
│ │ ├── .gitkeep
│ │ └── index.blade.php
│ └── welcome.blade.php
├── routes
├── api.php
├── api
│ └── mobile-v1.php
├── channels.php
├── console.php
└── web.php
├── server.php
├── storage
├── api-docs
│ └── api-docs.json
├── app
│ ├── .gitignore
│ └── public
│ │ └── .gitignore
├── framework
│ ├── .gitignore
│ ├── sessions
│ │ └── .gitignore
│ └── testing
│ │ └── .gitignore
└── logs
│ └── .gitignore
├── tests
├── CreatesApplication.php
├── Feature
│ └── ExampleTest.php
├── TestCase.php
└── Unit
│ └── ExampleTest.php
└── webpack.mix.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | insert_final_newline = true
7 | indent_style = space
8 | indent_size = 4
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
14 | [*.yml]
15 | indent_size = 2
16 |
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | APP_NAME=Laravel
2 | APP_ENV=local
3 | APP_KEY=base64:wzHgierz1ALoUih7EwhHn7+NvfYmScOVkTo/7XMPRSY=
4 | APP_DEBUG=true
5 | APP_URL=https://haze420appdev.loc
6 |
7 | LOG_CHANNEL=stack
8 |
9 | DB_CONNECTION=mysql
10 | DB_HOST=127.0.0.1
11 | DB_PORT=3306
12 | DB_DATABASE=laravel_haze420appdev
13 | DB_USERNAME=homestead
14 | DB_PASSWORD=secret
15 |
16 | #SERVER CONNECTION WORDPRESS DB
17 | WP_DB_HOST=77.104.132.139
18 | WP_DB_PORT=3306
19 | WP_DB_DATABASE=haze4209_wp3e8b
20 | WP_DB_USERNAME=haze4209_test
21 | WP_DB_PASSWORD=T,-f*T-,(155
22 | WP_DB_PREFIX=wpc6_
23 | WP_DB_SOCKET=
24 |
25 | #SERVER CONNECTION Woocommerce REST Api
26 | WP_WC_DOMAIN=www.haze420.co.uk
27 | WP_WC_URL=https://www.haze420.co.uk
28 | WP_WC_CONSUMER_KEY=ck_0f6cc5aeab1499b6815871a80700a5ccce3c55bb
29 | WP_WC_CONSUMER_SECRET=cs_36e0dde1d65bf5c3fa35e01f30a475a65a0e6cfb
30 |
31 | RESPONSE_CACHE_ENABLED=false
32 | RESPONSE_CACHE_LIFETIME=60*24*7
33 | RESPONSE_CACHE_DRIVER=file
34 |
35 | BROADCAST_DRIVER=log
36 | CACHE_DRIVER=file
37 | QUEUE_CONNECTION=sync
38 | SESSION_DRIVER=file
39 | SESSION_LIFETIME=12000
40 |
41 | REDIS_HOST=127.0.0.1
42 | REDIS_PASSWORD=null
43 | REDIS_PORT=6379
44 |
45 | MAIL_DRIVER=smtp
46 | MAIL_HOST=smtp.mailtrap.io
47 | MAIL_PORT=2525
48 | MAIL_USERNAME=6286e2a7185c7e
49 | MAIL_PASSWORD=2b53aa3a45fa9a
50 | MAIL_ENCRYPTION=tls
51 |
52 | PUSHER_APP_ID=
53 | PUSHER_APP_KEY=
54 | PUSHER_APP_SECRET=
55 | PUSHER_APP_CLUSTER=mt1
56 |
57 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
58 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
59 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | *.css linguist-vendored
3 | *.scss linguist-vendored
4 | *.js linguist-vendored
5 | CHANGELOG.md export-ignore
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /public/hot
3 | /public/docs
4 | /public/storage
5 | /storage/*.key
6 | /vendor
7 | /.idea
8 | /.vscode
9 | /.vagrant
10 | Homestead.json
11 | Homestead.yaml
12 | npm-debug.log
13 | yarn-error.log
14 | .env
15 | .DS_Store
16 | /storage/framework/views
17 | /storage/framework/cache
18 | .htaccess
--------------------------------------------------------------------------------
/app/Console/Commands/ProjectRebuild.php:
--------------------------------------------------------------------------------
1 | command('inspire')
28 | // ->hourly();
29 | }
30 |
31 | /**
32 | * Register the commands for the application.
33 | *
34 | * @return void
35 | */
36 | protected function commands()
37 | {
38 | $this->load(__DIR__.'/Commands');
39 |
40 | require base_path('routes/console.php');
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/Exceptions/Handler.php:
--------------------------------------------------------------------------------
1 | expectsJson()
50 | ? response()->Error($exception->getMessage())
51 | : redirect()->guest(route('login'));
52 | }
53 |
54 | /**
55 | * Render an exception into an HTTP response.
56 | *
57 | * @param \Illuminate\Http\Request $request
58 | * @param \Exception $exception
59 | * @return \Illuminate\Http\Response
60 | */
61 | public function render($request, Exception $exception)
62 | {
63 | return parent::render($request, $exception);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/v1/Cart/CartController.php:
--------------------------------------------------------------------------------
1 | cartService = $cartService;
21 | }
22 |
23 | /**
24 | * @return mixed
25 | * @throws \GuzzleHttp\Exception\GuzzleException
26 | */
27 | public function getCartList()
28 | {
29 | $cartList = $this->cartService->get();
30 |
31 | $cookies = collect($cartList['headers'])->only('Set-Cookie')->toArray();
32 |
33 | return response()->Success($cartList['data'], 200, $cookies);
34 | }
35 |
36 |
37 | /**
38 | * @param Request $request
39 | *
40 | * @return mixed
41 | * @throws \GuzzleHttp\Exception\GuzzleException
42 | */
43 | public function addToCart(Request $request)
44 | {
45 | $data = $request->only('product_id', 'quantity');
46 |
47 | $product = $this->cartService->post('add', $data);
48 |
49 | $cookies = collect($product['headers'])->only('Set-Cookie')->toArray();
50 |
51 | return response()->Success($product['data'], 200, $cookies);
52 | }
53 |
54 | /**
55 | * @param Request $request
56 | *
57 | * @return mixed
58 | * @throws \GuzzleHttp\Exception\GuzzleException
59 | */
60 | public function removeFromCart(Request $request)
61 | {
62 | $data = $request->only('cart_item_key');
63 |
64 | $response = $this->cartService->delete('cart-item', $data);
65 |
66 | $cookies = collect($response['headers'])->only('Set-Cookie')->toArray();
67 |
68 | return response()->Success($response['data'], 200, $cookies);
69 | }
70 |
71 | /**
72 | * @return mixed
73 | * @throws \GuzzleHttp\Exception\GuzzleException
74 | */
75 | public function clearCart() {
76 | $response = $this->cartService->post('clear');
77 |
78 | $cookies = collect($response['headers'])->only('Set-Cookie')->toArray();
79 |
80 | return response()->Success($response['data'], 200, $cookies);
81 | }
82 |
83 |
84 | /**
85 | * @param Request $request
86 | *
87 | * @return mixed|null|\Psr\Http\Message\ResponseInterface
88 | * @throws \GuzzleHttp\Exception\GuzzleException
89 | */
90 | public function updateItemCart(Request $request)
91 | {
92 | $data = $request->only('cart_item_key', 'quantity');
93 |
94 | $response = $this->cartService->post('cart-item', $data);
95 |
96 | $cookies = collect($response['headers'])->only('Set-Cookie')->toArray();
97 |
98 | return response()->Success($response['data'], 200, $cookies);
99 | }
100 |
101 |
102 | /**
103 | * @return mixed
104 | * @throws \GuzzleHttp\Exception\GuzzleException
105 | */
106 | public function getTotalsCart() {
107 | $response = $this->cartService->get('totals');
108 |
109 | $cookies = collect($response['headers'])->only('Set-Cookie')->toArray();
110 |
111 | return response()->Success($response['data'], 200, $cookies);
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/v1/Category/CategoryController.php:
--------------------------------------------------------------------------------
1 | service = $service;
21 | }
22 |
23 |
24 | /**
25 | * @return mixed
26 | */
27 | public function getList()
28 | {
29 | $parameters = [
30 | 'page' => $data['page'] ?? 1,
31 | 'per_page' => $data['per_page'] ?? 10,
32 | 'order' => $data['order'] ?? 'asc',
33 | 'orderby' => $data['orderby'] ?? 'name',
34 | 'exclude' => [16, 38]
35 | ];
36 |
37 | $categories = $this->service->get('products/categories', $parameters);
38 |
39 | return response()->Success(new CategoryCollection($categories['data']));
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/v1/Order/OrderController.php:
--------------------------------------------------------------------------------
1 | service = $service;
23 | }
24 |
25 |
26 | /**
27 | * @param Request $request
28 | *
29 | * @return mixed
30 | */
31 | public function getOrders(Request $request)
32 | {
33 | $data = $request->all();
34 |
35 | $orders = $this->service->get('orders',
36 | [
37 | 'customer' => Auth::user()->ID,
38 | 'page' => $data['page'] ?? 1,
39 | 'per_page' => $data['per_page'] ?? 10,
40 | 'order' => $data['order'] ?? 'desc',
41 | 'orderby' => $data['orderby'] ?? 'date',
42 | 'status' => $data['status'] ?? 'any',
43 | 'search' => $data['search_string'] ?? ''
44 | ]);
45 |
46 | return response()->Success(new OrderCollection($orders['data']));
47 | }
48 | }
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/v1/Product/ProductController.php:
--------------------------------------------------------------------------------
1 | service = $service;
23 | }
24 |
25 | /**
26 | * @param Request $request
27 | *
28 | * @return ProductCollection
29 | */
30 | public function getList(Request $request)
31 | {
32 | $data = $request->all();
33 |
34 | $parameters = collect([
35 | 'page' => $data['page'] ?? 1,
36 | 'per_page' => $data['per_page'] ?? 10,
37 | 'offset' => $data['offset'] ?? 0,
38 | 'order' => $data['order'] ?? 'desc',
39 | 'orderby' => $data['orderby'] ?? 'date',
40 | 'min_price' => $data['min_price'] ?? '',
41 | 'max_price' => $data['max_price'] ?? '',
42 | 'search' => $data['search'] ?? ''
43 | ]);
44 |
45 | if($request->has('category')){
46 | $parameters->prepend($data['category'], 'category');
47 | }
48 |
49 | if($request->has('on_sale')){
50 | $parameters->prepend($data['on_sale'], 'on_sale');
51 | }
52 |
53 | if($request->has('stock_status')){
54 | $parameters->prepend($data['stock_status'], 'stock_status');
55 | }
56 |
57 | $products = $this->service->get('products', $parameters->toArray());
58 |
59 | return response()->Success(new ProductCollection($products['data']));
60 | }
61 |
62 |
63 | /**
64 | * @param Request $request
65 | * @param $product_id
66 | *
67 | * @return ProductResource
68 | */
69 | public function getDetails(Request $request, $product_id)
70 | {
71 | $product = $this->service->get('products/' . $product_id);
72 |
73 | $this->service->get('products/'.$product_id);
74 |
75 | return response()->Success(new ProductResource($product['data']));
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/v1/Review/ReviewController.php:
--------------------------------------------------------------------------------
1 | service = $service;
24 | }
25 |
26 |
27 | /**
28 | * @param Request $request
29 | *
30 | * @return mixed
31 | */
32 | public function getReviews(Request $request)
33 | {
34 | $data = $request->all();
35 |
36 | $reviews = $this->service->get('products/reviews/',
37 | [
38 | 'product' => $data['product'],
39 | 'page' => $data['page'] ?? 1,
40 | 'per_page' => $data['per_page'] ?? 10,
41 | 'order' => $data['order'] ?? 'desc',
42 | 'orderby' => $data['orderby'] ?? 'date_gmt',
43 | 'status' => $data['status'] ?? 'any',
44 | 'search' => $data['search'] ?? ''
45 | ]);
46 |
47 | return response()->Success(new ReviewCollection($reviews['data']));
48 | }
49 |
50 |
51 | /**
52 | * @param string $id
53 | *
54 | * @return mixed
55 | */
56 | public function getReviewById($id = '')
57 | {
58 | $review = $this->service->get('products/reviews/' . $id);
59 |
60 | return response()->Success(new ReviewResource($review['data']));
61 | }
62 |
63 |
64 | /**
65 | * @param Request $request
66 | *
67 | * @return mixed
68 | */
69 | public function postReview(Request $request)
70 | {
71 | $data = $request->all();
72 | $user = Auth::user();
73 |
74 | $review = $this->service->post('products/reviews',
75 | [
76 | 'product_id' => $data['product_id'],
77 | 'review' => $data['review'],
78 | 'reviewer' => $user->first_name . ' ' . $user->last_name,
79 | 'reviewer_email' => $user->email,
80 | 'rating' => $data['rating']
81 | ]);
82 |
83 | return response()->Success(new ReviewResource($review['data']));
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/v1/Shipping/ShippingMethodController.php:
--------------------------------------------------------------------------------
1 | woocommerceService = $woocommerceService;
22 | }
23 |
24 |
25 | /**
26 | * @return mixed
27 | */
28 | public function getList()
29 | {
30 | $shipping_methods = $this->woocommerceService->get('shipping_methods');
31 |
32 | return response()->Success(new ShippingMethodsCollection($shipping_methods['data']));
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/v1/User/UserController.php:
--------------------------------------------------------------------------------
1 | wordpressService = $wordpressService;
31 | }
32 |
33 |
34 | /**
35 | * @param LoginRequest $request
36 | *
37 | * @return mixed
38 | */
39 | public function login(LoginRequest $request)
40 | {
41 | $credentials = $request->only('email', 'password');
42 |
43 | $response
44 | = Response::Error('The email or password you entered is incorrect.');
45 |
46 | if (Auth::attempt($credentials)) {
47 | $data['jwt_token'] = Auth::user()
48 | ->createToken('User Access Token')->accessToken;
49 | $response = Response::Success($data);
50 | }
51 |
52 | return $response;
53 | }
54 |
55 |
56 | /**
57 | * @param RegisterRequest $request
58 | *
59 | * @return mixed
60 | */
61 | public function register(RegisterRequest $request)
62 | {
63 | $data = $request->validated();
64 |
65 | $userCheck = User::where(function ($query) use ($data) {
66 | $query->where('user_login', $data['email']);
67 | $query->orWhere('user_email', $data['email']);
68 | })->exists();
69 |
70 | if ($userCheck) {
71 | $response
72 | = Response::Error('An account is already registered with your email address. Please log in.');
73 | } else {
74 | $user = new User;
75 | $user->user_login = $data['email'];
76 | $user->user_pass = $data['password'];
77 | $user->user_email = $data['email'];
78 | $user->save();
79 |
80 | $user->saveMeta([
81 | 'description' => $data['birthday'],
82 | 'phone' => $data['phone'],
83 | ]);
84 |
85 | $response = Response::Success();
86 | }
87 |
88 | return $response;
89 | }
90 |
91 |
92 | /**
93 | * @param ForgotPasswordRequest $request
94 | *
95 | * @return mixed|\Psr\Http\Message\ResponseInterface|null
96 | * @throws \GuzzleHttp\Exception\GuzzleException
97 | */
98 | public function forgotPassword(ForgotPasswordRequest $request)
99 | {
100 | $data = $request->validated();
101 |
102 | $response = $this->wordpressService->post('users/lostpassword',[
103 | 'user_login' => $data['email']
104 | ]);
105 |
106 | $data = collect($response['data'])->only('message');
107 |
108 | // Check Errors
109 | if(!$response['success']){
110 | $response = Response::Error($data['message']);
111 | }else{
112 | $response = Response::Success($data);
113 | }
114 |
115 | return $response;
116 | }
117 |
118 | /**
119 | * @return mixed
120 | */
121 | public function getUser()
122 | {
123 | return Response::Success(new UserResource(Auth::user()));
124 | }
125 |
126 | /**
127 | * @param SaveRequest $request
128 | *
129 | * @return mixed
130 | */
131 | public function saveUser(SaveRequest $request)
132 | {
133 | $data = $request->validated();
134 |
135 | $userCheck = User::where(function ($query) use ($data) {
136 | $query->where('user_login', $data['email']);
137 | $query->orWhere('user_email', $data['email']);
138 | })->exists();
139 |
140 | if ($userCheck && $data['email'] !== Auth::user()->email) {
141 | $response
142 | = Response::Error('An account is already registered with your email address. Please log in.');
143 | } else {
144 | Auth::user()->save([
145 | 'email' => $data['email']
146 | ]);
147 |
148 | Auth::user()->saveMeta([
149 | 'first_name' => $data['first_name'],
150 | 'last_name' => $data['last_name'],
151 | 'description' => $data['birthday'],
152 | 'phone' => $data['phone']
153 | ]);
154 |
155 | $response = Response::Success();
156 | }
157 |
158 |
159 | return $response;
160 | }
161 |
162 | /**
163 | * @param SaveBillingAddressRequest $request
164 | *
165 | * @return mixed
166 | */
167 | public function saveBillingAddress(SaveBillingAddressRequest $request)
168 | {
169 | $data = $request->validated();
170 |
171 | Auth::user()->saveMeta([
172 | 'billing_first_name' => $data['first_name'],
173 | 'billing_last_name' => $data['last_name'],
174 | 'billing_address_1' => $data['address_1'],
175 | 'billing_address_2' => $data['address_2'],
176 | 'billing_city' => $data['city'],
177 | 'billing_postcode' => $data['postcode'],
178 | 'billing_country' => $data['country'],
179 | 'billing_state' => $data['state'],
180 | 'billing_phone' => $data['phone']
181 | ]);
182 |
183 | return Response::Success();
184 | }
185 |
186 |
187 | /**
188 | * @param SaveDeliveryAddressRequest $request
189 | *
190 | * @return mixed
191 | */
192 | public function saveDeliveryAddress(SaveDeliveryAddressRequest $request)
193 | {
194 | $data = $request->validated();
195 |
196 | Auth::user()->saveMeta([
197 | 'shipping_address_1' => $data['address_1'],
198 | 'shipping_address_2' => $data['address_2'],
199 | 'shipping_city' => $data['city'],
200 | 'shipping_postcode' => $data['postcode'],
201 | 'shipping_country' => $data['country'],
202 | 'shipping_state' => $data['state'],
203 | 'shipping_additional_instruction' => $data['additional_instruction']
204 | ]);
205 |
206 | return Response::Success();
207 | }
208 | }
209 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Controller.php:
--------------------------------------------------------------------------------
1 | service = $service;
17 | // $this->client = new Client([
18 | // 'base_uri' => config('wordpress.WP_WC_URL')
19 | // . '/wp-json/wc/v2/cart/',
20 | // 'Accept' => 'application/json',
21 | // 'cookies' => true
22 | // ]);
23 | }
24 |
25 | /**
26 | * Show the application dashboard.
27 | *
28 | * @return \Illuminate\Contracts\Support\Renderable
29 | */
30 | public function index()
31 | {
32 | return $this->service->post('add', [
33 | 'product_id' => 1461,
34 | 'quantity' => 100
35 | ]);
36 |
37 | // $value = Cache::get('key');
38 | // $expiresAt = now()->addMinutes(10);
39 |
40 | // Cache::put('key', 'value', $expiresAt);
41 |
42 | // return dd($this->service->post('products/reviews',
43 | // [
44 | // 'product_id' => 10,
45 | // 'review' => 10,
46 | // 'reviewer' => 10,
47 | // 'reviewer_email' => 10,
48 | // 'rating' => 10
49 | // ]));
50 | $response = $this->service->get();
51 |
52 | return $response;
53 | }
54 |
55 | public function get() {
56 |
57 | // $cookieJar = CookieJar::fromArray(Cookie::get(), 'haze420.co.uk');
58 | //
59 | // $product = $this->client->request('GET', '', ['cookies' => $cookieJar]);
60 | //
61 | // dd(json_decode($product->getBody()->getContents()));
62 | //
63 | // return response()->json([]);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/app/Http/Foundation/CustomFormRequest.php:
--------------------------------------------------------------------------------
1 | Error(implode(" ", $validator->errors()->all()), 400));
23 | }
24 |
25 | }
--------------------------------------------------------------------------------
/app/Http/Kernel.php:
--------------------------------------------------------------------------------
1 | [
31 | \App\Http\Middleware\EncryptCookies::class,
32 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
33 | \Illuminate\Session\Middleware\StartSession::class,
34 | // \Illuminate\Session\Middleware\AuthenticateSession::class,
35 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
36 | \App\Http\Middleware\VerifyCsrfToken::class,
37 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
38 | \Spatie\ResponseCache\Middlewares\CacheResponse::class
39 | ],
40 |
41 | 'api' => [
42 | 'throttle:60,1',
43 | 'bindings',
44 | \Spatie\ResponseCache\Middlewares\CacheResponse::class
45 | ],
46 | ];
47 |
48 | /**
49 | * The application's route middleware.
50 | *
51 | * These middleware may be assigned to groups or used individually.
52 | *
53 | * @var array
54 | */
55 | protected $routeMiddleware = [
56 | 'auth' => \App\Http\Middleware\Authenticate::class,
57 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
58 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
59 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
60 | 'can' => \Illuminate\Auth\Middleware\Authorize::class,
61 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
62 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
63 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
64 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
65 | 'passport.client' => \App\Http\Middleware\CheckClientSecret::class,
66 | 'doNotCacheResponse' => \Spatie\ResponseCache\Middlewares\DoNotCacheResponse::class,
67 | 'cacheResponse' => \Spatie\ResponseCache\Middlewares\CacheResponse::class
68 | ];
69 |
70 | /**
71 | * The priority-sorted list of middleware.
72 | *
73 | * This forces non-global middleware to always be in the given order.
74 | *
75 | * @var array
76 | */
77 | protected $middlewarePriority = [
78 | \Illuminate\Session\Middleware\StartSession::class,
79 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
80 | \App\Http\Middleware\Authenticate::class,
81 | \Illuminate\Session\Middleware\AuthenticateSession::class,
82 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
83 | \Illuminate\Auth\Middleware\Authorize::class,
84 | ];
85 | }
86 |
--------------------------------------------------------------------------------
/app/Http/Middleware/Authenticate.php:
--------------------------------------------------------------------------------
1 | validate([
20 | 'client_id' => 'required|int',
21 | 'client_secret' => [
22 | 'required',
23 | Rule::in([OauthClient::findOrFail($request->client_id)->secret])
24 | ]
25 | ]);
26 |
27 | return $next($request);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/Http/Middleware/CheckForMaintenanceMode.php:
--------------------------------------------------------------------------------
1 | check()) {
21 | return redirect('/home');
22 | }
23 |
24 | return $next($request);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrimStrings.php:
--------------------------------------------------------------------------------
1 | 'required|email|unique:users',
28 | 'password' => 'required|min:8',
29 | 'phone' => 'required|unique:users',
30 | 'birthday' => 'required|date'
31 | ];
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/Http/Requests/User/ForgotPasswordRequest.php:
--------------------------------------------------------------------------------
1 | 'required|email'
28 | ];
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/Http/Requests/User/LoginRequest.php:
--------------------------------------------------------------------------------
1 | 'required|email',
28 | 'password' => 'required'
29 | ];
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/Http/Requests/User/RegisterRequest.php:
--------------------------------------------------------------------------------
1 | 'required|string|email|max:255',
28 | 'password' => 'required|string|min:6',
29 | 'phone' => 'required',
30 | 'birthday' => 'required',
31 | ];
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/Http/Requests/User/SaveBillingAddressRequest.php:
--------------------------------------------------------------------------------
1 | 'string|max:255',
28 | 'last_name' => 'string|max:255',
29 | 'company' => 'string|max:255',
30 | 'address_1' => 'string|max:255',
31 | 'address_2' => 'nullable|string|max:255',
32 | 'city' => 'string|max:255',
33 | 'postcode' => 'max:255',
34 | 'country' => 'string|max:255',
35 | 'state' => 'string|max:255',
36 | 'phone' => 'string|max:255'
37 | ];
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/Http/Requests/User/SaveDeliveryAddressRequest.php:
--------------------------------------------------------------------------------
1 | 'nullable|string|max:255',
28 | 'address_2' => 'nullable|string|max:255',
29 | 'city' => 'nullable|string|max:255',
30 | 'postcode' => 'nullable|max:255',
31 | 'country' => 'nullable|string|max:255',
32 | 'state' => 'nullable|string|max:255',
33 | 'additional_instruction' => 'nullable|string|max:1000'
34 | ];
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/Http/Requests/User/SaveRequest.php:
--------------------------------------------------------------------------------
1 | 'required|string|max:255',
28 | 'last_name' => 'required|string|max:255',
29 | 'email' => 'required|string|email|max:255',
30 | 'password' => 'string|min:6',
31 | 'phone' => 'required',
32 | 'birthday' => 'required'
33 | ];
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/Http/Resources/Category/CategoryCollection.php:
--------------------------------------------------------------------------------
1 | collection->transform(function ($product) {
18 | return (new CategoryResource($product));
19 | });
20 |
21 |
22 | return parent::toArray($request);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/Http/Resources/Category/CategoryResource.php:
--------------------------------------------------------------------------------
1 | $this->id,
19 | 'name' => $this->name,
20 | 'slug' => $this->slug,
21 | 'description' => $this->description,
22 | 'image' => $this->image,
23 | 'menu_order' => $this->menu_order
24 | ];
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Resources/Order/OrderCollection.php:
--------------------------------------------------------------------------------
1 | collection->transform(function ($order) {
18 | return (new OrderResource($order));
19 | });
20 |
21 | return parent::toArray($request);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/Http/Resources/Order/OrderResource.php:
--------------------------------------------------------------------------------
1 | $this->id,
20 | 'parent_id' => $this->parent_id,
21 | 'customer_id' => $this->customer_id,
22 | 'number' => $this->number,
23 | 'order_key' => $this->order_key,
24 | 'status' => $this->status,
25 | 'currency' => $this->currency,
26 | 'date_created' => $this->date_created,
27 | 'total' => $this->total,
28 | 'billing' => $this->billing,
29 | 'shipping' => $this->shipping,
30 | 'payment_method' => $this->payment_method
31 | ];
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/Http/Resources/Product/Image/ProductImageCollection.php:
--------------------------------------------------------------------------------
1 | collection->transform(function ($product) {
19 | return (new ProductImageResource($product));
20 | });
21 |
22 |
23 | return parent::toArray($request);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/Http/Resources/Product/Image/ProductImageResource.php:
--------------------------------------------------------------------------------
1 | $this->woocommerce_thumbnail,
20 | 'gallery_thumbnail' => $this->woocommerce_gallery_thumbnail,
21 | ];
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/Http/Resources/Product/ProductCollection.php:
--------------------------------------------------------------------------------
1 | collection->transform(function ($product) {
19 | return (new ProductResource($product));
20 | });
21 |
22 |
23 | return parent::toArray($request);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/Http/Resources/Product/ProductResource.php:
--------------------------------------------------------------------------------
1 | images);
20 |
21 | return [
22 | 'id' => $this->id,
23 | 'categories' => $this->categories,
24 | 'name' => $this->name,
25 | 'slug' => $this->slug,
26 | 'permalink' => $this->permalink,
27 | 'description' => $this->description,
28 | 'thumbnail_image' => $images->first()->woocommerce_gallery_thumbnail,
29 | 'images' => new ProductImageCollection($images),
30 | 'weight' => $this->weight,
31 | 'price' => $this->price,
32 | 'regular_price' => $this->regular_price,
33 | 'sale_price' => $this->sale_price,
34 | "average_rating" => $this->average_rating,
35 | "rating_count" => $this->rating_count,
36 | 'attributes' => [
37 | 'weight' => collect($this->attributes)
38 | ->where('name', 'Weight')->first()->options,
39 | 'thc_level' => collect($this->attributes)
40 | ->where('name', 'THC')->first()->options
41 | ]
42 | ];
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/Http/Resources/Review/ReviewCollection.php:
--------------------------------------------------------------------------------
1 | collection->transform(function ($review) {
18 | return (new ReviewResource($review));
19 | });
20 |
21 |
22 | return parent::toArray($request);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/Http/Resources/Review/ReviewResource.php:
--------------------------------------------------------------------------------
1 | $this->id,
20 | 'product_id' => $this->product_id,
21 | 'date_created' => $this->date_created,
22 | 'status' => $this->status,
23 | 'reviewer' => $this->reviewer,
24 | 'reviewer_email' => $this->reviewer_email,
25 | 'review' => $this->review,
26 | 'rating' => $this->rating,
27 | 'reviewer_avatar_urls' => $this->reviewer_avatar_urls
28 | ];
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/Http/Resources/Shipping/ShippingMethodsCollection.php:
--------------------------------------------------------------------------------
1 | collection->transform(function ($review) {
18 | return (new ShippingMethodsResource($review));
19 | });
20 |
21 |
22 | return parent::toArray($request);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/Http/Resources/Shipping/ShippingMethodsResource.php:
--------------------------------------------------------------------------------
1 | $this->id,
20 | 'title' => $this->title,
21 | 'description' => $this->description
22 | ];
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/Http/Resources/User/UserResource.php:
--------------------------------------------------------------------------------
1 | $this->ID,
20 | 'user_email' => $this->user_email,
21 | 'first_name' => $this->first_name,
22 | 'last_name' => $this->last_name,
23 | 'birthday' => $this->meta->description,
24 | "phone" => $this->meta->phone,
25 | 'avatar' => 'https:' . $this->avatar,
26 | 'billing_address' => [
27 | 'first_name' => $this->meta->billing_first_name,
28 | 'last_name' => $this->meta->billing_last_name,
29 | 'address_1' => $this->meta->billing_address_1,
30 | 'address_2' => $this->meta->billing_address_2,
31 | 'city' => $this->meta->billing_city,
32 | 'postcode' => $this->meta->billing_postcode,
33 | 'country' => $this->meta->billing_country,
34 | 'state' => $this->meta->billing_state,
35 | 'phone' => $this->meta->billing_phone,
36 | ],
37 | 'delivery_address' => [
38 | 'address_1' => $this->meta->shipping_address_1,
39 | 'address_2' => $this->meta->shipping_address_2,
40 | 'city' => $this->meta->shipping_city,
41 | 'postcode' => $this->meta->shipping_postcode,
42 | 'country' => $this->meta->shipping_country,
43 | 'state' => $this->meta->shipping_state,
44 | 'additional_instruction' => $this->meta->shipping_additional_instruction
45 | ]
46 | ];
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/Http/helpers.php:
--------------------------------------------------------------------------------
1 | ajax()) {
27 | return false;
28 | }
29 |
30 | if ($this->isRunningInConsole()) {
31 | return false;
32 | }
33 |
34 | return $request->isMethod('get');
35 | }
36 |
37 | /**
38 | * @param Response $response
39 | *
40 | * @return bool
41 | */
42 | public function shouldCacheResponse(Response $response): bool
43 | {
44 | return $response->isSuccessful() || $response->isRedirection();
45 | }
46 |
47 | /**
48 | * @param Request $request
49 | *
50 | * @return bool
51 | */
52 | public function enabled(Request $request): bool
53 | {
54 | return config('responsecache.enabled');
55 | }
56 |
57 | /*
58 | * Return the time when the cache must be invalided.
59 | */
60 | public function cacheRequestUntil(Request $request): DateTime
61 | {
62 | return Carbon::now()->addMinutes(
63 | config('responsecache.cache_lifetime_in_minutes')
64 | );
65 | }
66 |
67 | /*
68 | * Set a string to add to differentiate this request from others.
69 | */
70 | public function cacheNameSuffix(Request $request): string
71 | {
72 | if (\Auth::check()) {
73 | return \Auth::user()->ID;
74 | }
75 |
76 | return '';
77 | }
78 |
79 | /**
80 | * @return bool
81 | */
82 | public function isRunningInConsole(): bool
83 | {
84 | if (app()->environment('testing')) {
85 | return false;
86 | }
87 |
88 | return app()->runningInConsole();
89 | }
90 | }
--------------------------------------------------------------------------------
/app/Models/OauthClient.php:
--------------------------------------------------------------------------------
1 | where('post_type', '=', 'product');
21 | });
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/Models/User.php:
--------------------------------------------------------------------------------
1 | attributes['user_pass'] = $passwordService->createHash($password);
27 | }
28 | }
--------------------------------------------------------------------------------
/app/Policies/UserPolicy.php:
--------------------------------------------------------------------------------
1 | true,
19 | 'data' => $data
20 | ];
21 |
22 | return \Response::make($content, $status, $headers);
23 | });
24 |
25 | \Response::macro('Error', function ($data = null, $status = 400, $headers = []) {
26 | $content = [
27 | 'success' => false,
28 | 'error' => [
29 | 'code' => $status,
30 | 'message' => $data
31 | ]
32 | ];
33 |
34 | return \Response::make($content, $status, $headers);
35 | });
36 | }
37 |
38 | /**
39 | * Register any application services.
40 | *
41 | * @return void
42 | */
43 | public function register()
44 | {
45 |
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/Providers/AuthServiceProvider.php:
--------------------------------------------------------------------------------
1 | UserPolicy::class
19 | ];
20 |
21 | /**
22 | * Register any authentication / authorization services.
23 | *
24 | * @return void
25 | */
26 | public function boot()
27 | {
28 |
29 | $this->registerPolicies();
30 |
31 | Passport::tokensExpireIn(Carbon::now()->addDays(30));
32 | Passport::refreshTokensExpireIn(Carbon::now()->addDays(35));
33 | Passport::personalAccessTokensExpireIn(Carbon::now()->addDays(30));
34 |
35 | Passport::routes(function (RouteRegistrar $routeRegistrar) {
36 | $routeRegistrar->forAccessTokens();
37 | $routeRegistrar->forTransientTokens();
38 | }, [
39 | 'prefix' => 'api/mobile/v1'
40 | ]);
41 |
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/Providers/BroadcastServiceProvider.php:
--------------------------------------------------------------------------------
1 | [
19 | SendEmailVerificationNotification::class,
20 | ],
21 | ];
22 |
23 | /**
24 | * Register any events for your application.
25 | *
26 | * @return void
27 | */
28 | public function boot()
29 | {
30 | parent::boot();
31 |
32 | //
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/Providers/RouteServiceProvider.php:
--------------------------------------------------------------------------------
1 | mapApiRoutes();
39 |
40 | $this->mapWebRoutes();
41 |
42 | $this->mapApiMobileV1Routes();
43 | }
44 |
45 | /**
46 | * Define the "web" routes for the application.
47 | *
48 | * These routes all receive session state, CSRF protection, etc.
49 | *
50 | * @return void
51 | */
52 | protected function mapWebRoutes()
53 | {
54 | Route::middleware('web')
55 | ->namespace($this->namespace)
56 | ->group(base_path('routes/web.php'));
57 | }
58 |
59 | /**
60 | * Define the "api" routes for the application.
61 | *
62 | * These routes are typically stateless.
63 | *
64 | * @return void
65 | */
66 | protected function mapApiRoutes()
67 | {
68 | Route::prefix('api')
69 | ->middleware('api')
70 | ->namespace($this->namespace)
71 | ->group(base_path('routes/api.php'));
72 | }
73 |
74 |
75 | /**
76 | * Define the "api/mobile/v1" routes for the application.
77 | *
78 | * These routes are typically stateless.
79 | *
80 | * @return void
81 | */
82 | protected function mapApiMobileV1Routes()
83 | {
84 | Route::prefix('api/mobile/v1')
85 | ->middleware('api')
86 | ->namespace($this->namespace)
87 | ->group(base_path('routes/api/mobile-v1.php'));
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/app/Services/Auth/RegisterService.php:
--------------------------------------------------------------------------------
1 | create([
25 | 'user_login' => $request['email'],
26 | 'user_email' => $request['email'],
27 | 'user_pass' => $request['password']
28 | ]);
29 |
30 | $wordpressUser->saveMeta('phone_number',$request['phone']);
31 |
32 | return UserOld::query()->findOrFail($wordpressUser->getAuthIdentifier());
33 | }
34 |
35 | }
--------------------------------------------------------------------------------
/app/Services/WoocommerceCartService.php:
--------------------------------------------------------------------------------
1 | request($uri, 'GET', $data);
29 | }
30 |
31 |
32 | /**
33 | * @param string $uri
34 | * @param array $data
35 | *
36 | * @return mixed|null|\Psr\Http\Message\ResponseInterface
37 | * @throws \GuzzleHttp\Exception\GuzzleException
38 | */
39 | public function post($uri = '', $data = [])
40 | {
41 | return $this->request($uri, 'POST', $data);
42 | }
43 |
44 |
45 | /**
46 | * @param string $uri
47 | * @param array $data
48 | *
49 | * @return mixed|null|\Psr\Http\Message\ResponseInterface
50 | * @throws \GuzzleHttp\Exception\GuzzleException
51 | */
52 | public function delete($uri = '', $data = [])
53 | {
54 | return $this->request($uri, 'DELETE', $data);
55 | }
56 |
57 |
58 | /**
59 | * @param $uri
60 | * @param $method
61 | * @param $data
62 | *
63 | * @return mixed|null|\Psr\Http\Message\ResponseInterface
64 | * @throws \GuzzleHttp\Exception\GuzzleException
65 | */
66 | private function request($uri, $method, $data)
67 | {
68 |
69 | $cookieJar = CookieJar::fromArray(Cookie::get(),
70 | config('wordpress.WP_WC_DOMAIN'));
71 | $client = new Client([
72 | 'base_uri' => config('wordpress.WP_WC_URL')
73 | . '/wp-json/wc/v2/cart/',
74 | 'cookies' => $cookieJar
75 | ]);
76 |
77 | try {
78 | $request = $client->request($method, $uri, ["json" => $data]);
79 | $headers = $request->getHeaders();
80 | $response = json_decode($request->getBody(), true);
81 | $response = [
82 | 'success' => true,
83 | 'data' => $response,
84 | 'headers' => $headers
85 | ];
86 |
87 | return $response;
88 |
89 | } catch (BadResponseException $ex) {
90 | $response = $ex->getResponse();
91 | $response = json_decode((string)$response->getBody(), true);
92 | $errors = $response['message'];
93 |
94 | throw new HttpResponseException(response()->Error($errors));
95 | }
96 | }
97 | }
--------------------------------------------------------------------------------
/app/Services/WoocommerceService.php:
--------------------------------------------------------------------------------
1 | true,
47 | 'data' => $data
48 | ];
49 |
50 | return $response;
51 |
52 | } catch (HttpClientException $e) {
53 | $response = $e->getResponse();
54 | $errors = collect(json_decode((string)$response->getBody(), true)['data'])->except('status');
55 |
56 | throw new HttpResponseException(response()->Error($errors));
57 | }
58 | }
59 |
60 |
61 | /**
62 | * @param string $endpoint
63 | * @param array $data
64 | *
65 | * @return array|\Automattic\WooCommerce\HttpClient\Response|mixed
66 | */
67 | public function post($endpoint, $data)
68 | {
69 | try {
70 | $data = parent::post($endpoint, $data);
71 |
72 | if (gettype($data) === "array") {
73 | $data = collect($data);
74 | }
75 |
76 | $response = [
77 | 'success' => true,
78 | 'data' => $data
79 | ];
80 |
81 | return $response;
82 | } catch (HttpClientException $e) {
83 | $response = $e->getResponse();
84 | $errors = json_decode((string)$response->getBody(), true);
85 |
86 | throw new HttpResponseException(response()->Error($errors));
87 | }
88 | }
89 |
90 |
91 | /**
92 | * @param string $endpoint
93 | * @param array $data
94 | *
95 | * @return array|\Automattic\WooCommerce\HttpClient\Response|mixed
96 | */
97 | public function put($endpoint, $data)
98 | {
99 | try {
100 | $response = parent::put($endpoint,
101 | $data); // TODO: Change the autogenerated stub
102 |
103 | return $response;
104 | } catch (HttpClientException $e) {
105 | $response = $e->getResponse();
106 | $errors = json_decode((string)$response->getBody(), true);
107 |
108 | throw new HttpResponseException(response()->Error($errors));
109 | }
110 | }
111 |
112 |
113 | /**
114 | * @param string $endpoint
115 | * @param array $parameters
116 | *
117 | * @return array|\Automattic\WooCommerce\HttpClient\Response|mixed
118 | */
119 | public function delete($endpoint, $parameters = [])
120 | {
121 | try {
122 | $response = parent::delete($endpoint,
123 | $parameters); // TODO: Change the autogenerated stub
124 |
125 | return $response;
126 | } catch (HttpClientException $e) {
127 | $response = $e->getResponse();
128 | $errors = json_decode((string)$response->getBody(), true);
129 |
130 | throw new HttpResponseException(response()->Error($errors));
131 | }
132 | }
133 |
134 |
135 | /**
136 | * @param string $endpoint
137 | *
138 | * @return array|\Automattic\WooCommerce\HttpClient\Response|mixed
139 | */
140 | public function options($endpoint)
141 | {
142 | try {
143 | $response
144 | = parent::options($endpoint); // TODO: Change the autogenerated stub
145 | return $response;
146 | } catch (HttpClientException $e) {
147 | $response = $e->getResponse();
148 | $errors = json_decode((string)$response->getBody(), true);
149 |
150 | throw new HttpResponseException(response()->Error($errors));
151 | }
152 | }
153 | }
--------------------------------------------------------------------------------
/app/Services/WordpressService.php:
--------------------------------------------------------------------------------
1 | request($uri, 'GET', $data);
28 | }
29 |
30 |
31 | /**
32 | * @param string $uri
33 | * @param array $data
34 | *
35 | * @return mixed|null|\Psr\Http\Message\ResponseInterface
36 | * @throws \GuzzleHttp\Exception\GuzzleException
37 | */
38 | public function post($uri = '', $data = [])
39 | {
40 | return $this->request($uri, 'POST', $data);
41 | }
42 |
43 |
44 | /**
45 | * @param string $uri
46 | * @param array $data
47 | *
48 | * @return mixed|null|\Psr\Http\Message\ResponseInterface
49 | * @throws \GuzzleHttp\Exception\GuzzleException
50 | */
51 | public function delete($uri = '', $data = [])
52 | {
53 | return $this->request($uri, 'DELETE', $data);
54 | }
55 |
56 | /**
57 | * @param $uri
58 | * @param $method
59 | * @param $data
60 | *
61 | * @return mixed|null|\Psr\Http\Message\ResponseInterface
62 | * @throws \GuzzleHttp\Exception\GuzzleException
63 | */
64 | private function request($uri, $method, $data)
65 | {
66 | $cookieJar = CookieJar::fromArray(Cookie::get(),
67 | config('wordpress.WP_WC_DOMAIN'));
68 | $client = new Client([
69 | 'base_uri' => config('wordpress.WP_WC_URL') . '/wp-json/wp/v2/',
70 | 'cookies' => $cookieJar
71 | ]);
72 |
73 | try {
74 | $data = json_decode($client->request($method, $uri,
75 | ["json" => $data])->getBody(), true);
76 | $response = [
77 | 'success' => true,
78 | 'data' => $data
79 | ];
80 | } catch (BadResponseException $e) {
81 | $response = $e->getResponse();
82 | $data = collect(json_decode((string)$response->getBody(), true))->except('status');
83 |
84 | $response = [
85 | 'success' => false,
86 | 'code' => $e->getCode(),
87 | 'data' => $data
88 | ];
89 | }
90 |
91 | return $response;
92 | }
93 | }
--------------------------------------------------------------------------------
/app/Traits/PassportToken.php:
--------------------------------------------------------------------------------
1 | getNewRefreshToken();
59 | $refreshToken->setExpiryDateTime((new \DateTime())->add(Passport::refreshTokensExpireIn()));
60 | $refreshToken->setAccessToken($accessToken);
61 |
62 | while ($maxGenerationAttempts-- > 0) {
63 | $refreshToken->setIdentifier($this->generateUniqueIdentifier());
64 | try {
65 | $refreshTokenRepository->persistNewRefreshToken($refreshToken);
66 |
67 | return $refreshToken;
68 | } catch (UniqueTokenIdentifierConstraintViolationException $e) {
69 | if ($maxGenerationAttempts === 0) {
70 | throw $e;
71 | }
72 | }
73 | }
74 | }
75 |
76 | protected function createPassportTokenByUser(UserOld $user, $clientId)
77 | {
78 | $accessToken = new AccessToken($user->id);
79 | $accessToken->setIdentifier($this->generateUniqueIdentifier());
80 | $accessToken->setClient(new Client($clientId, null, null));
81 | $accessToken->setExpiryDateTime((new DateTime())->add(Passport::tokensExpireIn()));
82 |
83 | $accessTokenRepository = new AccessTokenRepository(new TokenRepository(), new Dispatcher());
84 | $accessTokenRepository->persistNewAccessToken($accessToken);
85 | $refreshToken = $this->issueRefreshToken($accessToken);
86 |
87 | return [
88 | 'access_token' => $accessToken,
89 | 'refresh_token' => $refreshToken,
90 | ];
91 | }
92 |
93 | protected function sendBearerTokenResponse($accessToken, $refreshToken)
94 | {
95 | $response = new BearerTokenResponse();
96 | $response->setAccessToken($accessToken);
97 | $response->setRefreshToken($refreshToken);
98 |
99 | $privateKey = new CryptKey('file://'.Passport::keyPath('oauth-private.key'));
100 |
101 | $response->setPrivateKey($privateKey);
102 | $response->setEncryptionKey(app('encrypter')->getKey());
103 |
104 | return $response->generateHttpResponse(new Response);
105 | }
106 |
107 | /**
108 | * @param \App\Models\UserOld $user
109 | * @param $clientId
110 | * @param bool $output default = true
111 | *
112 | * @return array | \League\OAuth2\Server\ResponseTypes\BearerTokenResponse
113 | */
114 | protected function getBearerTokenByUser(UserOld $user, $clientId, $output = true)
115 | {
116 | $passportToken = $this->createPassportTokenByUser($user, $clientId);
117 | $bearerToken = $this->sendBearerTokenResponse($passportToken['access_token'], $passportToken['refresh_token']);
118 |
119 | if (! $output) {
120 | $bearerToken = json_decode($bearerToken->getBody()->__toString(), true);
121 | }
122 |
123 | return $bearerToken;
124 | }
125 | }
--------------------------------------------------------------------------------
/artisan:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | make(Illuminate\Contracts\Console\Kernel::class);
34 |
35 | $status = $kernel->handle(
36 | $input = new Symfony\Component\Console\Input\ArgvInput,
37 | new Symfony\Component\Console\Output\ConsoleOutput
38 | );
39 |
40 | /*
41 | |--------------------------------------------------------------------------
42 | | Shutdown The Application
43 | |--------------------------------------------------------------------------
44 | |
45 | | Once Artisan has finished running, we will fire off the shutdown events
46 | | so that any final work may be done by the application before we shut
47 | | down the process. This is the last thing to happen to the request.
48 | |
49 | */
50 |
51 | $kernel->terminate($input, $status);
52 |
53 | exit($status);
54 |
--------------------------------------------------------------------------------
/bootstrap/app.php:
--------------------------------------------------------------------------------
1 | singleton(
30 | Illuminate\Contracts\Http\Kernel::class,
31 | App\Http\Kernel::class
32 | );
33 |
34 | $app->singleton(
35 | Illuminate\Contracts\Console\Kernel::class,
36 | App\Console\Kernel::class
37 | );
38 |
39 | $app->singleton(
40 | Illuminate\Contracts\Debug\ExceptionHandler::class,
41 | App\Exceptions\Handler::class
42 | );
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Return The Application
47 | |--------------------------------------------------------------------------
48 | |
49 | | This script returns the application instance. The instance is given to
50 | | the calling script so we can separate the building of the instances
51 | | from the actual running of the application and sending responses.
52 | |
53 | */
54 |
55 | return $app;
56 |
--------------------------------------------------------------------------------
/bootstrap/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "laravel/laravel",
3 | "type": "project",
4 | "description": "The Laravel Framework.",
5 | "keywords": [
6 | "framework",
7 | "laravel"
8 | ],
9 | "license": "MIT",
10 | "require": {
11 | "php": "^7.1.3",
12 | "automattic/woocommerce": "^3.0",
13 | "barryvdh/laravel-ide-helper": "^2.5",
14 | "big-shark/sql-to-builder": "^1.0@dev",
15 | "corcel/woocommerce": "dev-master",
16 | "fideloper/proxy": "^4.0",
17 | "guzzlehttp/guzzle": "^6.3",
18 | "jgrossi/corcel": "^2.7",
19 | "laravel/framework": "5.7.*",
20 | "laravel/passport": "^7.0",
21 | "laravel/tinker": "^1.0",
22 | "pentagonal/phpass": "^1.1",
23 | "predis/predis": "^1.1",
24 | "spatie/laravel-responsecache": "^4.4"
25 | },
26 | "require-dev": {
27 | "beyondcode/laravel-dump-server": "^1.0",
28 | "filp/whoops": "^2.0",
29 | "fzaninotto/faker": "^1.4",
30 | "mockery/mockery": "^1.0",
31 | "nunomaduro/collision": "^2.0",
32 | "phpunit/phpunit": "^7.0"
33 | },
34 | "config": {
35 | "optimize-autoloader": true,
36 | "preferred-install": "dist",
37 | "sort-packages": true
38 | },
39 | "extra": {
40 | "laravel": {
41 | "dont-discover": []
42 | }
43 | },
44 | "autoload": {
45 | "files": [
46 | "app/Http/helpers.php"
47 | ],
48 | "psr-4": {
49 | "App\\": "app/"
50 | },
51 | "classmap": [
52 | "database/seeds",
53 | "database/factories"
54 | ]
55 | },
56 | "autoload-dev": {
57 | "psr-4": {
58 | "Tests\\": "tests/"
59 | }
60 | },
61 | "minimum-stability": "dev",
62 | "prefer-stable": true,
63 | "scripts": {
64 | "post-autoload-dump": [
65 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
66 | "@php artisan package:discover --ansi"
67 | ],
68 | "post-root-package-install": [
69 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
70 | ],
71 | "post-create-project-cmd": [
72 | "@php artisan key:generate --ansi"
73 | ]
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/config/auth.php:
--------------------------------------------------------------------------------
1 | [
17 | 'guard' => 'web',
18 | 'passwords' => 'users',
19 | ],
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Authentication Guards
24 | |--------------------------------------------------------------------------
25 | |
26 | | Next, you may define every authentication guard for your application.
27 | | Of course, a great default configuration has been defined for you
28 | | here which uses session storage and the Eloquent user provider.
29 | |
30 | | All authentication drivers have a user provider. This defines how the
31 | | users are actually retrieved out of your database or other storage
32 | | mechanisms used by this application to persist your user's data.
33 | |
34 | | Supported: "session", "token"
35 | |
36 | */
37 |
38 | 'guards' => [
39 | 'web' => [
40 | 'driver' => 'session',
41 | 'provider' => 'users',
42 | ],
43 |
44 | 'api' => [
45 | 'driver' => 'passport',
46 | 'provider' => 'users',
47 | ],
48 | ],
49 |
50 | /*
51 | |--------------------------------------------------------------------------
52 | | UserOld Providers
53 | |--------------------------------------------------------------------------
54 | |
55 | | All authentication drivers have a user provider. This defines how the
56 | | users are actually retrieved out of your database or other storage
57 | | mechanisms used by this application to persist your user's data.
58 | |
59 | | If you have multiple user tables or models you may configure multiple
60 | | sources which represent each model / table. These sources may then
61 | | be assigned to any extra authentication guards you have defined.
62 | |
63 | | Supported: "database", "eloquent"
64 | |
65 | */
66 |
67 | 'providers' => [
68 | 'users' => [
69 | 'driver' => 'corcel',
70 | 'model' => \App\Models\User::class,
71 | ],
72 |
73 | // 'users' => [
74 | // 'driver' => 'database',
75 | // 'table' => 'users',
76 | // ],
77 | ],
78 |
79 | /*
80 | |--------------------------------------------------------------------------
81 | | Resetting Passwords
82 | |--------------------------------------------------------------------------
83 | |
84 | | You may specify multiple password reset configurations if you have more
85 | | than one user table or model in the application and you want to have
86 | | separate password reset settings based on the specific user types.
87 | |
88 | | The expire time is the number of minutes that the reset token should be
89 | | considered valid. This security feature keeps tokens short-lived so
90 | | they have less time to be guessed. You may change this as needed.
91 | |
92 | */
93 |
94 | 'passwords' => [
95 | 'users' => [
96 | 'provider' => 'users',
97 | 'table' => 'password_resets',
98 | 'expire' => 60,
99 | ],
100 | ],
101 |
102 | ];
103 |
--------------------------------------------------------------------------------
/config/broadcasting.php:
--------------------------------------------------------------------------------
1 | env('BROADCAST_DRIVER', 'null'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Broadcast Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the broadcast connections that will be used
26 | | to broadcast events to other systems or over websockets. Samples of
27 | | each available type of connection are provided inside this array.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'pusher' => [
34 | 'driver' => 'pusher',
35 | 'key' => env('PUSHER_APP_KEY'),
36 | 'secret' => env('PUSHER_APP_SECRET'),
37 | 'app_id' => env('PUSHER_APP_ID'),
38 | 'options' => [
39 | 'cluster' => env('PUSHER_APP_CLUSTER'),
40 | 'encrypted' => true,
41 | ],
42 | ],
43 |
44 | 'redis' => [
45 | 'driver' => 'redis',
46 | 'connection' => 'default',
47 | ],
48 |
49 | 'log' => [
50 | 'driver' => 'log',
51 | ],
52 |
53 | 'null' => [
54 | 'driver' => 'null',
55 | ],
56 |
57 | ],
58 |
59 | ];
60 |
--------------------------------------------------------------------------------
/config/cache.php:
--------------------------------------------------------------------------------
1 | env('CACHE_DRIVER', 'file'),
21 |
22 | /*
23 | |--------------------------------------------------------------------------
24 | | Cache Stores
25 | |--------------------------------------------------------------------------
26 | |
27 | | Here you may define all of the cache "stores" for your application as
28 | | well as their drivers. You may even define multiple stores for the
29 | | same cache driver to group types of items stored in your caches.
30 | |
31 | */
32 |
33 | 'stores' => [
34 |
35 | 'apc' => [
36 | 'driver' => 'apc',
37 | ],
38 |
39 | 'array' => [
40 | 'driver' => 'array',
41 | ],
42 |
43 | 'database' => [
44 | 'driver' => 'database',
45 | 'table' => 'cache',
46 | 'connection' => null,
47 | ],
48 |
49 | 'file' => [
50 | 'driver' => 'file',
51 | 'path' => storage_path('framework/cache/data'),
52 | ],
53 |
54 | 'memcached' => [
55 | 'driver' => 'memcached',
56 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
57 | 'sasl' => [
58 | env('MEMCACHED_USERNAME'),
59 | env('MEMCACHED_PASSWORD'),
60 | ],
61 | 'options' => [
62 | // Memcached::OPT_CONNECT_TIMEOUT => 2000,
63 | ],
64 | 'servers' => [
65 | [
66 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
67 | 'port' => env('MEMCACHED_PORT', 11211),
68 | 'weight' => 100,
69 | ],
70 | ],
71 | ],
72 |
73 | 'redis' => [
74 | 'driver' => 'redis',
75 | 'connection' => 'cache',
76 | ],
77 |
78 | ],
79 |
80 | /*
81 | |--------------------------------------------------------------------------
82 | | Cache Key Prefix
83 | |--------------------------------------------------------------------------
84 | |
85 | | When utilizing a RAM based store such as APC or Memcached, there might
86 | | be other applications utilizing the same cache. So, we'll specify a
87 | | value to get prefixed to all our keys so we can avoid collisions.
88 | |
89 | */
90 |
91 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
92 |
93 | ];
94 |
--------------------------------------------------------------------------------
/config/corcel.php:
--------------------------------------------------------------------------------
1 | 'wordpress',
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Registered Custom Post Types
24 | |--------------------------------------------------------------------------
25 | |
26 | | WordPress allows you to create your own custom post types. Corcel
27 | | makes querying posts using a custom post type easier, but here you can
28 | | set a list of your custom post types, and Corcel will automatically
29 | | register all of them, making returning those custom classes, instead
30 | | of just Post objects.
31 | |
32 | */
33 |
34 | 'post_types' => [
35 | // 'video' => App\Models\Video::class,
36 | ],
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Registered Shortcodes
41 | |--------------------------------------------------------------------------
42 | |
43 | | With Corcel you can register as many shortcodes you want, but that's
44 | | usually made in runtime. Here it's the place to set all your custom
45 | | shortcodes to make Corcel registering all of them automatically. Just
46 | | create your own shortcode class implementing `Corcel\Shortcode` interface.
47 | |
48 | */
49 |
50 | 'shortcodes' => [
51 | // 'foo' => App\Shortcodes\FooShortcode::class,
52 | ],
53 |
54 | /*
55 | |--------------------------------------------------------------------------
56 | | Registered Shortcode Parser
57 | |--------------------------------------------------------------------------
58 | |
59 | | Corcel uses the thunderer/shortcode library to parse shortcodes. Thunderer
60 | | provides three different parsers for shortcodes. You can use a
61 | | different parser if it suits your requirements better, or create your own.
62 | |
63 | */
64 |
65 | 'shortcode_parser' => Thunder\Shortcode\Parser\RegularParser::class,
66 | // 'shortcode_parser' => Thunder\Shortcode\Parser\RegexParser::class,
67 | // 'shortcode_parser' => Thunder\Shortcode\Parser\WordpressParser::class,
68 |
69 | ];
70 |
--------------------------------------------------------------------------------
/config/database.php:
--------------------------------------------------------------------------------
1 | env('DB_CONNECTION', 'mysql'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Database Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here are each of the database connections setup for your application.
24 | | Of course, examples of configuring each database platform that is
25 | | supported by Laravel is shown below to make development simple.
26 | |
27 | |
28 | | All database work in Laravel is done through the PHP PDO facilities
29 | | so make sure you have the driver for your particular database of
30 | | choice installed on your machine before you begin development.
31 | |
32 | */
33 |
34 | 'connections' => [
35 |
36 | 'sqlite' => [
37 | 'driver' => 'sqlite',
38 | 'database' => env('DB_DATABASE', database_path('database.sqlite')),
39 | 'prefix' => '',
40 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
41 | ],
42 |
43 | 'mysql' => [
44 | 'driver' => 'mysql',
45 | 'host' => env('DB_HOST', '127.0.0.1'),
46 | 'port' => env('DB_PORT', '3306'),
47 | 'database' => env('DB_DATABASE', 'forge'),
48 | 'username' => env('DB_USERNAME', 'forge'),
49 | 'password' => env('DB_PASSWORD', ''),
50 | 'unix_socket' => env('DB_SOCKET', ''),
51 | 'charset' => 'utf8mb4',
52 | 'collation' => 'utf8mb4_unicode_ci',
53 | 'prefix' => '',
54 | 'prefix_indexes' => true,
55 | 'strict' => true,
56 | 'engine' => null,
57 | ],
58 |
59 | 'wordpress' => [
60 | 'driver' => 'mysql',
61 | 'host' => env('WP_DB_HOST', '127.0.0.1'),
62 | 'port' => env('WP_DB_PORT', '3306'),
63 | 'database' => env('WP_DB_DATABASE', 'forge'),
64 | 'username' => env('WP_DB_USERNAME', 'forge'),
65 | 'password' => env('WP_DB_PASSWORD', ''),
66 | 'unix_socket' => env('WP_DB_SOCKET', ''),
67 | 'charset' => 'utf8mb4',
68 | 'collation' => 'utf8mb4_unicode_ci',
69 | 'prefix' => env('WP_DB_PREFIX', 'wp_'),
70 | 'prefix_indexes' => true,
71 | 'strict' => false,
72 | 'engine' => null,
73 | ],
74 |
75 | 'pgsql' => [
76 | 'driver' => 'pgsql',
77 | 'host' => env('DB_HOST', '127.0.0.1'),
78 | 'port' => env('DB_PORT', '5432'),
79 | 'database' => env('DB_DATABASE', 'forge'),
80 | 'username' => env('DB_USERNAME', 'forge'),
81 | 'password' => env('DB_PASSWORD', ''),
82 | 'charset' => 'utf8',
83 | 'prefix' => '',
84 | 'prefix_indexes' => true,
85 | 'schema' => 'public',
86 | 'sslmode' => 'prefer',
87 | ],
88 |
89 | 'sqlsrv' => [
90 | 'driver' => 'sqlsrv',
91 | 'host' => env('DB_HOST', 'localhost'),
92 | 'port' => env('DB_PORT', '1433'),
93 | 'database' => env('DB_DATABASE', 'forge'),
94 | 'username' => env('DB_USERNAME', 'forge'),
95 | 'password' => env('DB_PASSWORD', ''),
96 | 'charset' => 'utf8',
97 | 'prefix' => '',
98 | 'prefix_indexes' => true,
99 | ],
100 |
101 | ],
102 |
103 | /*
104 | |--------------------------------------------------------------------------
105 | | Migration Repository Table
106 | |--------------------------------------------------------------------------
107 | |
108 | | This table keeps track of all the migrations that have already run for
109 | | your application. Using this information, we can determine which of
110 | | the migrations on disk haven't actually been run in the database.
111 | |
112 | */
113 |
114 | 'migrations' => 'migrations',
115 |
116 | /*
117 | |--------------------------------------------------------------------------
118 | | Redis Databases
119 | |--------------------------------------------------------------------------
120 | |
121 | | Redis is an open source, fast, and advanced key-value store that also
122 | | provides a richer body of commands than a typical key-value system
123 | | such as APC or Memcached. Laravel makes it easy to dig right in.
124 | |
125 | */
126 |
127 | 'redis' => [
128 |
129 | 'client' => 'predis',
130 |
131 | 'default' => [
132 | 'host' => env('REDIS_HOST', '127.0.0.1'),
133 | 'password' => env('REDIS_PASSWORD', null),
134 | 'port' => env('REDIS_PORT', 6379),
135 | 'database' => env('REDIS_DB', 0),
136 | ],
137 |
138 | 'cache' => [
139 | 'host' => env('REDIS_HOST', '127.0.0.1'),
140 | 'password' => env('REDIS_PASSWORD', null),
141 | 'port' => env('REDIS_PORT', 6379),
142 | 'database' => env('REDIS_CACHE_DB', 1),
143 | ],
144 |
145 | ],
146 |
147 | ];
148 |
--------------------------------------------------------------------------------
/config/filesystems.php:
--------------------------------------------------------------------------------
1 | env('FILESYSTEM_DRIVER', 'local'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Default Cloud Filesystem Disk
21 | |--------------------------------------------------------------------------
22 | |
23 | | Many applications store files both locally and in the cloud. For this
24 | | reason, you may specify a default "cloud" driver here. This driver
25 | | will be bound as the Cloud disk implementation in the container.
26 | |
27 | */
28 |
29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'),
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Filesystem Disks
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here you may configure as many filesystem "disks" as you wish, and you
37 | | may even configure multiple disks of the same driver. Defaults have
38 | | been setup for each driver as an example of the required options.
39 | |
40 | | Supported Drivers: "local", "ftp", "sftp", "s3", "rackspace"
41 | |
42 | */
43 |
44 | 'disks' => [
45 |
46 | 'local' => [
47 | 'driver' => 'local',
48 | 'root' => storage_path('app'),
49 | ],
50 |
51 | 'public' => [
52 | 'driver' => 'local',
53 | 'root' => storage_path('app/public'),
54 | 'url' => env('APP_URL').'/storage',
55 | 'visibility' => 'public',
56 | ],
57 |
58 | 's3' => [
59 | 'driver' => 's3',
60 | 'key' => env('AWS_ACCESS_KEY_ID'),
61 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
62 | 'region' => env('AWS_DEFAULT_REGION'),
63 | 'bucket' => env('AWS_BUCKET'),
64 | 'url' => env('AWS_URL'),
65 | ],
66 |
67 | ],
68 |
69 | ];
70 |
--------------------------------------------------------------------------------
/config/hashing.php:
--------------------------------------------------------------------------------
1 | 'bcrypt',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Bcrypt Options
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may specify the configuration options that should be used when
26 | | passwords are hashed using the Bcrypt algorithm. This will allow you
27 | | to control the amount of time it takes to hash the given password.
28 | |
29 | */
30 |
31 | 'bcrypt' => [
32 | 'rounds' => env('BCRYPT_ROUNDS', 10),
33 | ],
34 |
35 | /*
36 | |--------------------------------------------------------------------------
37 | | Argon Options
38 | |--------------------------------------------------------------------------
39 | |
40 | | Here you may specify the configuration options that should be used when
41 | | passwords are hashed using the Argon algorithm. These will allow you
42 | | to control the amount of time it takes to hash the given password.
43 | |
44 | */
45 |
46 | 'argon' => [
47 | 'memory' => 1024,
48 | 'threads' => 2,
49 | 'time' => 2,
50 | ],
51 |
52 | ];
53 |
--------------------------------------------------------------------------------
/config/logging.php:
--------------------------------------------------------------------------------
1 | env('LOG_CHANNEL', 'stack'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Log Channels
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may configure the log channels for your application. Out of
27 | | the box, Laravel uses the Monolog PHP logging library. This gives
28 | | you a variety of powerful log handlers / formatters to utilize.
29 | |
30 | | Available Drivers: "single", "daily", "slack", "syslog",
31 | | "errorlog", "monolog",
32 | | "custom", "stack"
33 | |
34 | */
35 |
36 | 'channels' => [
37 | 'stack' => [
38 | 'driver' => 'stack',
39 | 'channels' => ['daily'],
40 | ],
41 |
42 | 'single' => [
43 | 'driver' => 'single',
44 | 'path' => storage_path('logs/laravel.log'),
45 | 'level' => 'debug',
46 | ],
47 |
48 | 'daily' => [
49 | 'driver' => 'daily',
50 | 'path' => storage_path('logs/laravel.log'),
51 | 'level' => 'debug',
52 | 'days' => 14,
53 | ],
54 |
55 | 'slack' => [
56 | 'driver' => 'slack',
57 | 'url' => env('LOG_SLACK_WEBHOOK_URL'),
58 | 'username' => 'Laravel Log',
59 | 'emoji' => ':boom:',
60 | 'level' => 'critical',
61 | ],
62 |
63 | 'papertrail' => [
64 | 'driver' => 'monolog',
65 | 'level' => 'debug',
66 | 'handler' => SyslogUdpHandler::class,
67 | 'handler_with' => [
68 | 'host' => env('PAPERTRAIL_URL'),
69 | 'port' => env('PAPERTRAIL_PORT'),
70 | ],
71 | ],
72 |
73 | 'stderr' => [
74 | 'driver' => 'monolog',
75 | 'handler' => StreamHandler::class,
76 | 'formatter' => env('LOG_STDERR_FORMATTER'),
77 | 'with' => [
78 | 'stream' => 'php://stderr',
79 | ],
80 | ],
81 |
82 | 'syslog' => [
83 | 'driver' => 'syslog',
84 | 'level' => 'debug',
85 | ],
86 |
87 | 'errorlog' => [
88 | 'driver' => 'errorlog',
89 | 'level' => 'debug',
90 | ],
91 | ],
92 |
93 | ];
94 |
--------------------------------------------------------------------------------
/config/mail.php:
--------------------------------------------------------------------------------
1 | env('MAIL_DRIVER', 'smtp'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | SMTP Host Address
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may provide the host address of the SMTP server used by your
27 | | applications. A default option is provided that is compatible with
28 | | the Mailgun mail service which will provide reliable deliveries.
29 | |
30 | */
31 |
32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
33 |
34 | /*
35 | |--------------------------------------------------------------------------
36 | | SMTP Host Port
37 | |--------------------------------------------------------------------------
38 | |
39 | | This is the SMTP port used by your application to deliver e-mails to
40 | | users of the application. Like the host we have set this value to
41 | | stay compatible with the Mailgun e-mail application by default.
42 | |
43 | */
44 |
45 | 'port' => env('MAIL_PORT', 587),
46 |
47 | /*
48 | |--------------------------------------------------------------------------
49 | | Global "From" Address
50 | |--------------------------------------------------------------------------
51 | |
52 | | You may wish for all e-mails sent by your application to be sent from
53 | | the same address. Here, you may specify a name and address that is
54 | | used globally for all e-mails that are sent by your application.
55 | |
56 | */
57 |
58 | 'from' => [
59 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
60 | 'name' => env('MAIL_FROM_NAME', 'Example'),
61 | ],
62 |
63 | /*
64 | |--------------------------------------------------------------------------
65 | | E-Mail Encryption Protocol
66 | |--------------------------------------------------------------------------
67 | |
68 | | Here you may specify the encryption protocol that should be used when
69 | | the application send e-mail messages. A sensible default using the
70 | | transport layer security protocol should provide great security.
71 | |
72 | */
73 |
74 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
75 |
76 | /*
77 | |--------------------------------------------------------------------------
78 | | SMTP Server Username
79 | |--------------------------------------------------------------------------
80 | |
81 | | If your SMTP server requires a username for authentication, you should
82 | | set it here. This will get used to authenticate with your server on
83 | | connection. You may also set the "password" value below this one.
84 | |
85 | */
86 |
87 | 'username' => env('MAIL_USERNAME'),
88 |
89 | 'password' => env('MAIL_PASSWORD'),
90 |
91 | /*
92 | |--------------------------------------------------------------------------
93 | | Sendmail System Path
94 | |--------------------------------------------------------------------------
95 | |
96 | | When using the "sendmail" driver to send e-mails, we will need to know
97 | | the path to where Sendmail lives on this server. A default path has
98 | | been provided here, which will work well on most of your systems.
99 | |
100 | */
101 |
102 | 'sendmail' => '/usr/sbin/sendmail -bs',
103 |
104 | /*
105 | |--------------------------------------------------------------------------
106 | | Markdown Mail Settings
107 | |--------------------------------------------------------------------------
108 | |
109 | | If you are using Markdown based email rendering, you may configure your
110 | | theme and component paths here, allowing you to customize the design
111 | | of the emails. Or, you may simply stick with the Laravel defaults!
112 | |
113 | */
114 |
115 | 'markdown' => [
116 | 'theme' => 'default',
117 |
118 | 'paths' => [
119 | resource_path('views/vendor/mail'),
120 | ],
121 | ],
122 |
123 | /*
124 | |--------------------------------------------------------------------------
125 | | Log Channel
126 | |--------------------------------------------------------------------------
127 | |
128 | | If you are using the "log" driver, you may specify the logging channel
129 | | if you prefer to keep mail messages separate from other log entries
130 | | for simpler reading. Otherwise, the default channel will be used.
131 | |
132 | */
133 |
134 | 'log_channel' => env('MAIL_LOG_CHANNEL'),
135 |
136 | ];
137 |
--------------------------------------------------------------------------------
/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_CONNECTION', 'sync'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Queue Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may configure the connection information for each server that
24 | | is used by your application. A default configuration has been added
25 | | for each back-end shipped with Laravel. You are free to add more.
26 | |
27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'sync' => [
34 | 'driver' => 'sync',
35 | ],
36 |
37 | 'database' => [
38 | 'driver' => 'database',
39 | 'table' => 'jobs',
40 | 'queue' => 'default',
41 | 'retry_after' => 90,
42 | ],
43 |
44 | 'beanstalkd' => [
45 | 'driver' => 'beanstalkd',
46 | 'host' => 'localhost',
47 | 'queue' => 'default',
48 | 'retry_after' => 90,
49 | ],
50 |
51 | 'sqs' => [
52 | 'driver' => 'sqs',
53 | 'key' => env('SQS_KEY', 'your-public-key'),
54 | 'secret' => env('SQS_SECRET', 'your-secret-key'),
55 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
56 | 'queue' => env('SQS_QUEUE', 'your-queue-name'),
57 | 'region' => env('SQS_REGION', 'us-east-1'),
58 | ],
59 |
60 | 'redis' => [
61 | 'driver' => 'redis',
62 | 'connection' => 'default',
63 | 'queue' => env('REDIS_QUEUE', 'default'),
64 | 'retry_after' => 90,
65 | 'block_for' => null,
66 | ],
67 |
68 | ],
69 |
70 | /*
71 | |--------------------------------------------------------------------------
72 | | Failed Queue Jobs
73 | |--------------------------------------------------------------------------
74 | |
75 | | These options configure the behavior of failed queue job logging so you
76 | | can control which database and table are used to store the jobs that
77 | | have failed. You may change them to any database / table you wish.
78 | |
79 | */
80 |
81 | 'failed' => [
82 | 'database' => env('DB_CONNECTION', 'mysql'),
83 | 'table' => 'failed_jobs',
84 | ],
85 |
86 | ];
87 |
--------------------------------------------------------------------------------
/config/responsecache.php:
--------------------------------------------------------------------------------
1 | env('RESPONSE_CACHE_ENABLED', true),
8 |
9 | /*
10 | * The given class will determinate if a request should be cached. The
11 | * default class will cache all successful GET-requests.
12 | *
13 | * You can provide your own class given that it implements the
14 | * CacheProfile interface.
15 | */
16 | 'cache_profile' => \App\Models\Cache\CacheProfile::class,
17 |
18 | /*
19 | * When using the default CacheRequestFilter this setting controls the
20 | * default number of minutes responses must be cached.
21 | */
22 | 'cache_lifetime_in_minutes' => env('RESPONSE_CACHE_LIFETIME', 60 * 24 * 7),
23 |
24 | /*
25 | * This setting determines if a http header named "Laravel-responsecache"
26 | * with the cache time should be added to a cached response. This
27 | * can be handy when debugging.
28 | */
29 | 'add_cache_time_header' => env('APP_DEBUG', true),
30 |
31 | /*
32 | * Here you may define the cache store that should be used to store
33 | * requests. This can be the name of any store that is
34 | * configured in app/config/cache.php
35 | */
36 | 'cache_store' => env('RESPONSE_CACHE_DRIVER', 'file'),
37 |
38 | /*
39 | * If the cache driver you configured supports tags, you may specify a tag name
40 | * here. All responses will be tagged. When clearing the responsecache only
41 | * items with that tag will be flushed.
42 | *
43 | * You may use a string or an array here.
44 | */
45 | 'cache_tag' => '',
46 | ];
47 |
--------------------------------------------------------------------------------
/config/services.php:
--------------------------------------------------------------------------------
1 | [
18 | 'domain' => env('MAILGUN_DOMAIN'),
19 | 'secret' => env('MAILGUN_SECRET'),
20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
21 | ],
22 |
23 | 'ses' => [
24 | 'key' => env('SES_KEY'),
25 | 'secret' => env('SES_SECRET'),
26 | 'region' => env('SES_REGION', 'us-east-1'),
27 | ],
28 |
29 | 'sparkpost' => [
30 | 'secret' => env('SPARKPOST_SECRET'),
31 | ],
32 |
33 | 'stripe' => [
34 | 'model' => App\User::class,
35 | 'key' => env('STRIPE_KEY'),
36 | 'secret' => env('STRIPE_SECRET'),
37 | 'webhook' => [
38 | 'secret' => env('STRIPE_WEBHOOK_SECRET'),
39 | 'tolerance' => env('STRIPE_WEBHOOK_TOLERANCE', 300),
40 | ],
41 | ],
42 |
43 | ];
44 |
--------------------------------------------------------------------------------
/config/session.php:
--------------------------------------------------------------------------------
1 | env('SESSION_DRIVER', 'file'),
22 |
23 | /*
24 | |--------------------------------------------------------------------------
25 | | Session Lifetime
26 | |--------------------------------------------------------------------------
27 | |
28 | | Here you may specify the number of minutes that you wish the session
29 | | to be allowed to remain idle before it expires. If you want them
30 | | to immediately expire on the browser closing, set that option.
31 | |
32 | */
33 |
34 | 'lifetime' => env('SESSION_LIFETIME', 120),
35 |
36 | 'expire_on_close' => false,
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Session Encryption
41 | |--------------------------------------------------------------------------
42 | |
43 | | This option allows you to easily specify that all of your session data
44 | | should be encrypted before it is stored. All encryption will be run
45 | | automatically by Laravel and you can use the Session like normal.
46 | |
47 | */
48 |
49 | 'encrypt' => false,
50 |
51 | /*
52 | |--------------------------------------------------------------------------
53 | | Session File Location
54 | |--------------------------------------------------------------------------
55 | |
56 | | When using the native session driver, we need a location where session
57 | | files may be stored. A default has been set for you but a different
58 | | location may be specified. This is only needed for file sessions.
59 | |
60 | */
61 |
62 | 'files' => storage_path('framework/sessions'),
63 |
64 | /*
65 | |--------------------------------------------------------------------------
66 | | Session Database Connection
67 | |--------------------------------------------------------------------------
68 | |
69 | | When using the "database" or "redis" session drivers, you may specify a
70 | | connection that should be used to manage these sessions. This should
71 | | correspond to a connection in your database configuration options.
72 | |
73 | */
74 |
75 | 'connection' => env('SESSION_CONNECTION', null),
76 |
77 | /*
78 | |--------------------------------------------------------------------------
79 | | Session Database Table
80 | |--------------------------------------------------------------------------
81 | |
82 | | When using the "database" session driver, you may specify the table we
83 | | should use to manage the sessions. Of course, a sensible default is
84 | | provided for you; however, you are free to change this as needed.
85 | |
86 | */
87 |
88 | 'table' => 'sessions',
89 |
90 | /*
91 | |--------------------------------------------------------------------------
92 | | Session Cache Store
93 | |--------------------------------------------------------------------------
94 | |
95 | | When using the "apc" or "memcached" session drivers, you may specify a
96 | | cache store that should be used for these sessions. This value must
97 | | correspond with one of the application's configured cache stores.
98 | |
99 | */
100 |
101 | 'store' => env('SESSION_STORE', null),
102 |
103 | /*
104 | |--------------------------------------------------------------------------
105 | | Session Sweeping Lottery
106 | |--------------------------------------------------------------------------
107 | |
108 | | Some session drivers must manually sweep their storage location to get
109 | | rid of old sessions from storage. Here are the chances that it will
110 | | happen on a given request. By default, the odds are 2 out of 100.
111 | |
112 | */
113 |
114 | 'lottery' => [2, 100],
115 |
116 | /*
117 | |--------------------------------------------------------------------------
118 | | Session Cookie Name
119 | |--------------------------------------------------------------------------
120 | |
121 | | Here you may change the name of the cookie used to identify a session
122 | | instance by ID. The name specified here will get used every time a
123 | | new session cookie is created by the framework for every driver.
124 | |
125 | */
126 |
127 | 'cookie' => env(
128 | 'SESSION_COOKIE',
129 | Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
130 | ),
131 |
132 | /*
133 | |--------------------------------------------------------------------------
134 | | Session Cookie Path
135 | |--------------------------------------------------------------------------
136 | |
137 | | The session cookie path determines the path for which the cookie will
138 | | be regarded as available. Typically, this will be the root path of
139 | | your application but you are free to change this when necessary.
140 | |
141 | */
142 |
143 | 'path' => '/',
144 |
145 | /*
146 | |--------------------------------------------------------------------------
147 | | Session Cookie Domain
148 | |--------------------------------------------------------------------------
149 | |
150 | | Here you may change the domain of the cookie used to identify a session
151 | | in your application. This will determine which domains the cookie is
152 | | available to in your application. A sensible default has been set.
153 | |
154 | */
155 |
156 | 'domain' => env('SESSION_DOMAIN', null),
157 |
158 | /*
159 | |--------------------------------------------------------------------------
160 | | HTTPS Only Cookies
161 | |--------------------------------------------------------------------------
162 | |
163 | | By setting this option to true, session cookies will only be sent back
164 | | to the server if the browser has a HTTPS connection. This will keep
165 | | the cookie from being sent to you if it can not be done securely.
166 | |
167 | */
168 |
169 | 'secure' => env('SESSION_SECURE_COOKIE', false),
170 |
171 | /*
172 | |--------------------------------------------------------------------------
173 | | HTTP Access Only
174 | |--------------------------------------------------------------------------
175 | |
176 | | Setting this value to true will prevent JavaScript from accessing the
177 | | value of the cookie and the cookie will only be accessible through
178 | | the HTTP protocol. You are free to modify this option if needed.
179 | |
180 | */
181 |
182 | 'http_only' => true,
183 |
184 | /*
185 | |--------------------------------------------------------------------------
186 | | Same-Site Cookies
187 | |--------------------------------------------------------------------------
188 | |
189 | | This option determines how your cookies behave when cross-site requests
190 | | take place, and can be used to mitigate CSRF attacks. By default, we
191 | | do not enable this as other CSRF protection services are in place.
192 | |
193 | | Supported: "lax", "strict"
194 | |
195 | */
196 |
197 | 'same_site' => null,
198 |
199 | ];
200 |
--------------------------------------------------------------------------------
/config/view.php:
--------------------------------------------------------------------------------
1 | [
17 | resource_path('views'),
18 | ],
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Compiled View Path
23 | |--------------------------------------------------------------------------
24 | |
25 | | This option determines where all the compiled Blade templates will be
26 | | stored for your application. Typically, this is within the storage
27 | | directory. However, as usual, you are free to change this value.
28 | |
29 | */
30 |
31 | 'compiled' => env(
32 | 'VIEW_COMPILED_PATH',
33 | realpath(storage_path('framework/views'))
34 | ),
35 |
36 | ];
37 |
--------------------------------------------------------------------------------
/config/wordpress.php:
--------------------------------------------------------------------------------
1 | env('WORDPRESS_DB_PREFIX', 'wp_'),
5 |
6 | "WP_WC_DOMAIN" => env('WP_WC_DOMAIN'),
7 | 'WP_WC_URL' => env('WP_WC_URL'),
8 | 'WP_WC_CONSUMER_KEY' => env('WP_WC_CONSUMER_KEY'),
9 | 'WP_WC_CONSUMER_SECRET' => env('WP_WC_CONSUMER_SECRET')
10 | ];
--------------------------------------------------------------------------------
/database/.gitignore:
--------------------------------------------------------------------------------
1 | *.sqlite
2 |
--------------------------------------------------------------------------------
/database/factories/UserFactory.php:
--------------------------------------------------------------------------------
1 | define(App\User::class, function (Faker $faker) {
17 | return [
18 | 'name' => $faker->name,
19 | 'email' => $faker->unique()->safeEmail,
20 | 'email_verified_at' => now(),
21 | 'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret
22 | 'remember_token' => str_random(10),
23 | ];
24 | });
25 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_100000_create_password_resets_table.php:
--------------------------------------------------------------------------------
1 | string('email')->index();
18 | $table->string('token');
19 | $table->timestamp('created_at')->nullable();
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | Schema::dropIfExists('password_resets');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/migrations/2019_02_04_133147_create_sessions_table.php:
--------------------------------------------------------------------------------
1 | string('id')->unique();
18 | $table->unsignedInteger('user_id')->nullable();
19 | $table->string('ip_address', 45)->nullable();
20 | $table->text('user_agent')->nullable();
21 | $table->text('payload');
22 | $table->integer('last_activity');
23 | });
24 | }
25 |
26 | /**
27 | * Reverse the migrations.
28 | *
29 | * @return void
30 | */
31 | public function down()
32 | {
33 | Schema::dropIfExists('sessions');
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/database/migrations/2019_02_11_092112_create_cache_table.php:
--------------------------------------------------------------------------------
1 | string('key')->unique();
18 | $table->mediumText('value');
19 | $table->integer('expiration');
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | Schema::dropIfExists('cache');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/seeds/DatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | call(UsersTableSeeder::class);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "dev": "npm run development",
5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
6 | "watch": "npm run development -- --watch",
7 | "watch-poll": "npm run watch -- --watch-poll",
8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
9 | "prod": "npm run production",
10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
11 | },
12 | "devDependencies": {
13 | "axios": "^0.18",
14 | "bootstrap": "^4.0.0",
15 | "cross-env": "^5.1",
16 | "jquery": "^3.2",
17 | "laravel-mix": "^4.0.7",
18 | "lodash": "^4.17.5",
19 | "popper.js": "^1.12",
20 | "resolve-url-loader": "^2.3.1",
21 | "sass": "^1.15.2",
22 | "sass-loader": "^7.1.0",
23 | "vue": "^2.5.17"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |