├── public ├── favicon.ico ├── robots.txt ├── mix-manifest.json ├── .htaccess └── index.php ├── database ├── .gitignore ├── seeders │ └── DatabaseSeeder.php ├── migrations │ ├── 2022_03_28_204252_create_stocks_table.php │ ├── 2022_04_01_200330_create_carts_table.php │ ├── 2022_06_12_184200_add_payment_intent_id_to_carts_table.php │ ├── 2022_05_18_195907_create_shipping_types_table.php │ ├── 2022_05_14_203358_create_category_product_table.php │ ├── 2022_03_19_210350_create_categories_table.php │ ├── 2022_05_26_205236_create_order_variation_table.php │ ├── 2022_04_01_200518_create_cart_variation_table.php │ ├── 2022_05_20_210222_create_shipping_addresses_table.php │ ├── 2022_03_21_203403_create_products_table.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2022_03_23_191747_create_variations_table.php │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ ├── 2019_12_14_000001_create_personal_access_tokens_table.php │ ├── 2022_05_26_190028_create_orders_table.php │ └── 2022_03_30_235857_create_media_table.php └── factories │ └── UserFactory.php ├── bootstrap ├── cache │ └── .gitignore └── app.php ├── storage ├── logs │ └── .gitignore ├── app │ ├── public │ │ └── .gitignore │ └── .gitignore ├── debugbar │ └── .gitignore └── framework │ ├── testing │ └── .gitignore │ ├── views │ └── .gitignore │ ├── cache │ ├── data │ │ └── .gitignore │ └── .gitignore │ ├── sessions │ └── .gitignore │ └── .gitignore ├── nike-air-force-1-black.png ├── nike-air-force-1-white.png ├── config ├── cart.php ├── stripe.php ├── cors.php ├── services.php ├── view.php ├── hashing.php ├── broadcasting.php ├── sanctum.php ├── filesystems.php ├── queue.php ├── cache.php ├── logging.php ├── mail.php ├── auth.php ├── scout.php └── database.php ├── app ├── Cart │ ├── Contracts │ │ └── CartInterface.php │ ├── Exceptions │ │ └── QuantityNoLongerAvailableException.php │ └── Cart.php ├── Models │ ├── Stock.php │ ├── ShippingType.php │ ├── Scopes │ │ └── LiveScope.php │ ├── Category.php │ ├── ShippingAddress.php │ ├── Presenters │ │ └── OrderPresenter.php │ ├── Cart.php │ ├── User.php │ ├── Variation.php │ ├── Product.php │ └── Order.php ├── Http │ ├── Controllers │ │ ├── CategoryShowController.php │ │ ├── OrderConfirmationIndexController.php │ │ ├── HomeController.php │ │ ├── ProductShowController.php │ │ ├── Controller.php │ │ ├── OrderIndexController.php │ │ ├── CartIndexController.php │ │ ├── Auth │ │ │ ├── EmailVerificationPromptController.php │ │ │ ├── EmailVerificationNotificationController.php │ │ │ ├── VerifyEmailController.php │ │ │ ├── ConfirmablePasswordController.php │ │ │ ├── PasswordResetLinkController.php │ │ │ ├── AuthenticatedSessionController.php │ │ │ ├── RegisteredUserController.php │ │ │ └── NewPasswordController.php │ │ └── CheckoutIndexController.php │ ├── Middleware │ │ ├── EncryptCookies.php │ │ ├── VerifyCsrfToken.php │ │ ├── PreventRequestsDuringMaintenance.php │ │ ├── TrustHosts.php │ │ ├── TrimStrings.php │ │ ├── Authenticate.php │ │ ├── CartMiddleware.php │ │ ├── RedirectIfCartEmptyMiddleware.php │ │ ├── TrustProxies.php │ │ └── RedirectIfAuthenticated.php │ ├── Livewire │ │ ├── Cart.php │ │ ├── ProductGallery.php │ │ ├── Navigation.php │ │ ├── ProductDropdown.php │ │ ├── CartItem.php │ │ ├── ProductSelector.php │ │ └── ProductBrowser.php │ ├── Requests │ │ └── Auth │ │ │ └── LoginRequest.php │ └── Kernel.php ├── View │ └── Components │ │ ├── AppLayout.php │ │ └── GuestLayout.php ├── Mail │ ├── OrderCreatedMail.php │ └── OrderStatusUpdatedMail.php ├── Providers │ ├── StripeServiceProvider.php │ ├── BroadcastServiceProvider.php │ ├── CartServiceProvider.php │ ├── AuthServiceProvider.php │ ├── AppServiceProvider.php │ ├── EventServiceProvider.php │ └── RouteServiceProvider.php ├── Listeners │ └── AttachOrdersListener.php ├── Console │ └── Kernel.php ├── Observers │ └── OrderObserver.php └── Exceptions │ └── Handler.php ├── resources ├── js │ ├── app.js │ └── bootstrap.js ├── css │ └── app.css ├── views │ ├── components │ │ ├── label.blade.php │ │ ├── auth-session-status.blade.php │ │ ├── select.blade.php │ │ ├── dropdown-link.blade.php │ │ ├── input.blade.php │ │ ├── category.blade.php │ │ ├── auth-card.blade.php │ │ ├── button-anchor.blade.php │ │ ├── button.blade.php │ │ ├── auth-validation-errors.blade.php │ │ ├── nav-link.blade.php │ │ ├── responsive-nav-link.blade.php │ │ ├── notification.blade.php │ │ ├── dropdown.blade.php │ │ └── application-logo.blade.php │ ├── emails │ │ ├── order-created.blade.php │ │ └── order-status-updated.blade.php │ ├── cart │ │ └── index.blade.php │ ├── checkout.blade.php │ ├── livewire │ │ ├── product-gallery.blade.php │ │ ├── product-selector.blade.php │ │ ├── product-dropdown.blade.php │ │ ├── cart.blade.php │ │ ├── cart-item.blade.php │ │ └── product-browser.blade.php │ ├── home.blade.php │ ├── dashboard.blade.php │ ├── categories │ │ └── show.blade.php │ ├── orders │ │ ├── confirmation.blade.php │ │ └── index.blade.php │ ├── layouts │ │ ├── guest.blade.php │ │ └── app.blade.php │ ├── products │ │ └── show.blade.php │ └── auth │ │ ├── confirm-password.blade.php │ │ ├── forgot-password.blade.php │ │ ├── verify-email.blade.php │ │ ├── reset-password.blade.php │ │ ├── register.blade.php │ │ └── login.blade.php └── lang │ └── en │ ├── pagination.php │ ├── auth.php │ └── passwords.php ├── .gitattributes ├── tests ├── TestCase.php ├── Unit │ └── ExampleTest.php ├── Feature │ ├── ExampleTest.php │ └── Auth │ │ ├── RegistrationTest.php │ │ ├── AuthenticationTest.php │ │ ├── PasswordConfirmationTest.php │ │ ├── EmailVerificationTest.php │ │ └── PasswordResetTest.php └── CreatesApplication.php ├── .styleci.yml ├── .gitignore ├── .editorconfig ├── tailwind.config.js ├── routes ├── channels.php ├── api.php ├── console.php ├── web.php └── auth.php ├── server.php ├── webpack.mix.js ├── package.json ├── .env.example ├── phpunit.xml ├── artisan ├── composer.json └── README.md /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/debugbar/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /public/mix-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "/js/app.js": "/js/app.js", 3 | "/css/app.css": "/css/app.css" 4 | } 5 | -------------------------------------------------------------------------------- /nike-air-force-1-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/turiondolby/laravel-ecommerce/HEAD/nike-air-force-1-black.png -------------------------------------------------------------------------------- /nike-air-force-1-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/turiondolby/laravel-ecommerce/HEAD/nike-air-force-1-white.png -------------------------------------------------------------------------------- /config/cart.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'key' => 'cart_session', 6 | ] 7 | ]; 8 | -------------------------------------------------------------------------------- /config/stripe.php: -------------------------------------------------------------------------------- 1 | env('STRIPE_KEY'), 5 | 'secret' => env('STRIPE_SECRET'), 6 | ]; 7 | -------------------------------------------------------------------------------- /app/Cart/Contracts/CartInterface.php: -------------------------------------------------------------------------------- 1 | merge(['class' => 'block font-medium text-sm text-gray-700']) }}> 4 | {{ $value ?? $slot }} 5 | 6 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.blade.php diff=html 4 | *.css diff=css 5 | *.html diff=html 6 | *.md diff=markdown 7 | *.php diff=php 8 | 9 | /.github export-ignore 10 | CHANGELOG.md export-ignore 11 | -------------------------------------------------------------------------------- /app/Cart/Exceptions/QuantityNoLongerAvailableException.php: -------------------------------------------------------------------------------- 1 | merge(['class' => 'font-medium text-sm text-green-600']) }}> 5 | {{ $status }} 6 | 7 | @endif 8 | -------------------------------------------------------------------------------- /resources/views/components/select.blade.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /resources/views/components/dropdown-link.blade.php: -------------------------------------------------------------------------------- 1 | merge(['class' => 'block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 transition duration-150 ease-in-out']) }}>{{ $slot }} 2 | -------------------------------------------------------------------------------- /.styleci.yml: -------------------------------------------------------------------------------- 1 | php: 2 | preset: laravel 3 | version: 8 4 | disabled: 5 | - no_unused_imports 6 | finder: 7 | not-name: 8 | - index.php 9 | - server.php 10 | js: 11 | finder: 12 | not-name: 13 | - webpack.mix.js 14 | css: true 15 | -------------------------------------------------------------------------------- /resources/views/components/input.blade.php: -------------------------------------------------------------------------------- 1 | @props(['disabled' => false]) 2 | 3 | merge(['class' => 'rounded-md shadow-sm border-gray-300 focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50']) !!}> 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /public/hot 3 | /public/storage 4 | /storage/*.key 5 | /vendor 6 | .env 7 | .env.backup 8 | .phpunit.result.cache 9 | docker-compose.override.yml 10 | Homestead.json 11 | Homestead.yaml 12 | npm-debug.log 13 | yarn-error.log 14 | /.idea 15 | /.vscode 16 | -------------------------------------------------------------------------------- /app/Models/Stock.php: -------------------------------------------------------------------------------- 1 | 2 | {{ $category->title }} 3 | 4 | @foreach($category->children as $child) 5 | 6 | @endforeach 7 | 8 | -------------------------------------------------------------------------------- /resources/views/emails/order-created.blade.php: -------------------------------------------------------------------------------- 1 | @component('mail::message') 2 | # Your order (#{{ $order->id }}) has been placed. 3 | 4 | The body of your message. 5 | 6 | @component('mail::button', ['url' => '']) 7 | Button Text 8 | @endcomponent 9 | 10 | Thanks,
11 | {{ config('app.name') }} 12 | @endcomponent 13 | -------------------------------------------------------------------------------- /resources/views/emails/order-status-updated.blade.php: -------------------------------------------------------------------------------- 1 | @component('mail::message') 2 | # The status of your order (#{{ $order->id }}) has changed. 3 | 4 | The body of your message. 5 | 6 | @component('mail::button', ['url' => '']) 7 | Button Text 8 | @endcomponent 9 | 10 | Thanks,
11 | {{ config('app.name') }} 12 | @endcomponent 13 | -------------------------------------------------------------------------------- /.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,yaml}] 15 | indent_size = 2 16 | 17 | [docker-compose.yml] 18 | indent_size = 4 19 | -------------------------------------------------------------------------------- /resources/views/components/auth-card.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | {{ $logo }} 4 |
5 | 6 |
7 | {{ $slot }} 8 |
9 |
10 | -------------------------------------------------------------------------------- /tests/Unit/ExampleTest.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/Models/ShippingType.php: -------------------------------------------------------------------------------- 1 | price); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/Http/Controllers/CategoryShowController.php: -------------------------------------------------------------------------------- 1 | $category 13 | ]); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/Http/Controllers/OrderConfirmationIndexController.php: -------------------------------------------------------------------------------- 1 | $order 13 | ]); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /resources/views/cart/index.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | Cart 5 |

6 |
7 | 8 |
9 |
10 | 11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /app/Http/Controllers/HomeController.php: -------------------------------------------------------------------------------- 1 | get()->toTree(); 12 | 13 | return view('home', [ 14 | 'categories' => $categories 15 | ]); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/Models/Scopes/LiveScope.php: -------------------------------------------------------------------------------- 1 | whereNotNull('live_at'); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /resources/views/checkout.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | Checkout 5 |

6 |
7 | 8 |
9 |
10 | 11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/View/Components/AppLayout.php: -------------------------------------------------------------------------------- 1 | load('variations.children', 'variations.descendantsAndSelf.stocks'); 12 | 13 | return view('products.show', compact('product')); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/Http/Livewire/Cart.php: -------------------------------------------------------------------------------- 1 | '$refresh' 12 | ]; 13 | 14 | public function render(CartInterface $cart) 15 | { 16 | return view('livewire.cart', compact('cart')); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /resources/views/components/button-anchor.blade.php: -------------------------------------------------------------------------------- 1 | merge(['href' => '#', 'class' => 'inline-flex items-center px-4 py-2 bg-gray-800 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-gray-700 active:bg-gray-900 focus:outline-none focus:border-gray-900 focus:ring ring-gray-300 disabled:opacity-25 transition ease-in-out duration-150']) }}> 2 | {{ $slot }} 3 | 4 | -------------------------------------------------------------------------------- /resources/views/components/button.blade.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /resources/views/livewire/product-gallery.blade.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
5 | @foreach($product->getMedia() as $media) 6 | 9 | @endforeach 10 |
11 |
12 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 | @foreach($categories as $category) 6 | 7 | @endforeach 8 |
9 |
10 |
11 | 12 | -------------------------------------------------------------------------------- /tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 18 | 19 | $response->assertStatus(200); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Models/Category.php: -------------------------------------------------------------------------------- 1 | belongsToMany(Product::class); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/Http/Middleware/PreventRequestsDuringMaintenance.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustHosts.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function hosts() 15 | { 16 | return [ 17 | $this->allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | 'current_password', 16 | 'password', 17 | 'password_confirmation', 18 | ]; 19 | } 20 | -------------------------------------------------------------------------------- /app/Mail/OrderCreatedMail.php: -------------------------------------------------------------------------------- 1 | order = $order; 15 | } 16 | 17 | public function build() 18 | { 19 | return $this->subject('Your order has been placed') 20 | ->markdown('emails.order-created'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Providers/StripeServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->singleton('stripe', function () { 13 | return new StripeClient(config('stripe.secret')); 14 | }); 15 | } 16 | 17 | public function boot() 18 | { 19 | // 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 19 | 20 | return $app; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | any()) 4 |
5 |
6 | {{ __('Whoops! Something went wrong.') }} 7 |
8 | 9 | 14 |
15 | @endif 16 | -------------------------------------------------------------------------------- /resources/views/livewire/product-selector.blade.php: -------------------------------------------------------------------------------- 1 |
2 | @if ($initialVariation) 3 | 4 | @endif 5 | 6 | @if ($skuVariant) 7 |
8 |
9 | {{ $skuVariant->formattedPrice() }} 10 |
11 | 12 | Add to cart 13 |
14 | @endif 15 |
16 | -------------------------------------------------------------------------------- /app/Providers/CartServiceProvider.php: -------------------------------------------------------------------------------- 1 | app->singleton(CartInterface::class, function () { 14 | return new Cart(session()); 15 | }); 16 | } 17 | 18 | public function boot() 19 | { 20 | // 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Mail/OrderStatusUpdatedMail.php: -------------------------------------------------------------------------------- 1 | order = $order; 15 | } 16 | 17 | public function build() 18 | { 19 | return $this->subject('The status of your order has changed') 20 | ->markdown('emails.order-status-updated'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Listeners/AttachOrdersListener.php: -------------------------------------------------------------------------------- 1 | user->email)->get()->each(function ($order) use ($event) { 18 | $order->user()->associate($event->user); 19 | $order->save(); 20 | }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | const defaultTheme = require('tailwindcss/defaultTheme'); 2 | 3 | module.exports = { 4 | content: [ 5 | './vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php', 6 | './storage/framework/views/*.php', 7 | './resources/views/**/*.blade.php', 8 | ], 9 | 10 | theme: { 11 | extend: { 12 | fontFamily: { 13 | sans: ['Nunito', ...defaultTheme.fontFamily.sans], 14 | }, 15 | }, 16 | }, 17 | 18 | plugins: [require('@tailwindcss/forms')], 19 | }; 20 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 18 | return route('login'); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Livewire/ProductGallery.php: -------------------------------------------------------------------------------- 1 | selectedImageUrl = $this->product->getFirstMediaUrl(); 15 | } 16 | 17 | public function selectImage($url) 18 | { 19 | $this->selectedImageUrl = $url; 20 | } 21 | 22 | public function render() 23 | { 24 | return view('livewire.product-gallery'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Middleware/CartMiddleware.php: -------------------------------------------------------------------------------- 1 | cart = $cart; 16 | } 17 | 18 | public function handle(Request $request, Closure $next) 19 | { 20 | if (! $this->cart->exists()) { 21 | $this->cart->create($request->user()); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /resources/views/dashboard.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | {{ __('Dashboard') }} 5 |

6 |
7 | 8 |
9 |
10 |
11 |
12 | You're logged in! 13 |
14 |
15 |
16 |
17 |
18 | -------------------------------------------------------------------------------- /app/Http/Controllers/OrderIndexController.php: -------------------------------------------------------------------------------- 1 | middleware(['auth']); 12 | } 13 | 14 | public function __invoke(Request $request) 15 | { 16 | $orders = $request->user()->orders()->latest() 17 | ->with('variations.product', 'variations.media', 'variations.ancestorsAndSelf', 'shippingType') 18 | ->get(); 19 | 20 | return view('orders.index', compact('orders')); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfCartEmptyMiddleware.php: -------------------------------------------------------------------------------- 1 | cart = $cart; 16 | } 17 | 18 | public function handle(Request $request, Closure $next) 19 | { 20 | if ($this->cart->isEmpty()) { 21 | return redirect()->route('cart'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 18 | }); 19 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 18 | return $request->user(); 19 | }); 20 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /resources/views/components/nav-link.blade.php: -------------------------------------------------------------------------------- 1 | @props(['active']) 2 | 3 | @php 4 | $classes = ($active ?? false) 5 | ? 'inline-flex items-center px-1 pt-1 border-b-2 border-indigo-400 text-sm font-medium leading-5 text-gray-900 focus:outline-none focus:border-indigo-700 transition duration-150 ease-in-out' 6 | : 'inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 text-gray-500 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out'; 7 | @endphp 8 | 9 | merge(['class' => $classes]) }}> 10 | {{ $slot }} 11 | 12 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 19 | })->purpose('Display an inspiring quote'); 20 | -------------------------------------------------------------------------------- /database/migrations/2022_03_28_204252_create_stocks_table.php: -------------------------------------------------------------------------------- 1 | id(); 13 | $table->foreignId('variation_id')->constrained(); 14 | $table->integer('amount'); 15 | $table->timestamps(); 16 | }); 17 | } 18 | 19 | public function down() 20 | { 21 | Schema::dropIfExists('stocks'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /database/migrations/2022_04_01_200330_create_carts_table.php: -------------------------------------------------------------------------------- 1 | id(); 13 | $table->uuid('uuid'); 14 | $table->foreignId('user_id')->nullable()->constrained(); 15 | $table->timestamps(); 16 | }); 17 | } 18 | 19 | public function down() 20 | { 21 | Schema::dropIfExists('carts'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /database/migrations/2022_06_12_184200_add_payment_intent_id_to_carts_table.php: -------------------------------------------------------------------------------- 1 | string('payment_intent_id')->nullable(); 13 | }); 14 | } 15 | 16 | public function down() 17 | { 18 | Schema::table('carts', function (Blueprint $table) { 19 | $table->dropColumn('payment_intent_id'); 20 | }); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /database/migrations/2022_05_18_195907_create_shipping_types_table.php: -------------------------------------------------------------------------------- 1 | id(); 13 | $table->string('title'); 14 | $table->integer('price')->unsigned(); 15 | $table->timestamps(); 16 | }); 17 | } 18 | 19 | public function down() 20 | { 21 | Schema::dropIfExists('shipping_types'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Send Requests To Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /app/Http/Controllers/CartIndexController.php: -------------------------------------------------------------------------------- 1 | verifyAvailableQuantities(); 14 | } catch (QuantityNoLongerAvailableException $e) { 15 | session()->flash('notification', 'Some items or quantities in your cart have become unavailable.'); 16 | 17 | $cart->syncAvailableQuantities(); 18 | } 19 | 20 | return view('cart.index'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Models/ShippingAddress.php: -------------------------------------------------------------------------------- 1 | address, 22 | $this->city, 23 | $this->postcode 24 | ); 25 | } 26 | 27 | public function user() 28 | { 29 | return $this->belongsTo(User::class); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /resources/views/categories/show.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | @foreach ($category->ancestors->reverse() as $ancestor) 5 | 6 | {{ $ancestor->title }} 7 | 8 | 9 | / 10 | @endforeach 11 |
12 | 13 |

14 | {{ $category->title }} 15 |

16 |
17 | 18 | 19 |
20 | -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | const mix = require('laravel-mix'); 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Mix Asset Management 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Mix provides a clean, fluent API for defining some Webpack build steps 9 | | for your Laravel applications. By default, we are compiling the CSS 10 | | file for the application as well as bundling up all the JS files. 11 | | 12 | */ 13 | 14 | mix.js('resources/js/app.js', 'public/js').postCss('resources/css/app.css', 'public/css', [ 15 | require('postcss-import'), 16 | require('tailwindcss'), 17 | require('autoprefixer'), 18 | ]).disableNotifications(); 19 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/EmailVerificationPromptController.php: -------------------------------------------------------------------------------- 1 | user()->hasVerifiedEmail() 20 | ? redirect()->intended(RouteServiceProvider::HOME) 21 | : view('auth.verify-email'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /resources/views/components/responsive-nav-link.blade.php: -------------------------------------------------------------------------------- 1 | @props(['active']) 2 | 3 | @php 4 | $classes = ($active ?? false) 5 | ? 'block pl-3 pr-4 py-2 border-l-4 border-indigo-400 text-base font-medium text-indigo-700 bg-indigo-50 focus:outline-none focus:text-indigo-800 focus:bg-indigo-100 focus:border-indigo-700 transition duration-150 ease-in-out' 6 | : 'block pl-3 pr-4 py-2 border-l-4 border-transparent text-base font-medium text-gray-600 hover:text-gray-800 hover:bg-gray-50 hover:border-gray-300 focus:outline-none focus:text-gray-800 focus:bg-gray-50 focus:border-gray-300 transition duration-150 ease-in-out'; 7 | @endphp 8 | 9 | merge(['class' => $classes]) }}> 10 | {{ $slot }} 11 | 12 | -------------------------------------------------------------------------------- /app/Models/Presenters/OrderPresenter.php: -------------------------------------------------------------------------------- 1 | order = $order; 14 | } 15 | 16 | public function status() 17 | { 18 | if ($this->order->status() === 'placed_at') { 19 | return 'Order Placed'; 20 | } 21 | 22 | if ($this->order->status() === 'packaged_at') { 23 | return 'Order Packaged'; 24 | } 25 | 26 | if ($this->order->status() === 'shipped_at') { 27 | return 'Order shipped'; 28 | } 29 | 30 | return ''; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2022_05_14_203358_create_category_product_table.php: -------------------------------------------------------------------------------- 1 | id(); 13 | $table->foreignId('category_id')->constrained(); 14 | $table->foreignId('product_id')->constrained(); 15 | $table->timestamps(); 16 | }); 17 | } 18 | 19 | public function down() 20 | { 21 | Schema::dropIfExists('category_product'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "npm run development", 5 | "development": "mix", 6 | "watch": "mix watch", 7 | "watch-poll": "mix watch -- --watch-options-poll=1000", 8 | "hot": "mix watch --hot", 9 | "prod": "npm run production", 10 | "production": "mix --production" 11 | }, 12 | "devDependencies": { 13 | "@tailwindcss/forms": "^0.4.0", 14 | "alpinejs": "^3.4.2", 15 | "autoprefixer": "^10.4.2", 16 | "axios": "^0.21", 17 | "laravel-mix": "^6.0.6", 18 | "lodash": "^4.17.19", 19 | "postcss": "^8.4.6", 20 | "postcss-import": "^14.0.2", 21 | "tailwindcss": "^3.0.18" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /database/migrations/2022_03_19_210350_create_categories_table.php: -------------------------------------------------------------------------------- 1 | id(); 13 | $table->string('title'); 14 | $table->string('slug')->unique(); 15 | $table->unsignedBigInteger('parent_id')->nullable(); 16 | $table->timestamps(); 17 | }); 18 | } 19 | 20 | public function down() 21 | { 22 | Schema::dropIfExists('categories'); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /database/migrations/2022_05_26_205236_create_order_variation_table.php: -------------------------------------------------------------------------------- 1 | id(); 12 | $table->foreignId('order_id')->constrained(); 13 | $table->foreignId('variation_id')->constrained(); 14 | $table->integer('quantity'); 15 | $table->timestamps(); 16 | }); 17 | } 18 | 19 | public function down() 20 | { 21 | Schema::dropIfExists('order_variation'); 22 | } 23 | }; 24 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $policies = [ 16 | // 'App\Models\Model' => 'App\Policies\ModelPolicy', 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | * 22 | * @return void 23 | */ 24 | public function boot() 25 | { 26 | $this->registerPolicies(); 27 | 28 | // 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'password' => 'The provided password is incorrect.', 18 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 19 | 20 | ]; 21 | -------------------------------------------------------------------------------- /resources/views/orders/confirmation.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | Thanks for your order 5 |

6 |
7 | 8 |
9 |
10 |
11 |
12 | Your order (#{{ $order->id }}) has been placed. 13 | 14 | Create an account to manage your orders. 15 |
16 |
17 |
18 |
19 |
20 | -------------------------------------------------------------------------------- /database/migrations/2022_04_01_200518_create_cart_variation_table.php: -------------------------------------------------------------------------------- 1 | id(); 13 | $table->foreignId('cart_id')->constrained(); 14 | $table->foreignId('variation_id')->constrained(); 15 | $table->integer('quantity'); 16 | $table->timestamps(); 17 | }); 18 | } 19 | 20 | public function down() 21 | { 22 | Schema::dropIfExists('cart_variation'); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/Http/Controllers/CheckoutIndexController.php: -------------------------------------------------------------------------------- 1 | middleware(RedirectIfCartEmptyMiddleware::class); 14 | } 15 | 16 | public function __invoke(CartInterface $cart) 17 | { 18 | try { 19 | $cart->verifyAvailableQuantities(); 20 | } catch (QuantityNoLongerAvailableException $e) { 21 | $cart->syncAvailableQuantities(); 22 | } 23 | 24 | return view('checkout'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | |string|null 14 | */ 15 | protected $proxies; 16 | 17 | /** 18 | * The headers that should be used to detect proxies. 19 | * 20 | * @var int 21 | */ 22 | protected $headers = 23 | Request::HEADER_X_FORWARDED_FOR | 24 | Request::HEADER_X_FORWARDED_HOST | 25 | Request::HEADER_X_FORWARDED_PORT | 26 | Request::HEADER_X_FORWARDED_PROTO | 27 | Request::HEADER_X_FORWARDED_AWS_ELB; 28 | } 29 | -------------------------------------------------------------------------------- /app/Http/Livewire/Navigation.php: -------------------------------------------------------------------------------- 1 | '$refresh' 15 | ]; 16 | 17 | public function clearSearch() 18 | { 19 | $this->searchQuery = ''; 20 | } 21 | 22 | public function getCartProperty(CartInterface $cart) 23 | { 24 | return $cart; 25 | } 26 | 27 | public function render() 28 | { 29 | $products = Product::search($this->searchQuery)->get(); 30 | 31 | return view('livewire.navigation', [ 32 | 'products' => $products 33 | ]); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /database/migrations/2022_05_20_210222_create_shipping_addresses_table.php: -------------------------------------------------------------------------------- 1 | id(); 13 | $table->foreignId('user_id')->nullable()->constrained(); 14 | $table->string('address'); 15 | $table->string('city'); 16 | $table->string('postcode'); 17 | $table->timestamps(); 18 | }); 19 | } 20 | 21 | public function down() 22 | { 23 | Schema::dropIfExists('shipping_addresses'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire')->hourly(); 19 | } 20 | 21 | /** 22 | * Register the commands for the application. 23 | * 24 | * @return void 25 | */ 26 | protected function commands() 27 | { 28 | $this->load(__DIR__.'/Commands'); 29 | 30 | require base_path('routes/console.php'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2022_03_21_203403_create_products_table.php: -------------------------------------------------------------------------------- 1 | id(); 13 | $table->string('title'); 14 | $table->string('slug')->unique(); 15 | $table->string('description')->nullable(); 16 | $table->integer('price')->unsigned(); 17 | $table->dateTime('live_at')->nullable(); 18 | $table->timestamps(); 19 | }); 20 | } 21 | 22 | public function down() 23 | { 24 | Schema::dropIfExists('products'); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Your password has been reset!', 17 | 'sent' => 'We have emailed your password reset link!', 18 | 'throttled' => 'Please wait before retrying.', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that email address.", 21 | 22 | ]; 23 | -------------------------------------------------------------------------------- /app/Models/Cart.php: -------------------------------------------------------------------------------- 1 | uuid = (string)Str::uuid(); 22 | }); 23 | } 24 | 25 | public function user() 26 | { 27 | return $this->belongsTo(User::class); 28 | } 29 | 30 | public function variations() 31 | { 32 | return $this->belongsToMany(Variation::class) 33 | ->withPivot('quantity') 34 | ->orderBy('id'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/EmailVerificationNotificationController.php: -------------------------------------------------------------------------------- 1 | user()->hasVerifiedEmail()) { 20 | return redirect()->intended(RouteServiceProvider::HOME); 21 | } 22 | 23 | $request->user()->sendEmailVerificationNotification(); 24 | 25 | return back()->with('status', 'verification-link-sent'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/Observers/OrderObserver.php: -------------------------------------------------------------------------------- 1 | getOriginal()) 15 | ->only($order->statuses) 16 | ->toArray() 17 | ); 18 | 19 | 20 | $filledStatuses = collect($order->getDirty()) 21 | ->only($order->statuses) 22 | ->filter(function ($status) { 23 | return filled($status); 24 | }); 25 | 26 | if ($originalOrder->status() !== $order->status() && $filledStatuses->count()) { 27 | Mail::to($order->user)->send(new OrderStatusUpdatedMail($order)); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /resources/views/layouts/guest.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ config('app.name', 'Laravel') }} 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | {{ $slot }} 22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | map(function ($value) { 29 | if (is_array($value) || is_object($value)) { 30 | return collect($value)->recursive(); 31 | } 32 | 33 | return $value; 34 | }); 35 | }); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /resources/views/livewire/product-dropdown.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | {{ Str::title(optional($variations->first())->type) }} 4 |
5 | 6 | 7 | 8 | 9 | @foreach ($variations as $variation) 10 | 13 | @endforeach 14 | 15 | 16 | @if (optional(optional($this->selectedVariationModel)->children)->count()) 17 | 18 | @endif 19 |
20 | -------------------------------------------------------------------------------- /tests/Feature/Auth/RegistrationTest.php: -------------------------------------------------------------------------------- 1 | get('/register'); 16 | 17 | $response->assertStatus(200); 18 | } 19 | 20 | public function test_new_users_can_register() 21 | { 22 | $response = $this->post('/register', [ 23 | 'name' => 'Test User', 24 | 'email' => 'test@example.com', 25 | 'password' => 'password', 26 | 'password_confirmation' => 'password', 27 | ]); 28 | 29 | $this->assertAuthenticated(); 30 | $response->assertRedirect(RouteServiceProvider::HOME); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Http/Livewire/ProductDropdown.php: -------------------------------------------------------------------------------- 1 | selectedVariation) { 16 | return; 17 | } 18 | 19 | return Variation::find($this->selectedVariation); 20 | } 21 | 22 | public function updatedSelectedVariation() 23 | { 24 | $this->emitTo('product-selector', 'skuVariantSelected', null); 25 | 26 | if (optional($this->selectedVariationModel)->sku) { 27 | $this->emitTo('product-selector', 'skuVariantSelected', $this->selectedVariation); 28 | } 29 | } 30 | 31 | public function render() 32 | { 33 | return view('livewire.product-dropdown'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /database/migrations/2022_03_23_191747_create_variations_table.php: -------------------------------------------------------------------------------- 1 | id(); 13 | $table->foreignId('product_id')->constrained(); 14 | $table->string('title'); 15 | $table->integer('price')->unsigned()->default(0); 16 | $table->string('type'); 17 | $table->string('sku')->nullable(); 18 | $table->unsignedBigInteger('parent_id')->nullable(); 19 | $table->integer('order')->nullable(); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | public function down() 25 | { 26 | Schema::dropIfExists('variations'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /config/cors.php: -------------------------------------------------------------------------------- 1 | ['api/*', 'sanctum/csrf-cookie'], 19 | 20 | 'allowed_methods' => ['*'], 21 | 22 | 'allowed_origins' => ['*'], 23 | 24 | 'allowed_origins_patterns' => [], 25 | 26 | 'allowed_headers' => ['*'], 27 | 28 | 'exposed_headers' => [], 29 | 30 | 'max_age' => 0, 31 | 32 | 'supports_credentials' => false, 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | window._ = require('lodash'); 2 | 3 | /** 4 | * We'll load the axios HTTP library which allows us to easily issue requests 5 | * to our Laravel back-end. This library automatically handles sending the 6 | * CSRF token as a header based on the value of the "XSRF" token cookie. 7 | */ 8 | 9 | window.axios = require('axios'); 10 | 11 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 12 | 13 | /** 14 | * Echo exposes an expressive API for subscribing to channels and listening 15 | * for events that are broadcast by Laravel. Echo and event broadcasting 16 | * allows your team to easily build robust real-time web applications. 17 | */ 18 | 19 | // import Echo from 'laravel-echo'; 20 | 21 | // window.Pusher = require('pusher-js'); 22 | 23 | // window.Echo = new Echo({ 24 | // broadcaster: 'pusher', 25 | // key: process.env.MIX_PUSHER_APP_KEY, 26 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER, 27 | // forceTLS: true 28 | // }); 29 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('name'); 19 | $table->string('email')->unique(); 20 | $table->timestamp('email_verified_at')->nullable(); 21 | $table->string('password'); 22 | $table->rememberToken(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('users'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | > 14 | */ 15 | protected $dontReport = [ 16 | // 17 | ]; 18 | 19 | /** 20 | * A list of the inputs that are never flashed for validation exceptions. 21 | * 22 | * @var array 23 | */ 24 | protected $dontFlash = [ 25 | 'current_password', 26 | 'password', 27 | 'password_confirmation', 28 | ]; 29 | 30 | /** 31 | * Register the exception handling callbacks for the application. 32 | * 33 | * @return void 34 | */ 35 | public function register() 36 | { 37 | $this->reportable(function (Throwable $e) { 38 | // 39 | }); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->string('uuid')->unique(); 19 | $table->text('connection'); 20 | $table->text('queue'); 21 | $table->longText('payload'); 22 | $table->longText('exception'); 23 | $table->timestamp('failed_at')->useCurrent(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('failed_jobs'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | > 18 | */ 19 | protected $listen = [ 20 | Registered::class => [ 21 | SendEmailVerificationNotification::class, 22 | AttachOrdersListener::class, 23 | ], 24 | ]; 25 | 26 | /** 27 | * Register any events for your application. 28 | * 29 | * @return void 30 | */ 31 | public function boot() 32 | { 33 | Order::observe(OrderObserver::class); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 26 | return redirect(RouteServiceProvider::HOME); 27 | } 28 | } 29 | 30 | return $next($request); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/VerifyEmailController.php: -------------------------------------------------------------------------------- 1 | user()->hasVerifiedEmail()) { 21 | return redirect()->intended(RouteServiceProvider::HOME.'?verified=1'); 22 | } 23 | 24 | if ($request->user()->markEmailAsVerified()) { 25 | event(new Verified($request->user())); 26 | } 27 | 28 | return redirect()->intended(RouteServiceProvider::HOME.'?verified=1'); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | $table->morphs('tokenable'); 19 | $table->string('name'); 20 | $table->string('token', 64)->unique(); 21 | $table->text('abilities')->nullable(); 22 | $table->timestamp('last_used_at')->nullable(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::dropIfExists('personal_access_tokens'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/migrations/2022_05_26_190028_create_orders_table.php: -------------------------------------------------------------------------------- 1 | id(); 12 | $table->uuid('uuid'); 13 | $table->string('email'); 14 | $table->foreignId('user_id')->nullable()->constrained(); 15 | $table->foreignId('shipping_address_id')->constrained(); 16 | $table->foreignId('shipping_type_id')->constrained(); 17 | $table->integer('subtotal'); 18 | $table->timestamp('placed_at')->nullable(); 19 | $table->timestamp('packaged_at')->nullable(); 20 | $table->timestamp('shipped_at')->nullable(); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | public function down() 26 | { 27 | Schema::dropIfExists('orders'); 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /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 | 'postmark' => [ 24 | 'token' => env('POSTMARK_TOKEN'), 25 | ], 26 | 27 | 'ses' => [ 28 | 'key' => env('AWS_ACCESS_KEY_ID'), 29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 31 | ], 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /app/Http/Livewire/CartItem.php: -------------------------------------------------------------------------------- 1 | quantity = $this->variation->pivot->quantity; 17 | } 18 | 19 | public function updatedQuantity($quantity) 20 | { 21 | app(CartInterface::class)->changeQuantity($this->variation, $quantity); 22 | 23 | $this->emit('cart.updated'); 24 | 25 | $this->dispatchBrowserEvent('notification', [ 26 | 'body' => 'Quantity updated' 27 | ]); 28 | } 29 | 30 | public function remove(CartInterface $cart) 31 | { 32 | $cart->remove($this->variation); 33 | 34 | $this->emit('cart.updated'); 35 | 36 | $this->dispatchBrowserEvent('notification', [ 37 | 'body' => $this->variation->product->title . ' removed from cart.' 38 | ]); 39 | } 40 | 41 | public function render() 42 | { 43 | return view('livewire.cart-item'); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | $this->faker->name(), 19 | 'email' => $this->faker->unique()->safeEmail(), 20 | 'email_verified_at' => now(), 21 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 22 | 'remember_token' => Str::random(10), 23 | ]; 24 | } 25 | 26 | /** 27 | * Indicate that the model's email address should be unverified. 28 | * 29 | * @return \Illuminate\Database\Eloquent\Factories\Factory 30 | */ 31 | public function unverified() 32 | { 33 | return $this->state(function (array $attributes) { 34 | return [ 35 | 'email_verified_at' => null, 36 | ]; 37 | }); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | LOG_DEPRECATIONS_CHANNEL=null 9 | LOG_LEVEL=debug 10 | 11 | DB_CONNECTION=mysql 12 | DB_HOST=127.0.0.1 13 | DB_PORT=3306 14 | DB_DATABASE=laravel 15 | DB_USERNAME=root 16 | DB_PASSWORD= 17 | 18 | BROADCAST_DRIVER=log 19 | CACHE_DRIVER=file 20 | FILESYSTEM_DRIVER=local 21 | QUEUE_CONNECTION=sync 22 | SESSION_DRIVER=file 23 | SESSION_LIFETIME=120 24 | 25 | MEMCACHED_HOST=127.0.0.1 26 | 27 | REDIS_HOST=127.0.0.1 28 | REDIS_PASSWORD=null 29 | REDIS_PORT=6379 30 | 31 | MAIL_MAILER=smtp 32 | MAIL_HOST=mailhog 33 | MAIL_PORT=1025 34 | MAIL_USERNAME=null 35 | MAIL_PASSWORD=null 36 | MAIL_ENCRYPTION=null 37 | MAIL_FROM_ADDRESS=null 38 | MAIL_FROM_NAME="${APP_NAME}" 39 | 40 | AWS_ACCESS_KEY_ID= 41 | AWS_SECRET_ACCESS_KEY= 42 | AWS_DEFAULT_REGION=us-east-1 43 | AWS_BUCKET= 44 | AWS_USE_PATH_STYLE_ENDPOINT=false 45 | 46 | PUSHER_APP_ID= 47 | PUSHER_APP_KEY= 48 | PUSHER_APP_SECRET= 49 | PUSHER_APP_CLUSTER=mt1 50 | 51 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 52 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 53 | 54 | STRIPE_KEY= 55 | STRIPE_SECRET= 56 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /database/migrations/2022_03_30_235857_create_media_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 13 | 14 | $table->morphs('model'); 15 | $table->uuid('uuid')->nullable()->unique(); 16 | $table->string('collection_name'); 17 | $table->string('name'); 18 | $table->string('file_name'); 19 | $table->string('mime_type')->nullable(); 20 | $table->string('disk'); 21 | $table->string('conversions_disk')->nullable(); 22 | $table->unsignedBigInteger('size'); 23 | $table->json('manipulations'); 24 | $table->json('custom_properties'); 25 | $table->json('generated_conversions'); 26 | $table->json('responsive_images'); 27 | $table->unsignedInteger('order_column')->nullable()->index(); 28 | 29 | $table->nullableTimestamps(); 30 | }); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /resources/views/livewire/cart.blade.php: -------------------------------------------------------------------------------- 1 | @if ($cart->isEmpty()) 2 |
3 | Your cart is empty. 4 |
5 | @else 6 |
7 |
8 | @foreach($cart->contents() as $variation) 9 | 10 | @endforeach 11 |
12 | 13 |
14 |
15 |
16 |
17 |
Subtotal
18 |

19 | {{ $cart->formattedSubtotal() }} 20 |

21 |
22 |
23 | 24 | Checkout 25 |
26 | 27 |
28 |
29 | @endif 30 | -------------------------------------------------------------------------------- /tests/Feature/Auth/AuthenticationTest.php: -------------------------------------------------------------------------------- 1 | get('/login'); 17 | 18 | $response->assertStatus(200); 19 | } 20 | 21 | public function test_users_can_authenticate_using_the_login_screen() 22 | { 23 | $user = User::factory()->create(); 24 | 25 | $response = $this->post('/login', [ 26 | 'email' => $user->email, 27 | 'password' => 'password', 28 | ]); 29 | 30 | $this->assertAuthenticated(); 31 | $response->assertRedirect(RouteServiceProvider::HOME); 32 | } 33 | 34 | public function test_users_can_not_authenticate_with_invalid_password() 35 | { 36 | $user = User::factory()->create(); 37 | 38 | $this->post('/login', [ 39 | 'email' => $user->email, 40 | 'password' => 'wrong-password', 41 | ]); 42 | 43 | $this->assertGuest(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/Feature/Auth/PasswordConfirmationTest.php: -------------------------------------------------------------------------------- 1 | create(); 16 | 17 | $response = $this->actingAs($user)->get('/confirm-password'); 18 | 19 | $response->assertStatus(200); 20 | } 21 | 22 | public function test_password_can_be_confirmed() 23 | { 24 | $user = User::factory()->create(); 25 | 26 | $response = $this->actingAs($user)->post('/confirm-password', [ 27 | 'password' => 'password', 28 | ]); 29 | 30 | $response->assertRedirect(); 31 | $response->assertSessionHasNoErrors(); 32 | } 33 | 34 | public function test_password_is_not_confirmed_with_invalid_password() 35 | { 36 | $user = User::factory()->create(); 37 | 38 | $response = $this->actingAs($user)->post('/confirm-password', [ 39 | 'password' => 'wrong-password', 40 | ]); 41 | 42 | $response->assertSessionHasErrors(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /resources/views/products/show.blade.php: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 |
6 |
7 | 8 |
9 |
10 |
11 |

{{ $product->title }}

12 |

13 | {{ $product->formattedPrice() }} 14 |

15 |

16 | {{ $product->description }} 17 |

18 |
19 | 20 |
21 | 22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/ConfirmablePasswordController.php: -------------------------------------------------------------------------------- 1 | validate([ 32 | 'email' => $request->user()->email, 33 | 'password' => $request->password, 34 | ])) { 35 | throw ValidationException::withMessages([ 36 | 'password' => __('auth.password'), 37 | ]); 38 | } 39 | 40 | $request->session()->put('auth.password_confirmed_at', time()); 41 | 42 | return redirect()->intended(RouteServiceProvider::HOME); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | ./tests/Unit 10 | 11 | 12 | ./tests/Feature 13 | 14 | 15 | 16 | 17 | ./app 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /resources/views/components/notification.blade.php: -------------------------------------------------------------------------------- 1 |
19 |
20 |
21 |
22 |
23 | 27 |
28 |
29 |
30 |
31 | -------------------------------------------------------------------------------- /app/Http/Livewire/ProductSelector.php: -------------------------------------------------------------------------------- 1 | initialVariation = $this->product->variations->sortBy('order')->groupBy('type')->first(); 22 | } 23 | 24 | public function skuVariantSelected($variantId) 25 | { 26 | if (! $variantId) { 27 | $this->skuVariant = null; 28 | return; 29 | } 30 | 31 | $this->skuVariant = Variation::find($variantId); 32 | } 33 | 34 | public function addToCart(CartInterface $cart) 35 | { 36 | $cart->add($this->skuVariant, 1); 37 | 38 | $this->emit('cart.updated'); 39 | 40 | $this->dispatchBrowserEvent('notification', [ 41 | 'body' => $this->skuVariant->product->title . ' added to cart', 42 | 'timeout' => 4 * 1000 43 | ]); 44 | } 45 | 46 | public function render() 47 | { 48 | return view('livewire.product-selector'); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /resources/views/auth/confirm-password.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | {{ __('This is a secure area of the application. Please confirm your password before continuing.') }} 11 |
12 | 13 | 14 | 15 | 16 |
17 | @csrf 18 | 19 | 20 |
21 | 22 | 23 | 27 |
28 | 29 |
30 | 31 | {{ __('Confirm') }} 32 | 33 |
34 |
35 |
36 |
37 | -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | 19 | */ 20 | protected $fillable = [ 21 | 'name', 22 | 'email', 23 | 'password', 24 | ]; 25 | 26 | /** 27 | * The attributes that should be hidden for serialization. 28 | * 29 | * @var array 30 | */ 31 | protected $hidden = [ 32 | 'password', 33 | 'remember_token', 34 | ]; 35 | 36 | /** 37 | * The attributes that should be cast. 38 | * 39 | * @var array 40 | */ 41 | protected $casts = [ 42 | 'email_verified_at' => 'datetime', 43 | ]; 44 | 45 | public function shippingAddresses() 46 | { 47 | return $this->hasMany(ShippingAddress::class); 48 | 49 | } 50 | 51 | public function orders() 52 | { 53 | return $this->hasMany(Order::class); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /resources/views/auth/forgot-password.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | {{ __('Forgot your password? No problem. Just let us know your email address and we will email you a password reset link that will allow you to choose a new one.') }} 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | @csrf 21 | 22 | 23 |
24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 | {{ __('Email Password Reset Link') }} 32 | 33 |
34 |
35 |
36 |
37 | -------------------------------------------------------------------------------- /resources/views/components/dropdown.blade.php: -------------------------------------------------------------------------------- 1 | @props(['align' => 'right', 'width' => '48', 'contentClasses' => 'py-1 bg-white']) 2 | 3 | @php 4 | switch ($align) { 5 | case 'left': 6 | $alignmentClasses = 'origin-top-left left-0'; 7 | break; 8 | case 'top': 9 | $alignmentClasses = 'origin-top'; 10 | break; 11 | case 'right': 12 | default: 13 | $alignmentClasses = 'origin-top-right right-0'; 14 | break; 15 | } 16 | 17 | switch ($width) { 18 | case '48': 19 | $width = 'w-48'; 20 | break; 21 | } 22 | @endphp 23 | 24 |
25 |
26 | {{ $trigger }} 27 |
28 | 29 | 43 |
44 | -------------------------------------------------------------------------------- /resources/views/layouts/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{ config('app.name', 'Laravel') }} 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | @isset($header) 29 |
30 |
31 | {{ $header }} 32 |
33 |
34 | @endisset 35 | 36 | 37 |
38 | {{ $slot }} 39 |
40 |
41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | name('home'); 24 | 25 | Route::get('cart', CartIndexController::class)->name('cart'); 26 | 27 | Route::get('checkout', CheckoutIndexController::class); 28 | 29 | Route::get('categories/{category:slug}', CategoryShowController::class); 30 | 31 | Route::get('products/{product:slug}', ProductShowController::class); 32 | 33 | Route::get('orders/{order:uuid}/confirmation', OrderConfirmationIndexController::class)->name('orders.confirmation'); 34 | 35 | Route::get('orders', OrderIndexController::class)->name('orders'); 36 | 37 | Route::get('dashboard', function () { 38 | return view('dashboard'); 39 | })->middleware(['auth'])->name('dashboard'); 40 | 41 | require __DIR__.'/auth.php'; 42 | -------------------------------------------------------------------------------- /resources/views/livewire/cart-item.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 | 6 |
7 |
8 |
9 | {{ $variation->formattedPrice() }} 10 |
11 |
12 |
{{ $variation->product->title }}
13 | 14 |
15 | @foreach ($variation->ancestorsAndSelf as $ancestor) 16 | {{ $ancestor->title }} @if (! $loop->last) / @endif 17 | @endforeach 18 |
19 |
20 |
21 | 22 |
23 |
24 |
Quantity
25 | 30 |
31 | 32 | 35 |
36 |
37 |
38 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/PasswordResetLinkController.php: -------------------------------------------------------------------------------- 1 | validate([ 32 | 'email' => ['required', 'email'], 33 | ]); 34 | 35 | // We will send the password reset link to this user. Once we have attempted 36 | // to send the link, we will examine the response then see the message we 37 | // need to show to the user. Finally, we'll send out a proper response. 38 | $status = Password::sendResetLink( 39 | $request->only('email') 40 | ); 41 | 42 | return $status == Password::RESET_LINK_SENT 43 | ? back()->with('status', __($status)) 44 | : back()->withInput($request->only('email')) 45 | ->withErrors(['email' => __($status)]); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/AuthenticatedSessionController.php: -------------------------------------------------------------------------------- 1 | authenticate(); 33 | 34 | $request->session()->regenerate(); 35 | 36 | $cart->associate($request->user()); 37 | 38 | return redirect()->intended(RouteServiceProvider::HOME); 39 | } 40 | 41 | /** 42 | * Destroy an authenticated session. 43 | * 44 | * @param \Illuminate\Http\Request $request 45 | * @return \Illuminate\Http\RedirectResponse 46 | */ 47 | public function destroy(Request $request) 48 | { 49 | Auth::guard('web')->logout(); 50 | 51 | $request->session()->invalidate(); 52 | 53 | $request->session()->regenerateToken(); 54 | 55 | return redirect('/'); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /resources/views/auth/verify-email.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | {{ __('Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we just emailed to you? If you didn\'t receive the email, we will gladly send you another.') }} 11 |
12 | 13 | @if (session('status') == 'verification-link-sent') 14 |
15 | {{ __('A new verification link has been sent to the email address you provided during registration.') }} 16 |
17 | @endif 18 | 19 |
20 |
21 | @csrf 22 | 23 |
24 | 25 | {{ __('Resend Verification Email') }} 26 | 27 |
28 |
29 | 30 |
31 | @csrf 32 | 33 | 36 |
37 |
38 |
39 |
40 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/RegisteredUserController.php: -------------------------------------------------------------------------------- 1 | validate([ 37 | 'name' => ['required', 'string', 'max:255'], 38 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 39 | 'password' => ['required', 'confirmed', Rules\Password::defaults()], 40 | ]); 41 | 42 | $user = User::create([ 43 | 'name' => $request->name, 44 | 'email' => $request->email, 45 | 'password' => Hash::make($request->password), 46 | ]); 47 | 48 | event(new Registered($user)); 49 | 50 | Auth::login($user); 51 | 52 | return redirect(RouteServiceProvider::HOME); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /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' => 65536, 48 | 'threads' => 1, 49 | 'time' => 4, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/Models/Variation.php: -------------------------------------------------------------------------------- 1 | price); 22 | } 23 | 24 | public function inStock() 25 | { 26 | return $this->stockCount() > 0; 27 | } 28 | 29 | public function outOfStock() 30 | { 31 | return ! $this->inStock(); 32 | } 33 | 34 | public function lowStock() 35 | { 36 | return ! $this->outOfStock() && $this->stockCount() <= 5; 37 | } 38 | 39 | public function stockCount() 40 | { 41 | return $this->descendantsAndSelf->sum(function ($variation) { 42 | return $variation->stocks->sum('amount'); 43 | }); 44 | } 45 | 46 | public function stocks() 47 | { 48 | return $this->hasMany(Stock::class); 49 | } 50 | 51 | public function product() 52 | { 53 | return $this->belongsTo(Product::class); 54 | } 55 | 56 | public function registerMediaConversions(?Media $media = null): void 57 | { 58 | $this->addMediaConversion('thumb200x200') 59 | ->fit(Manipulations::FIT_CROP, 200, 200); 60 | } 61 | 62 | public function registerMediaCollections(): void 63 | { 64 | $this->addMediaCollection('default') 65 | ->useFallbackUrl(url('/storage/no-product-image.png')); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /resources/views/auth/reset-password.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | @csrf 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 |
24 | 25 | 26 |
27 | 28 | 29 | 30 |
31 | 32 | 33 |
34 | 35 | 36 | 39 |
40 | 41 |
42 | 43 | {{ __('Reset Password') }} 44 | 45 |
46 |
47 |
48 |
49 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class); 50 | 51 | $response = $kernel->handle( 52 | $request = Request::capture() 53 | )->send(); 54 | 55 | $kernel->terminate($request, $response); 56 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | configureRateLimiting(); 39 | 40 | $this->routes(function () { 41 | Route::prefix('api') 42 | ->middleware('api') 43 | ->namespace($this->namespace) 44 | ->group(base_path('routes/api.php')); 45 | 46 | Route::middleware('web') 47 | ->namespace($this->namespace) 48 | ->group(base_path('routes/web.php')); 49 | }); 50 | } 51 | 52 | /** 53 | * Configure the rate limiters for the application. 54 | * 55 | * @return void 56 | */ 57 | protected function configureRateLimiting() 58 | { 59 | RateLimiter::for('api', function (Request $request) { 60 | return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip()); 61 | }); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /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 | 'useTLS' => true, 41 | ], 42 | ], 43 | 44 | 'ably' => [ 45 | 'driver' => 'ably', 46 | 'key' => env('ABLY_KEY'), 47 | ], 48 | 49 | 'redis' => [ 50 | 'driver' => 'redis', 51 | 'connection' => 'default', 52 | ], 53 | 54 | 'log' => [ 55 | 'driver' => 'log', 56 | ], 57 | 58 | 'null' => [ 59 | 'driver' => 'null', 60 | ], 61 | 62 | ], 63 | 64 | ]; 65 | -------------------------------------------------------------------------------- /app/Models/Product.php: -------------------------------------------------------------------------------- 1 | price); 28 | } 29 | 30 | public function variations() 31 | { 32 | return $this->hasMany(Variation::class); 33 | } 34 | 35 | public function registerMediaConversions(?Media $media = null): void 36 | { 37 | $this->addMediaConversion('thumb200x200') 38 | ->fit(Manipulations::FIT_CROP, 200, 200); 39 | } 40 | 41 | public function registerMediaCollections(): void 42 | { 43 | $this->addMediaCollection('default') 44 | ->useFallbackUrl(url('/storage/no-product-image.png')); 45 | } 46 | 47 | public function categories() 48 | { 49 | return $this->belongsToMany(Category::class); 50 | } 51 | 52 | public function toSearchableArray() 53 | { 54 | return array_merge([ 55 | 'id' => $this->id, 56 | 'title' => $this->title, 57 | 'slug' => $this->slug, 58 | 'price' => $this->price, 59 | 'category_ids' => $this->categories->pluck('id')->toArray(), 60 | ], $this->variations->groupBy('type') 61 | ->mapWithKeys(function ($variation, $key) { 62 | return [ 63 | $key => $variation->pluck('title') 64 | ]; 65 | }) 66 | ->toArray() 67 | ); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /tests/Feature/Auth/EmailVerificationTest.php: -------------------------------------------------------------------------------- 1 | create([ 20 | 'email_verified_at' => null, 21 | ]); 22 | 23 | $response = $this->actingAs($user)->get('/verify-email'); 24 | 25 | $response->assertStatus(200); 26 | } 27 | 28 | public function test_email_can_be_verified() 29 | { 30 | $user = User::factory()->create([ 31 | 'email_verified_at' => null, 32 | ]); 33 | 34 | Event::fake(); 35 | 36 | $verificationUrl = URL::temporarySignedRoute( 37 | 'verification.verify', 38 | now()->addMinutes(60), 39 | ['id' => $user->id, 'hash' => sha1($user->email)] 40 | ); 41 | 42 | $response = $this->actingAs($user)->get($verificationUrl); 43 | 44 | Event::assertDispatched(Verified::class); 45 | $this->assertTrue($user->fresh()->hasVerifiedEmail()); 46 | $response->assertRedirect(RouteServiceProvider::HOME.'?verified=1'); 47 | } 48 | 49 | public function test_email_is_not_verified_with_invalid_hash() 50 | { 51 | $user = User::factory()->create([ 52 | 'email_verified_at' => null, 53 | ]); 54 | 55 | $verificationUrl = URL::temporarySignedRoute( 56 | 'verification.verify', 57 | now()->addMinutes(60), 58 | ['id' => $user->id, 'hash' => sha1('wrong-email')] 59 | ); 60 | 61 | $this->actingAs($user)->get($verificationUrl); 62 | 63 | $this->assertFalse($user->fresh()->hasVerifiedEmail()); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/Models/Order.php: -------------------------------------------------------------------------------- 1 | 'datetime', 30 | 'packaged_at' => 'datetime', 31 | 'shipped_at' => 'datetime' 32 | ]; 33 | 34 | public $statuses = [ 35 | 'placed_at', 36 | 'packaged_at', 37 | 'shipped_at' 38 | ]; 39 | 40 | protected static function booted() 41 | { 42 | static::creating(function (Order $order) { 43 | $order->placed_at = now(); 44 | $order->uuid = (string)Str::uuid(); 45 | }); 46 | } 47 | 48 | public function status() 49 | { 50 | return collect($this->statuses) 51 | ->last(function ($status) { 52 | return filled($this->{$status}); 53 | }); 54 | } 55 | 56 | public function formattedSubtotal() 57 | { 58 | return money($this->subtotal); 59 | } 60 | 61 | public function user() 62 | { 63 | return $this->belongsTo(User::class); 64 | } 65 | 66 | public function shippingType() 67 | { 68 | return $this->belongsTo(ShippingType::class); 69 | } 70 | 71 | public function shippingAddress() 72 | { 73 | return $this->belongsTo(ShippingAddress::class); 74 | } 75 | 76 | public function variations() 77 | { 78 | return $this->belongsToMany(Variation::class) 79 | ->withPivot(['quantity']) 80 | ->withTimestamps(); 81 | } 82 | 83 | public function presenter() 84 | { 85 | return new OrderPresenter($this); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /tests/Feature/Auth/PasswordResetTest.php: -------------------------------------------------------------------------------- 1 | get('/forgot-password'); 18 | 19 | $response->assertStatus(200); 20 | } 21 | 22 | public function test_reset_password_link_can_be_requested() 23 | { 24 | Notification::fake(); 25 | 26 | $user = User::factory()->create(); 27 | 28 | $this->post('/forgot-password', ['email' => $user->email]); 29 | 30 | Notification::assertSentTo($user, ResetPassword::class); 31 | } 32 | 33 | public function test_reset_password_screen_can_be_rendered() 34 | { 35 | Notification::fake(); 36 | 37 | $user = User::factory()->create(); 38 | 39 | $this->post('/forgot-password', ['email' => $user->email]); 40 | 41 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) { 42 | $response = $this->get('/reset-password/'.$notification->token); 43 | 44 | $response->assertStatus(200); 45 | 46 | return true; 47 | }); 48 | } 49 | 50 | public function test_password_can_be_reset_with_valid_token() 51 | { 52 | Notification::fake(); 53 | 54 | $user = User::factory()->create(); 55 | 56 | $this->post('/forgot-password', ['email' => $user->email]); 57 | 58 | Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) { 59 | $response = $this->post('/reset-password', [ 60 | 'token' => $notification->token, 61 | 'email' => $user->email, 62 | 'password' => 'password', 63 | 'password_confirmation' => 'password', 64 | ]); 65 | 66 | $response->assertSessionHasNoErrors(); 67 | 68 | return true; 69 | }); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/Http/Livewire/ProductBrowser.php: -------------------------------------------------------------------------------- 1 | null 16 | ]; 17 | 18 | public function mount() 19 | { 20 | $this->queryFilters = $this->category->products->pluck('variations') 21 | ->flatten() 22 | ->groupBy('type') 23 | ->keys() 24 | ->mapWithKeys(function ($key) { 25 | return [$key => []]; 26 | }) 27 | ->toArray(); 28 | } 29 | 30 | public function render() 31 | { 32 | $search = Product::search('', function ($meilisearch, $query, $options) { 33 | $filters = collect($this->queryFilters) 34 | ->filter() 35 | ->recursive() 36 | ->map(function ($value, $key) { 37 | return $value->map(function ($value) use ($key) { 38 | return $key . ' = "' . $value . '"'; 39 | }); 40 | }) 41 | ->flatten() 42 | ->join(' OR '); 43 | 44 | $options['facetsDistribution'] = ['size', 'color']; //refactor 45 | 46 | $options['filter'] = null; 47 | 48 | if ($filters) { 49 | $options['filter'] = $filters; 50 | } 51 | 52 | if ($this->priceRage['max']) { 53 | $options['filter'] .= (isset($options['filter']) ? ' AND ' : '') . 'price <= ' . $this->priceRage['max']; 54 | } 55 | 56 | return $meilisearch->search($query, $options); 57 | }) 58 | ->raw(); 59 | 60 | $products = $this->category->products->find( 61 | collect($search['hits'])->pluck('id') 62 | ); 63 | 64 | $maxPrice = $this->category->products->max('price'); 65 | 66 | $this->priceRage['max'] = $this->priceRage['max'] ?: $maxPrice; 67 | 68 | return view('livewire.product-browser', [ 69 | 'products' => $products, 70 | 'filters' => $search['facetsDistribution'], 71 | 'maxPrice' => $maxPrice 72 | ]); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /resources/views/auth/register.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | @csrf 14 | 15 | 16 |
17 | 18 | 19 | 20 |
21 | 22 | 23 |
24 | 25 | 26 | 27 |
28 | 29 | 30 |
31 | 32 | 33 | 37 |
38 | 39 | 40 |
41 | 42 | 43 | 46 |
47 | 48 |
49 | 50 | {{ __('Already registered?') }} 51 | 52 | 53 | 54 | {{ __('Register') }} 55 | 56 |
57 |
58 |
59 |
60 | -------------------------------------------------------------------------------- /resources/views/auth/login.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | @csrf 17 | 18 | 19 |
20 | 21 | 22 | 23 |
24 | 25 | 26 |
27 | 28 | 29 | 33 |
34 | 35 | 36 |
37 | 41 |
42 | 43 |
44 | @if (Route::has('password.request')) 45 | 46 | {{ __('Forgot your password?') }} 47 | 48 | @endif 49 | 50 | 51 | {{ __('Log in') }} 52 | 53 |
54 |
55 |
56 |
57 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The Laravel Framework.", 5 | "keywords": ["framework", "laravel"], 6 | "license": "MIT", 7 | "require": { 8 | "php": "^7.3|^8.0", 9 | "cknow/laravel-money": "^6.3", 10 | "fruitcake/laravel-cors": "^2.0", 11 | "guzzlehttp/guzzle": "^7.0.1", 12 | "http-interop/http-factory-guzzle": "^1.2", 13 | "laravel/framework": "^8.75", 14 | "laravel/sanctum": "^2.11", 15 | "laravel/scout": "^9.4", 16 | "laravel/tinker": "^2.5", 17 | "livewire/livewire": "^2.10", 18 | "meilisearch/meilisearch-php": "^0.23.2", 19 | "spatie/laravel-medialibrary": "^9.0.0", 20 | "staudenmeir/laravel-adjacency-list": "^1.0", 21 | "stripe/stripe-php": "^8.6" 22 | }, 23 | "require-dev": { 24 | "barryvdh/laravel-debugbar": "^3.6", 25 | "facade/ignition": "^2.5", 26 | "fakerphp/faker": "^1.9.1", 27 | "laravel/breeze": "^1.8", 28 | "laravel/sail": "^1.0.1", 29 | "mockery/mockery": "^1.4.4", 30 | "nunomaduro/collision": "^5.10", 31 | "phpunit/phpunit": "^9.5.10" 32 | }, 33 | "autoload": { 34 | "psr-4": { 35 | "App\\": "app/", 36 | "Database\\Factories\\": "database/factories/", 37 | "Database\\Seeders\\": "database/seeders/" 38 | } 39 | }, 40 | "autoload-dev": { 41 | "psr-4": { 42 | "Tests\\": "tests/" 43 | } 44 | }, 45 | "scripts": { 46 | "post-autoload-dump": [ 47 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 48 | "@php artisan package:discover --ansi" 49 | ], 50 | "post-update-cmd": [ 51 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force" 52 | ], 53 | "post-root-package-install": [ 54 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 55 | ], 56 | "post-create-project-cmd": [ 57 | "@php artisan key:generate --ansi" 58 | ] 59 | }, 60 | "extra": { 61 | "laravel": { 62 | "dont-discover": [] 63 | } 64 | }, 65 | "config": { 66 | "optimize-autoloader": true, 67 | "preferred-install": "dist", 68 | "sort-packages": true 69 | }, 70 | "minimum-stability": "dev", 71 | "prefer-stable": true 72 | } 73 | -------------------------------------------------------------------------------- /config/sanctum.php: -------------------------------------------------------------------------------- 1 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( 17 | '%s%s', 18 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', 19 | env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : '' 20 | ))), 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Sanctum Guards 25 | |-------------------------------------------------------------------------- 26 | | 27 | | This array contains the authentication guards that will be checked when 28 | | Sanctum is trying to authenticate a request. If none of these guards 29 | | are able to authenticate the request, Sanctum will use the bearer 30 | | token that's present on an incoming request for authentication. 31 | | 32 | */ 33 | 34 | 'guard' => ['web'], 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Expiration Minutes 39 | |-------------------------------------------------------------------------- 40 | | 41 | | This value controls the number of minutes until an issued token will be 42 | | considered expired. If this value is null, personal access tokens do 43 | | not expire. This won't tweak the lifetime of first-party sessions. 44 | | 45 | */ 46 | 47 | 'expiration' => null, 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Sanctum Middleware 52 | |-------------------------------------------------------------------------- 53 | | 54 | | When authenticating your first-party SPA with Sanctum you may need to 55 | | customize some of the middleware Sanctum uses while processing the 56 | | request. You may change the middleware listed below as required. 57 | | 58 | */ 59 | 60 | 'middleware' => [ 61 | 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, 62 | 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, 63 | ], 64 | 65 | ]; 66 | -------------------------------------------------------------------------------- /routes/auth.php: -------------------------------------------------------------------------------- 1 | group(function () { 14 | Route::get('register', [RegisteredUserController::class, 'create']) 15 | ->name('register'); 16 | 17 | Route::post('register', [RegisteredUserController::class, 'store']); 18 | 19 | Route::get('login', [AuthenticatedSessionController::class, 'create']) 20 | ->name('login'); 21 | 22 | Route::post('login', [AuthenticatedSessionController::class, 'store']); 23 | 24 | Route::get('forgot-password', [PasswordResetLinkController::class, 'create']) 25 | ->name('password.request'); 26 | 27 | Route::post('forgot-password', [PasswordResetLinkController::class, 'store']) 28 | ->name('password.email'); 29 | 30 | Route::get('reset-password/{token}', [NewPasswordController::class, 'create']) 31 | ->name('password.reset'); 32 | 33 | Route::post('reset-password', [NewPasswordController::class, 'store']) 34 | ->name('password.update'); 35 | }); 36 | 37 | Route::middleware('auth')->group(function () { 38 | Route::get('verify-email', [EmailVerificationPromptController::class, '__invoke']) 39 | ->name('verification.notice'); 40 | 41 | Route::get('verify-email/{id}/{hash}', [VerifyEmailController::class, '__invoke']) 42 | ->middleware(['signed', 'throttle:6,1']) 43 | ->name('verification.verify'); 44 | 45 | Route::post('email/verification-notification', [EmailVerificationNotificationController::class, 'store']) 46 | ->middleware('throttle:6,1') 47 | ->name('verification.send'); 48 | 49 | Route::get('confirm-password', [ConfirmablePasswordController::class, 'show']) 50 | ->name('password.confirm'); 51 | 52 | Route::post('confirm-password', [ConfirmablePasswordController::class, 'store']); 53 | 54 | Route::post('logout', [AuthenticatedSessionController::class, 'destroy']) 55 | ->name('logout'); 56 | }); 57 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DRIVER', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Filesystem Disks 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure as many filesystem "disks" as you wish, and you 24 | | may even configure multiple disks of the same driver. Defaults have 25 | | been setup for each driver as an example of the required options. 26 | | 27 | | Supported Drivers: "local", "ftp", "sftp", "s3" 28 | | 29 | */ 30 | 31 | 'disks' => [ 32 | 33 | 'local' => [ 34 | 'driver' => 'local', 35 | 'root' => storage_path('app'), 36 | ], 37 | 38 | 'public' => [ 39 | 'driver' => 'local', 40 | 'root' => storage_path('app/public'), 41 | 'url' => env('APP_URL').'/storage', 42 | 'visibility' => 'public', 43 | ], 44 | 45 | 's3' => [ 46 | 'driver' => 's3', 47 | 'key' => env('AWS_ACCESS_KEY_ID'), 48 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 49 | 'region' => env('AWS_DEFAULT_REGION'), 50 | 'bucket' => env('AWS_BUCKET'), 51 | 'url' => env('AWS_URL'), 52 | 'endpoint' => env('AWS_ENDPOINT'), 53 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 54 | ], 55 | 56 | ], 57 | 58 | /* 59 | |-------------------------------------------------------------------------- 60 | | Symbolic Links 61 | |-------------------------------------------------------------------------- 62 | | 63 | | Here you may configure the symbolic links that will be created when the 64 | | `storage:link` Artisan command is executed. The array keys should be 65 | | the locations of the links and the values should be their targets. 66 | | 67 | */ 68 | 69 | 'links' => [ 70 | public_path('storage') => storage_path('app/public'), 71 | ], 72 | 73 | ]; 74 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/NewPasswordController.php: -------------------------------------------------------------------------------- 1 | $request]); 24 | } 25 | 26 | /** 27 | * Handle an incoming new password request. 28 | * 29 | * @param \Illuminate\Http\Request $request 30 | * @return \Illuminate\Http\RedirectResponse 31 | * 32 | * @throws \Illuminate\Validation\ValidationException 33 | */ 34 | public function store(Request $request) 35 | { 36 | $request->validate([ 37 | 'token' => ['required'], 38 | 'email' => ['required', 'email'], 39 | 'password' => ['required', 'confirmed', Rules\Password::defaults()], 40 | ]); 41 | 42 | // Here we will attempt to reset the user's password. If it is successful we 43 | // will update the password on an actual user model and persist it to the 44 | // database. Otherwise we will parse the error and return the response. 45 | $status = Password::reset( 46 | $request->only('email', 'password', 'password_confirmation', 'token'), 47 | function ($user) use ($request) { 48 | $user->forceFill([ 49 | 'password' => Hash::make($request->password), 50 | 'remember_token' => Str::random(60), 51 | ])->save(); 52 | 53 | event(new PasswordReset($user)); 54 | } 55 | ); 56 | 57 | // If the password was successfully reset, we will redirect the user back to 58 | // the application's home authenticated view. If there is an error we can 59 | // redirect them back to where they came from with their error message. 60 | return $status == Password::PASSWORD_RESET 61 | ? redirect()->route('login')->with('status', __($status)) 62 | : back()->withInput($request->only('email')) 63 | ->withErrors(['email' => __($status)]); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/Http/Requests/Auth/LoginRequest.php: -------------------------------------------------------------------------------- 1 | ['required', 'string', 'email'], 33 | 'password' => ['required', 'string'], 34 | ]; 35 | } 36 | 37 | /** 38 | * Attempt to authenticate the request's credentials. 39 | * 40 | * @return void 41 | * 42 | * @throws \Illuminate\Validation\ValidationException 43 | */ 44 | public function authenticate() 45 | { 46 | $this->ensureIsNotRateLimited(); 47 | 48 | if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) { 49 | RateLimiter::hit($this->throttleKey()); 50 | 51 | throw ValidationException::withMessages([ 52 | 'email' => trans('auth.failed'), 53 | ]); 54 | } 55 | 56 | RateLimiter::clear($this->throttleKey()); 57 | } 58 | 59 | /** 60 | * Ensure the login request is not rate limited. 61 | * 62 | * @return void 63 | * 64 | * @throws \Illuminate\Validation\ValidationException 65 | */ 66 | public function ensureIsNotRateLimited() 67 | { 68 | if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { 69 | return; 70 | } 71 | 72 | event(new Lockout($this)); 73 | 74 | $seconds = RateLimiter::availableIn($this->throttleKey()); 75 | 76 | throw ValidationException::withMessages([ 77 | 'email' => trans('auth.throttle', [ 78 | 'seconds' => $seconds, 79 | 'minutes' => ceil($seconds / 60), 80 | ]), 81 | ]); 82 | } 83 | 84 | /** 85 | * Get the rate limiting throttle key for the request. 86 | * 87 | * @return string 88 | */ 89 | public function throttleKey() 90 | { 91 | return Str::lower($this->input('email')).'|'.$this->ip(); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | protected $middleware = [ 17 | // \App\Http\Middleware\TrustHosts::class, 18 | \App\Http\Middleware\TrustProxies::class, 19 | \Fruitcake\Cors\HandleCors::class, 20 | \App\Http\Middleware\PreventRequestsDuringMaintenance::class, 21 | \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, 22 | \App\Http\Middleware\TrimStrings::class, 23 | \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, 24 | ]; 25 | 26 | /** 27 | * The application's route middleware groups. 28 | * 29 | * @var array> 30 | */ 31 | protected $middlewareGroups = [ 32 | 'web' => [ 33 | \App\Http\Middleware\EncryptCookies::class, 34 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 35 | \Illuminate\Session\Middleware\StartSession::class, 36 | // \Illuminate\Session\Middleware\AuthenticateSession::class, 37 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 38 | \App\Http\Middleware\VerifyCsrfToken::class, 39 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 40 | \App\Http\Middleware\CartMiddleware::class, 41 | ], 42 | 43 | 'api' => [ 44 | // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, 45 | 'throttle:api', 46 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 47 | ], 48 | ]; 49 | 50 | /** 51 | * The application's route middleware. 52 | * 53 | * These middleware may be assigned to groups or used individually. 54 | * 55 | * @var array 56 | */ 57 | protected $routeMiddleware = [ 58 | 'auth' => \App\Http\Middleware\Authenticate::class, 59 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 60 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 61 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 62 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 63 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 64 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, 65 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 66 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 67 | ]; 68 | } 69 | -------------------------------------------------------------------------------- /resources/views/components/application-logo.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /resources/views/livewire/product-browser.blade.php: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | 14 |
15 | 16 |
17 | @if($category->products->count()) 18 |
19 |
Max price ({{ money($priceRage['max']) }})
20 |
21 | 22 |
23 |
24 | @endif 25 | 26 | @if ($products->count()) 27 | @foreach($filters as $title => $filter) 28 |
29 |
{{ Str::title($title) }}
30 | @foreach($filter as $option => $count) 31 |
32 | 35 | 38 |
39 | @endforeach 40 |
41 | @endforeach 42 | @endif 43 |
44 |
45 |
46 |
47 |
48 | Found {{ $products->count() }} {{ Str::plural('product', $products->count()) }} matching your filters 49 |
50 | 51 |
52 | @foreach($products as $product) 53 | 54 | 55 | 56 |
57 |
{{ $product->title }}
58 |
{{ $product->formattedPrice() }}
59 |
60 |
61 | @endforeach 62 |
63 |
64 |
65 | -------------------------------------------------------------------------------- /resources/views/orders/index.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | Orders 5 |

6 |
7 | 8 |
9 |
10 |
11 | @forelse($orders as $order) 12 |
13 |
14 |
#{{ $order->id }}
15 |
{{ $order->formattedSubtotal() }}
16 |
{{ $order->shippingType->title }}
17 |
{{ $order->created_at->toDayDateTimeString() }}
18 | 19 |
20 | 22 | {{ $order->presenter()->status() }} 23 | 24 |
25 |
26 | 27 | @foreach($order->variations as $variation) 28 |
29 |
30 | 32 |
33 | 34 |
35 |
36 |
{{ $variation->formattedPrice() }}
37 |
{{ $variation->product->title }}
38 |
39 | 40 |
41 |
42 | Quantity: {{ $variation->pivot->quantity }} / 44 |
45 | @foreach($variation->ancestorsAndSelf as $ancestor) 46 | {{ $ancestor->title }} @if(! $loop->last) 47 | / 48 | @endif 49 | @endforeach 50 |
51 |
52 |
53 | @endforeach 54 |
55 | @empty 56 | No orders 57 | @endforelse 58 |
59 |
60 |
61 |
62 | -------------------------------------------------------------------------------- /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 | 'after_commit' => false, 43 | ], 44 | 45 | 'beanstalkd' => [ 46 | 'driver' => 'beanstalkd', 47 | 'host' => 'localhost', 48 | 'queue' => 'default', 49 | 'retry_after' => 90, 50 | 'block_for' => 0, 51 | 'after_commit' => false, 52 | ], 53 | 54 | 'sqs' => [ 55 | 'driver' => 'sqs', 56 | 'key' => env('AWS_ACCESS_KEY_ID'), 57 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 58 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 59 | 'queue' => env('SQS_QUEUE', 'default'), 60 | 'suffix' => env('SQS_SUFFIX'), 61 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 62 | 'after_commit' => false, 63 | ], 64 | 65 | 'redis' => [ 66 | 'driver' => 'redis', 67 | 'connection' => 'default', 68 | 'queue' => env('REDIS_QUEUE', 'default'), 69 | 'retry_after' => 90, 70 | 'block_for' => null, 71 | 'after_commit' => false, 72 | ], 73 | 74 | ], 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | Failed Queue Jobs 79 | |-------------------------------------------------------------------------- 80 | | 81 | | These options configure the behavior of failed queue job logging so you 82 | | can control which database and table are used to store the jobs that 83 | | have failed. You may change them to any database / table you wish. 84 | | 85 | */ 86 | 87 | 'failed' => [ 88 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 89 | 'database' => env('DB_CONNECTION', 'mysql'), 90 | 'table' => 'failed_jobs', 91 | ], 92 | 93 | ]; 94 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | | Supported drivers: "apc", "array", "database", "file", 30 | | "memcached", "redis", "dynamodb", "octane", "null" 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'apc' => [ 37 | 'driver' => 'apc', 38 | ], 39 | 40 | 'array' => [ 41 | 'driver' => 'array', 42 | 'serialize' => false, 43 | ], 44 | 45 | 'database' => [ 46 | 'driver' => 'database', 47 | 'table' => 'cache', 48 | 'connection' => null, 49 | 'lock_connection' => null, 50 | ], 51 | 52 | 'file' => [ 53 | 'driver' => 'file', 54 | 'path' => storage_path('framework/cache/data'), 55 | ], 56 | 57 | 'memcached' => [ 58 | 'driver' => 'memcached', 59 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 60 | 'sasl' => [ 61 | env('MEMCACHED_USERNAME'), 62 | env('MEMCACHED_PASSWORD'), 63 | ], 64 | 'options' => [ 65 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 66 | ], 67 | 'servers' => [ 68 | [ 69 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 70 | 'port' => env('MEMCACHED_PORT', 11211), 71 | 'weight' => 100, 72 | ], 73 | ], 74 | ], 75 | 76 | 'redis' => [ 77 | 'driver' => 'redis', 78 | 'connection' => 'cache', 79 | 'lock_connection' => 'default', 80 | ], 81 | 82 | 'dynamodb' => [ 83 | 'driver' => 'dynamodb', 84 | 'key' => env('AWS_ACCESS_KEY_ID'), 85 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 86 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 87 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 88 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 89 | ], 90 | 91 | 'octane' => [ 92 | 'driver' => 'octane', 93 | ], 94 | 95 | ], 96 | 97 | /* 98 | |-------------------------------------------------------------------------- 99 | | Cache Key Prefix 100 | |-------------------------------------------------------------------------- 101 | | 102 | | When utilizing a RAM based store such as APC or Memcached, there might 103 | | be other applications utilizing the same cache. So, we'll specify a 104 | | value to get prefixed to all our keys so we can avoid collisions. 105 | | 106 | */ 107 | 108 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), 109 | 110 | ]; 111 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | Build Status 5 | Total Downloads 6 | Latest Stable Version 7 | License 8 |

9 | 10 | ## About Laravel 11 | 12 | Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: 13 | 14 | - [Simple, fast routing engine](https://laravel.com/docs/routing). 15 | - [Powerful dependency injection container](https://laravel.com/docs/container). 16 | - Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. 17 | - Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). 18 | - Database agnostic [schema migrations](https://laravel.com/docs/migrations). 19 | - [Robust background job processing](https://laravel.com/docs/queues). 20 | - [Real-time event broadcasting](https://laravel.com/docs/broadcasting). 21 | 22 | Laravel is accessible, powerful, and provides tools required for large, robust applications. 23 | 24 | ## Learning Laravel 25 | 26 | Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. 27 | 28 | If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. 29 | 30 | ## Laravel Sponsors 31 | 32 | We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell). 33 | 34 | ### Premium Partners 35 | 36 | - **[Vehikl](https://vehikl.com/)** 37 | - **[Tighten Co.](https://tighten.co)** 38 | - **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** 39 | - **[64 Robots](https://64robots.com)** 40 | - **[Cubet Techno Labs](https://cubettech.com)** 41 | - **[Cyber-Duck](https://cyber-duck.co.uk)** 42 | - **[Many](https://www.many.co.uk)** 43 | - **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)** 44 | - **[DevSquad](https://devsquad.com)** 45 | - **[Curotec](https://www.curotec.com/services/technologies/laravel/)** 46 | - **[OP.GG](https://op.gg)** 47 | - **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)** 48 | - **[Lendio](https://lendio.com)** 49 | 50 | ## Contributing 51 | 52 | Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). 53 | 54 | ## Code of Conduct 55 | 56 | In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). 57 | 58 | ## Security Vulnerabilities 59 | 60 | If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. 61 | 62 | ## License 63 | 64 | The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). 65 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Deprecations Log Channel 25 | |-------------------------------------------------------------------------- 26 | | 27 | | This option controls the log channel that should be used to log warnings 28 | | regarding deprecated PHP and library features. This allows you to get 29 | | your application ready for upcoming major versions of dependencies. 30 | | 31 | */ 32 | 33 | 'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Log Channels 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may configure the log channels for your application. Out of 41 | | the box, Laravel uses the Monolog PHP logging library. This gives 42 | | you a variety of powerful log handlers / formatters to utilize. 43 | | 44 | | Available Drivers: "single", "daily", "slack", "syslog", 45 | | "errorlog", "monolog", 46 | | "custom", "stack" 47 | | 48 | */ 49 | 50 | 'channels' => [ 51 | 'stack' => [ 52 | 'driver' => 'stack', 53 | 'channels' => ['single'], 54 | 'ignore_exceptions' => false, 55 | ], 56 | 57 | 'single' => [ 58 | 'driver' => 'single', 59 | 'path' => storage_path('logs/laravel.log'), 60 | 'level' => env('LOG_LEVEL', 'debug'), 61 | ], 62 | 63 | 'daily' => [ 64 | 'driver' => 'daily', 65 | 'path' => storage_path('logs/laravel.log'), 66 | 'level' => env('LOG_LEVEL', 'debug'), 67 | 'days' => 14, 68 | ], 69 | 70 | 'slack' => [ 71 | 'driver' => 'slack', 72 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 73 | 'username' => 'Laravel Log', 74 | 'emoji' => ':boom:', 75 | 'level' => env('LOG_LEVEL', 'critical'), 76 | ], 77 | 78 | 'papertrail' => [ 79 | 'driver' => 'monolog', 80 | 'level' => env('LOG_LEVEL', 'debug'), 81 | 'handler' => SyslogUdpHandler::class, 82 | 'handler_with' => [ 83 | 'host' => env('PAPERTRAIL_URL'), 84 | 'port' => env('PAPERTRAIL_PORT'), 85 | ], 86 | ], 87 | 88 | 'stderr' => [ 89 | 'driver' => 'monolog', 90 | 'level' => env('LOG_LEVEL', 'debug'), 91 | 'handler' => StreamHandler::class, 92 | 'formatter' => env('LOG_STDERR_FORMATTER'), 93 | 'with' => [ 94 | 'stream' => 'php://stderr', 95 | ], 96 | ], 97 | 98 | 'syslog' => [ 99 | 'driver' => 'syslog', 100 | 'level' => env('LOG_LEVEL', 'debug'), 101 | ], 102 | 103 | 'errorlog' => [ 104 | 'driver' => 'errorlog', 105 | 'level' => env('LOG_LEVEL', 'debug'), 106 | ], 107 | 108 | 'null' => [ 109 | 'driver' => 'monolog', 110 | 'handler' => NullHandler::class, 111 | ], 112 | 113 | 'emergency' => [ 114 | 'path' => storage_path('logs/laravel.log'), 115 | ], 116 | ], 117 | 118 | ]; 119 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_MAILER', 'smtp'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Mailer Configurations 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure all of the mailers used by your application plus 24 | | their respective settings. Several examples have been configured for 25 | | you and you are free to add your own as your application requires. 26 | | 27 | | Laravel supports a variety of mail "transport" drivers to be used while 28 | | sending an e-mail. You will specify which one you are using for your 29 | | mailers below. You are free to add additional mailers as required. 30 | | 31 | | Supported: "smtp", "sendmail", "mailgun", "ses", 32 | | "postmark", "log", "array", "failover" 33 | | 34 | */ 35 | 36 | 'mailers' => [ 37 | 'smtp' => [ 38 | 'transport' => 'smtp', 39 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 40 | 'port' => env('MAIL_PORT', 587), 41 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 42 | 'username' => env('MAIL_USERNAME'), 43 | 'password' => env('MAIL_PASSWORD'), 44 | 'timeout' => null, 45 | 'auth_mode' => null, 46 | ], 47 | 48 | 'ses' => [ 49 | 'transport' => 'ses', 50 | ], 51 | 52 | 'mailgun' => [ 53 | 'transport' => 'mailgun', 54 | ], 55 | 56 | 'postmark' => [ 57 | 'transport' => 'postmark', 58 | ], 59 | 60 | 'sendmail' => [ 61 | 'transport' => 'sendmail', 62 | 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -t -i'), 63 | ], 64 | 65 | 'log' => [ 66 | 'transport' => 'log', 67 | 'channel' => env('MAIL_LOG_CHANNEL'), 68 | ], 69 | 70 | 'array' => [ 71 | 'transport' => 'array', 72 | ], 73 | 74 | 'failover' => [ 75 | 'transport' => 'failover', 76 | 'mailers' => [ 77 | 'smtp', 78 | 'log', 79 | ], 80 | ], 81 | ], 82 | 83 | /* 84 | |-------------------------------------------------------------------------- 85 | | Global "From" Address 86 | |-------------------------------------------------------------------------- 87 | | 88 | | You may wish for all e-mails sent by your application to be sent from 89 | | the same address. Here, you may specify a name and address that is 90 | | used globally for all e-mails that are sent by your application. 91 | | 92 | */ 93 | 94 | 'from' => [ 95 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 96 | 'name' => env('MAIL_FROM_NAME', 'Example'), 97 | ], 98 | 99 | /* 100 | |-------------------------------------------------------------------------- 101 | | Markdown Mail Settings 102 | |-------------------------------------------------------------------------- 103 | | 104 | | If you are using Markdown based email rendering, you may configure your 105 | | theme and component paths here, allowing you to customize the design 106 | | of the emails. Or, you may simply stick with the Laravel defaults! 107 | | 108 | */ 109 | 110 | 'markdown' => [ 111 | 'theme' => 'default', 112 | 113 | 'paths' => [ 114 | resource_path('views/vendor/mail'), 115 | ], 116 | ], 117 | 118 | ]; 119 | -------------------------------------------------------------------------------- /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" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | ], 44 | 45 | /* 46 | |-------------------------------------------------------------------------- 47 | | User Providers 48 | |-------------------------------------------------------------------------- 49 | | 50 | | All authentication drivers have a user provider. This defines how the 51 | | users are actually retrieved out of your database or other storage 52 | | mechanisms used by this application to persist your user's data. 53 | | 54 | | If you have multiple user tables or models you may configure multiple 55 | | sources which represent each model / table. These sources may then 56 | | be assigned to any extra authentication guards you have defined. 57 | | 58 | | Supported: "database", "eloquent" 59 | | 60 | */ 61 | 62 | 'providers' => [ 63 | 'users' => [ 64 | 'driver' => 'eloquent', 65 | 'model' => App\Models\User::class, 66 | ], 67 | 68 | // 'users' => [ 69 | // 'driver' => 'database', 70 | // 'table' => 'users', 71 | // ], 72 | ], 73 | 74 | /* 75 | |-------------------------------------------------------------------------- 76 | | Resetting Passwords 77 | |-------------------------------------------------------------------------- 78 | | 79 | | You may specify multiple password reset configurations if you have more 80 | | than one user table or model in the application and you want to have 81 | | separate password reset settings based on the specific user types. 82 | | 83 | | The expire time is the number of minutes that each reset token will be 84 | | considered valid. This security feature keeps tokens short-lived so 85 | | they have less time to be guessed. You may change this as needed. 86 | | 87 | */ 88 | 89 | 'passwords' => [ 90 | 'users' => [ 91 | 'provider' => 'users', 92 | 'table' => 'password_resets', 93 | 'expire' => 60, 94 | 'throttle' => 60, 95 | ], 96 | ], 97 | 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Password Confirmation Timeout 101 | |-------------------------------------------------------------------------- 102 | | 103 | | Here you may define the amount of seconds before a password confirmation 104 | | times out and the user is prompted to re-enter their password via the 105 | | confirmation screen. By default, the timeout lasts for three hours. 106 | | 107 | */ 108 | 109 | 'password_timeout' => 10800, 110 | 111 | ]; 112 | -------------------------------------------------------------------------------- /config/scout.php: -------------------------------------------------------------------------------- 1 | env('SCOUT_DRIVER', 'algolia'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Index Prefix 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify a prefix that will be applied to all search index 26 | | names used by Scout. This prefix may be useful if you have multiple 27 | | "tenants" or applications sharing the same search infrastructure. 28 | | 29 | */ 30 | 31 | 'prefix' => env('SCOUT_PREFIX', ''), 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Queue Data Syncing 36 | |-------------------------------------------------------------------------- 37 | | 38 | | This option allows you to control if the operations that sync your data 39 | | with your search engines are queued. When this is set to "true" then 40 | | all automatic data syncing will get queued for better performance. 41 | | 42 | */ 43 | 44 | 'queue' => env('SCOUT_QUEUE', false), 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Database Transactions 49 | |-------------------------------------------------------------------------- 50 | | 51 | | This configuration option determines if your data will only be synced 52 | | with your search indexes after every open database transaction has 53 | | been committed, thus preventing any discarded data from syncing. 54 | | 55 | */ 56 | 57 | 'after_commit' => false, 58 | 59 | /* 60 | |-------------------------------------------------------------------------- 61 | | Chunk Sizes 62 | |-------------------------------------------------------------------------- 63 | | 64 | | These options allow you to control the maximum chunk size when you are 65 | | mass importing data into the search engine. This allows you to fine 66 | | tune each of these chunk sizes based on the power of the servers. 67 | | 68 | */ 69 | 70 | 'chunk' => [ 71 | 'searchable' => 500, 72 | 'unsearchable' => 500, 73 | ], 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Soft Deletes 78 | |-------------------------------------------------------------------------- 79 | | 80 | | This option allows to control whether to keep soft deleted records in 81 | | the search indexes. Maintaining soft deleted records can be useful 82 | | if your application still needs to search for the records later. 83 | | 84 | */ 85 | 86 | 'soft_delete' => false, 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Identify User 91 | |-------------------------------------------------------------------------- 92 | | 93 | | This option allows you to control whether to notify the search engine 94 | | of the user performing the search. This is sometimes useful if the 95 | | engine supports any analytics based on this application's users. 96 | | 97 | | Supported engines: "algolia" 98 | | 99 | */ 100 | 101 | 'identify' => env('SCOUT_IDENTIFY', false), 102 | 103 | /* 104 | |-------------------------------------------------------------------------- 105 | | Algolia Configuration 106 | |-------------------------------------------------------------------------- 107 | | 108 | | Here you may configure your Algolia settings. Algolia is a cloud hosted 109 | | search engine which works great with Scout out of the box. Just plug 110 | | in your application ID and admin API key to get started searching. 111 | | 112 | */ 113 | 114 | 'algolia' => [ 115 | 'id' => env('ALGOLIA_APP_ID', ''), 116 | 'secret' => env('ALGOLIA_SECRET', ''), 117 | ], 118 | 119 | /* 120 | |-------------------------------------------------------------------------- 121 | | MeiliSearch Configuration 122 | |-------------------------------------------------------------------------- 123 | | 124 | | Here you may configure your MeiliSearch settings. MeiliSearch is an open 125 | | source search engine with minimal configuration. Below, you can state 126 | | the host and key information for your own MeiliSearch installation. 127 | | 128 | | See: https://docs.meilisearch.com/guides/advanced_guides/configuration.html 129 | | 130 | */ 131 | 132 | 'meilisearch' => [ 133 | 'host' => env('MEILISEARCH_HOST', 'http://localhost:7700'), 134 | 'key' => env('MEILISEARCH_KEY', null), 135 | ], 136 | 137 | ]; 138 | -------------------------------------------------------------------------------- /app/Cart/Cart.php: -------------------------------------------------------------------------------- 1 | session = $session; 20 | } 21 | 22 | public function exists() 23 | { 24 | return $this->session->has(config('cart.session.key')) && $this->instance(); 25 | } 26 | 27 | public function destroy() 28 | { 29 | $this->session->forget(config('cart.session.key')); 30 | } 31 | 32 | public function associate(User $user) 33 | { 34 | $this->instance->user()->associate($user); 35 | 36 | $this->instance->save(); 37 | } 38 | 39 | public function create(?User $user = null) 40 | { 41 | $instance = ModelsCart::make(); 42 | 43 | if ($user) { 44 | $instance->user()->associate($user); 45 | } 46 | 47 | $instance->save(); 48 | 49 | $this->session->put(config('cart.session.key'), $instance->uuid); 50 | } 51 | 52 | public function contents() 53 | { 54 | return $this->instance()->variations; 55 | } 56 | 57 | public function contentsCount() 58 | { 59 | return $this->contents()->count(); 60 | } 61 | 62 | public function getVariation(Variation $variation) 63 | { 64 | return $this->instance()->variations->find($variation->id); 65 | } 66 | 67 | protected function clearInstanceCache() 68 | { 69 | $this->instance = null; 70 | } 71 | 72 | protected function instance() 73 | { 74 | if ($this->instance) { 75 | return $this->instance; 76 | } 77 | 78 | return ModelsCart::query() 79 | ->with( 80 | 'variations.product', 81 | 'variations.ancestorsAndSelf', 82 | 'variations.descendantsAndSelf.stocks', 83 | 'variations.media' 84 | ) 85 | ->whereUuid($this->session->get(config('cart.session.key'))) 86 | ->first(); 87 | } 88 | 89 | public function add(Variation $variation, $quantity = 1) 90 | { 91 | if ($existingVariation = $this->getVariation($variation)) { 92 | $quantity += $existingVariation->pivot->quantity; 93 | } 94 | 95 | $this->instance()->variations()->syncWithoutDetaching([ 96 | $variation->id => [ 97 | 'quantity' => min($quantity, $variation->stockCount()) 98 | ] 99 | ]); 100 | } 101 | 102 | public function changeQuantity(Variation $variation, $quantity) 103 | { 104 | $this->instance()->variations()->updateExistingPivot($variation->id, [ 105 | 'quantity' => min($quantity, $variation->stockCount()) 106 | ]); 107 | } 108 | 109 | public function remove(Variation $variation) 110 | { 111 | $this->instance()->variations()->detach($variation); 112 | } 113 | 114 | public function isEmpty() 115 | { 116 | return $this->contentsCount() === 0; 117 | } 118 | 119 | public function verifyAvailableQuantities() 120 | { 121 | $this->instance()->variations->each(function ($variation) { 122 | if ($variation->pivot->quantity > $variation->stocks->sum('amount')) { 123 | throw new QuantityNoLongerAvailableException('Stock reduced'); 124 | } 125 | }); 126 | } 127 | 128 | public function syncAvailableQuantities() 129 | { 130 | $syncedQuantities = $this->instance()->variations->mapWithKeys(function ($variation) { 131 | $quantity = $variation->pivot->quantity > $variation->stocks->sum('count') 132 | ? $variation->stockCount() 133 | : $variation->pivot->quantity; 134 | 135 | return [ 136 | $variation->id => [ 137 | 'quantity' => $quantity 138 | ] 139 | ]; 140 | })->reject(function ($syncedQuantity) { 141 | return $syncedQuantity['quantity'] < 1; 142 | })->toArray(); 143 | 144 | $this->instance()->variations()->sync($syncedQuantities); 145 | 146 | $this->clearInstanceCache(); 147 | } 148 | 149 | public function removeAll() 150 | { 151 | $this->instance()->variations()->detach(); 152 | } 153 | 154 | public function subtotal() 155 | { 156 | return $this->instance()->variations 157 | ->reduce(function ($carry, $variation) { 158 | return $carry + ($variation->price * $variation->pivot->quantity); 159 | }); 160 | } 161 | 162 | public function formattedSubtotal() 163 | { 164 | return money($this->subtotal()); 165 | } 166 | 167 | public function hasPaymentIntent() 168 | { 169 | return ! is_null($this->getPaymentIntentId()); 170 | } 171 | 172 | public function getPaymentIntentId() 173 | { 174 | return $this->instance()->payment_intent_id; 175 | } 176 | 177 | public function updatePaymentIntentId($paymentIntentId) 178 | { 179 | $this->instance()->update([ 180 | 'payment_intent_id' => $paymentIntentId 181 | ]); 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'mysql'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Database Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here are each of the database connections setup for your application. 26 | | Of course, examples of configuring each database platform that is 27 | | supported by Laravel is shown below to make development simple. 28 | | 29 | | 30 | | All database work in Laravel is done through the PHP PDO facilities 31 | | so make sure you have the driver for your particular database of 32 | | choice installed on your machine before you begin development. 33 | | 34 | */ 35 | 36 | 'connections' => [ 37 | 38 | 'sqlite' => [ 39 | 'driver' => 'sqlite', 40 | 'url' => env('DATABASE_URL'), 41 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 42 | 'prefix' => '', 43 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 44 | ], 45 | 46 | 'mysql' => [ 47 | 'driver' => 'mysql', 48 | 'url' => env('DATABASE_URL'), 49 | 'host' => env('DB_HOST', '127.0.0.1'), 50 | 'port' => env('DB_PORT', '3306'), 51 | 'database' => env('DB_DATABASE', 'forge'), 52 | 'username' => env('DB_USERNAME', 'forge'), 53 | 'password' => env('DB_PASSWORD', ''), 54 | 'unix_socket' => env('DB_SOCKET', ''), 55 | 'charset' => 'utf8mb4', 56 | 'collation' => 'utf8mb4_unicode_ci', 57 | 'prefix' => '', 58 | 'prefix_indexes' => true, 59 | 'strict' => true, 60 | 'engine' => null, 61 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 62 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 63 | ]) : [], 64 | ], 65 | 66 | 'pgsql' => [ 67 | 'driver' => 'pgsql', 68 | 'url' => env('DATABASE_URL'), 69 | 'host' => env('DB_HOST', '127.0.0.1'), 70 | 'port' => env('DB_PORT', '5432'), 71 | 'database' => env('DB_DATABASE', 'forge'), 72 | 'username' => env('DB_USERNAME', 'forge'), 73 | 'password' => env('DB_PASSWORD', ''), 74 | 'charset' => 'utf8', 75 | 'prefix' => '', 76 | 'prefix_indexes' => true, 77 | 'schema' => 'public', 78 | 'sslmode' => 'prefer', 79 | ], 80 | 81 | 'sqlsrv' => [ 82 | 'driver' => 'sqlsrv', 83 | 'url' => env('DATABASE_URL'), 84 | 'host' => env('DB_HOST', 'localhost'), 85 | 'port' => env('DB_PORT', '1433'), 86 | 'database' => env('DB_DATABASE', 'forge'), 87 | 'username' => env('DB_USERNAME', 'forge'), 88 | 'password' => env('DB_PASSWORD', ''), 89 | 'charset' => 'utf8', 90 | 'prefix' => '', 91 | 'prefix_indexes' => true, 92 | ], 93 | 94 | ], 95 | 96 | /* 97 | |-------------------------------------------------------------------------- 98 | | Migration Repository Table 99 | |-------------------------------------------------------------------------- 100 | | 101 | | This table keeps track of all the migrations that have already run for 102 | | your application. Using this information, we can determine which of 103 | | the migrations on disk haven't actually been run in the database. 104 | | 105 | */ 106 | 107 | 'migrations' => 'migrations', 108 | 109 | /* 110 | |-------------------------------------------------------------------------- 111 | | Redis Databases 112 | |-------------------------------------------------------------------------- 113 | | 114 | | Redis is an open source, fast, and advanced key-value store that also 115 | | provides a richer body of commands than a typical key-value system 116 | | such as APC or Memcached. Laravel makes it easy to dig right in. 117 | | 118 | */ 119 | 120 | 'redis' => [ 121 | 122 | 'client' => env('REDIS_CLIENT', 'phpredis'), 123 | 124 | 'options' => [ 125 | 'cluster' => env('REDIS_CLUSTER', 'redis'), 126 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), 127 | ], 128 | 129 | 'default' => [ 130 | 'url' => env('REDIS_URL'), 131 | 'host' => env('REDIS_HOST', '127.0.0.1'), 132 | 'password' => env('REDIS_PASSWORD', null), 133 | 'port' => env('REDIS_PORT', '6379'), 134 | 'database' => env('REDIS_DB', '0'), 135 | ], 136 | 137 | 'cache' => [ 138 | 'url' => env('REDIS_URL'), 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 | --------------------------------------------------------------------------------