├── database ├── .gitignore ├── factories │ ├── CategoryFactory.php │ ├── CountryFactory.php │ ├── UserFactory.php │ ├── BookFactory.php │ └── AddressFactory.php ├── migrations │ ├── 2023_09_10_200332_create_categories_table.php │ ├── 2023_09_09_082617_create_countries_table.php │ ├── 2014_10_12_100000_create_password_reset_tokens_table.php │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ ├── 2023_09_10_201516_create_category_book_table.php │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2023_09_24_191038_create_order_items_table.php │ ├── 2019_12_14_000001_create_personal_access_tokens_table.php │ ├── 2023_09_18_231834_create_carts_table.php │ ├── 2023_09_25_025347_create_payments_table.php │ ├── 2023_09_08_155432_create_addresses_table.php │ ├── 2023_09_10_170424_create_books_table.php │ └── 2023_09_24_182030_create_orders_table.php └── seeders │ ├── CategoryBookSeeder.php │ ├── CategorySeeder.php │ └── DatabaseSeeder.php ├── resources ├── js │ ├── Components │ │ ├── OrderCard.jsx │ │ ├── InputError.jsx │ │ ├── DarkModeToggle.jsx │ │ ├── ShareLink.jsx │ │ ├── AddToCart.jsx │ │ ├── CartToggle.jsx │ │ ├── ProfileBreadcrumb.jsx │ │ ├── BookDescription.jsx │ │ ├── CartItem.jsx │ │ ├── Pagination.jsx │ │ ├── Address.jsx │ │ ├── QuantityInput.jsx │ │ ├── BookCard.jsx │ │ ├── RelatedBooks.jsx │ │ ├── Modal.jsx │ │ ├── CartTotal.jsx │ │ ├── RandomBooks.jsx │ │ ├── UserDropdown.jsx │ │ ├── BookBanner.jsx │ │ ├── SearchBar.jsx │ │ ├── CartDrawer.jsx │ │ └── Order.jsx │ ├── Hooks │ │ ├── useCartDrawer.jsx │ │ ├── useColorMode.jsx │ │ └── useLocalStorage.jsx │ ├── Pages │ │ ├── Book │ │ │ ├── Partials │ │ │ │ ├── searchBarTheme.jsx │ │ │ │ ├── SortBy.jsx │ │ │ │ ├── ClearFilter.jsx │ │ │ │ ├── TypeFilter.jsx │ │ │ │ ├── AuthorFilter.jsx │ │ │ │ ├── CategoryFilter.jsx │ │ │ │ └── PublisherFilter.jsx │ │ │ └── Breadcrumb │ │ │ │ ├── IndexBreadcrumb.jsx │ │ │ │ └── ShowBreadcrumb.jsx │ │ ├── Address │ │ │ ├── Partials │ │ │ │ ├── AddressDefault.jsx │ │ │ │ └── AddressDelete.jsx │ │ │ └── Index.jsx │ │ ├── Cart │ │ │ ├── Partials │ │ │ │ ├── CartTable.jsx │ │ │ │ └── CartTableRow.jsx │ │ │ └── Breadcrumb │ │ │ │ └── IndexBreadcrumb.jsx │ │ ├── Checkout │ │ │ ├── Breadcrumb │ │ │ │ └── IndexBreadcrumb.jsx │ │ │ └── Partials │ │ │ │ ├── CheckoutItem.jsx │ │ │ │ └── CheckoutTotal.jsx │ │ ├── Profile │ │ │ └── Edit.jsx │ │ ├── Order │ │ │ └── Index.jsx │ │ ├── Payment │ │ │ └── Index.jsx │ │ └── Auth │ │ │ └── ForgotPassword.jsx │ ├── app.jsx │ ├── Layouts │ │ ├── FilterLayout.jsx │ │ ├── MainLayout.jsx │ │ ├── ProfileLayout.jsx │ │ └── ScrollAreaLayout.jsx │ └── bootstrap.js ├── css │ └── app.css └── views │ └── app.blade.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 ├── public ├── robots.txt ├── favicon.ico ├── book-cloud.png ├── book-earth.png ├── book-glass.png ├── book-stack.png ├── book-store.png ├── book-background.jpg ├── book-banner-1.png ├── book-banner-2.png ├── book-images │ ├── 1.webp │ ├── 10.webp │ ├── 11.webp │ ├── 12.webp │ ├── 13.webp │ ├── 14.webp │ ├── 15.webp │ ├── 16.webp │ ├── 17.webp │ ├── 18.webp │ ├── 19.webp │ ├── 2.webp │ ├── 20.webp │ ├── 21.webp │ ├── 22.webp │ ├── 23.webp │ ├── 24.webp │ ├── 3.webp │ ├── 4.webp │ ├── 5.webp │ ├── 6.webp │ ├── 7.webp │ ├── 8.webp │ └── 9.webp ├── favicon-16x16.png ├── favicon-32x32.png ├── social-preview.png ├── apple-touch-icon.png ├── landing-banner-1.png ├── landing-banner-2.png ├── landing-banner-3.png ├── android-chrome-192x192.png ├── android-chrome-512x512.png ├── site.webmanifest ├── .htaccess ├── avatar.svg └── index.php ├── screenshots ├── screenshot-1.png ├── screenshot-2.png ├── screenshot-3.png ├── screenshot-4.png ├── screenshot-5.png ├── screenshot-6.png ├── screenshot-7.png ├── screenshot-8.png ├── screenshot-9.png ├── screenshot-10.png ├── screenshot-11.png ├── screenshot-12.png └── screenshot-13.png ├── postcss.config.js ├── jsconfig.json ├── tests ├── TestCase.php ├── Unit │ └── ExampleTest.php ├── Feature │ └── ExampleTest.php └── CreatesApplication.php ├── .gitattributes ├── app ├── Models │ ├── Country.php │ ├── Category.php │ ├── Payment.php │ ├── OrderItem.php │ ├── Address.php │ ├── Cart.php │ ├── Order.php │ └── User.php ├── Http │ ├── Controllers │ │ ├── Controller.php │ │ ├── IndexController.php │ │ ├── CheckoutController.php │ │ ├── AddressDefaultController.php │ │ ├── Auth │ │ │ ├── PasswordController.php │ │ │ ├── PasswordResetLinkController.php │ │ │ ├── RegisteredUserController.php │ │ │ ├── AuthenticatedSessionController.php │ │ │ └── NewPasswordController.php │ │ ├── BookController.php │ │ ├── PaymentController.php │ │ └── ProfileController.php │ ├── Middleware │ │ ├── EncryptCookies.php │ │ ├── VerifyCsrfToken.php │ │ ├── PreventRequestsDuringMaintenance.php │ │ ├── TrimStrings.php │ │ ├── TrustHosts.php │ │ ├── Authenticate.php │ │ ├── ValidateSignature.php │ │ ├── TrustProxies.php │ │ ├── RedirectIfAuthenticated.php │ │ └── HandleInertiaRequests.php │ ├── Requests │ │ ├── ProfileUpdateRequest.php │ │ └── Auth │ │ │ └── LoginRequest.php │ └── Kernel.php ├── Providers │ ├── BroadcastServiceProvider.php │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── EventServiceProvider.php │ └── RouteServiceProvider.php ├── Console │ └── Kernel.php ├── Exceptions │ └── Handler.php └── Policies │ └── AddressPolicy.php ├── .gitignore ├── .editorconfig ├── vite.config.js ├── routes ├── channels.php ├── api.php ├── console.php ├── auth.php └── web.php ├── tailwind.config.js ├── package.json ├── config ├── cors.php ├── services.php ├── view.php ├── hashing.php ├── broadcasting.php ├── sanctum.php └── filesystems.php ├── phpunit.xml ├── .env.example ├── artisan ├── composer.json └── README.md /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /resources/js/Components/OrderCard.jsx: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /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/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/favicon.ico -------------------------------------------------------------------------------- /public/book-cloud.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-cloud.png -------------------------------------------------------------------------------- /public/book-earth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-earth.png -------------------------------------------------------------------------------- /public/book-glass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-glass.png -------------------------------------------------------------------------------- /public/book-stack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-stack.png -------------------------------------------------------------------------------- /public/book-store.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-store.png -------------------------------------------------------------------------------- /public/book-background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-background.jpg -------------------------------------------------------------------------------- /public/book-banner-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-banner-1.png -------------------------------------------------------------------------------- /public/book-banner-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-banner-2.png -------------------------------------------------------------------------------- /public/book-images/1.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/1.webp -------------------------------------------------------------------------------- /public/book-images/10.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/10.webp -------------------------------------------------------------------------------- /public/book-images/11.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/11.webp -------------------------------------------------------------------------------- /public/book-images/12.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/12.webp -------------------------------------------------------------------------------- /public/book-images/13.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/13.webp -------------------------------------------------------------------------------- /public/book-images/14.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/14.webp -------------------------------------------------------------------------------- /public/book-images/15.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/15.webp -------------------------------------------------------------------------------- /public/book-images/16.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/16.webp -------------------------------------------------------------------------------- /public/book-images/17.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/17.webp -------------------------------------------------------------------------------- /public/book-images/18.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/18.webp -------------------------------------------------------------------------------- /public/book-images/19.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/19.webp -------------------------------------------------------------------------------- /public/book-images/2.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/2.webp -------------------------------------------------------------------------------- /public/book-images/20.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/20.webp -------------------------------------------------------------------------------- /public/book-images/21.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/21.webp -------------------------------------------------------------------------------- /public/book-images/22.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/22.webp -------------------------------------------------------------------------------- /public/book-images/23.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/23.webp -------------------------------------------------------------------------------- /public/book-images/24.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/24.webp -------------------------------------------------------------------------------- /public/book-images/3.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/3.webp -------------------------------------------------------------------------------- /public/book-images/4.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/4.webp -------------------------------------------------------------------------------- /public/book-images/5.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/5.webp -------------------------------------------------------------------------------- /public/book-images/6.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/6.webp -------------------------------------------------------------------------------- /public/book-images/7.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/7.webp -------------------------------------------------------------------------------- /public/book-images/8.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/8.webp -------------------------------------------------------------------------------- /public/book-images/9.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/book-images/9.webp -------------------------------------------------------------------------------- /public/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/favicon-16x16.png -------------------------------------------------------------------------------- /public/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/favicon-32x32.png -------------------------------------------------------------------------------- /public/social-preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/social-preview.png -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/apple-touch-icon.png -------------------------------------------------------------------------------- /public/landing-banner-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/landing-banner-1.png -------------------------------------------------------------------------------- /public/landing-banner-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/landing-banner-2.png -------------------------------------------------------------------------------- /public/landing-banner-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/landing-banner-3.png -------------------------------------------------------------------------------- /screenshots/screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/screenshots/screenshot-1.png -------------------------------------------------------------------------------- /screenshots/screenshot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/screenshots/screenshot-2.png -------------------------------------------------------------------------------- /screenshots/screenshot-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/screenshots/screenshot-3.png -------------------------------------------------------------------------------- /screenshots/screenshot-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/screenshots/screenshot-4.png -------------------------------------------------------------------------------- /screenshots/screenshot-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/screenshots/screenshot-5.png -------------------------------------------------------------------------------- /screenshots/screenshot-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/screenshots/screenshot-6.png -------------------------------------------------------------------------------- /screenshots/screenshot-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/screenshots/screenshot-7.png -------------------------------------------------------------------------------- /screenshots/screenshot-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/screenshots/screenshot-8.png -------------------------------------------------------------------------------- /screenshots/screenshot-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/screenshots/screenshot-9.png -------------------------------------------------------------------------------- /screenshots/screenshot-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/screenshots/screenshot-10.png -------------------------------------------------------------------------------- /screenshots/screenshot-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/screenshots/screenshot-11.png -------------------------------------------------------------------------------- /screenshots/screenshot-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/screenshots/screenshot-12.png -------------------------------------------------------------------------------- /screenshots/screenshot-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/screenshots/screenshot-13.png -------------------------------------------------------------------------------- /public/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/android-chrome-192x192.png -------------------------------------------------------------------------------- /public/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salimi-my/book-store/main/public/android-chrome-512x512.png -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | compiled.php 2 | config.php 3 | down 4 | events.scanned.php 5 | maintenance.php 6 | routes.php 7 | routes.scanned.php 8 | schedule-* 9 | services.json 10 | -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "paths": { 5 | "@/*": ["resources/js/*"] 6 | } 7 | }, 8 | "exclude": ["node_modules", "public"] 9 | } 10 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | 4 | {message} 5 |

6 | ) : null; 7 | } 8 | -------------------------------------------------------------------------------- /app/Models/Country.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 2 7 | indent_style = space 8 | insert_final_newline = true 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 = 2 19 | -------------------------------------------------------------------------------- /vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import laravel from 'laravel-vite-plugin'; 3 | import react from '@vitejs/plugin-react'; 4 | 5 | export default defineConfig({ 6 | plugins: [ 7 | laravel({ 8 | input: 'resources/js/app.jsx', 9 | refresh: true, 10 | }), 11 | react(), 12 | ], 13 | }); 14 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | Book::inRandomOrder()->limit(10)->get() 14 | ]); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /resources/js/Hooks/useCartDrawer.jsx: -------------------------------------------------------------------------------- 1 | import { create } from "zustand"; 2 | 3 | export const useCartDrawer = create((set) => ({ 4 | isOpen: false, 5 | onOpen: () => { 6 | document.body.classList.add("overflow-hidden"); 7 | set({ isOpen: true }); 8 | }, 9 | onClose: () => { 10 | document.body.classList.remove("overflow-hidden"); 11 | set({ isOpen: false }); 12 | }, 13 | })); 14 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | 'payment-callback' 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 16 | 17 | $response->assertStatus(200); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | 'current_password', 16 | 'password', 17 | 'password_confirmation', 18 | ]; 19 | } 20 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 18 | 19 | return $app; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustHosts.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function hosts(): array 15 | { 16 | return [ 17 | $this->allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Models/Category.php: -------------------------------------------------------------------------------- 1 | belongsToMany(Book::class, 'category_book'); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | expectsJson() ? null : route('login'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /resources/js/Hooks/useColorMode.jsx: -------------------------------------------------------------------------------- 1 | import { useEffect } from "react"; 2 | import useLocalStorage from "@/Hooks/useLocalStorage"; 3 | 4 | export default function useColorMode() { 5 | const [colorMode, setColorMode] = useLocalStorage("color-theme", "light"); 6 | 7 | useEffect(() => { 8 | const className = "dark"; 9 | const bodyClass = window.document.body.classList; 10 | 11 | colorMode === "dark" 12 | ? bodyClass.add(className) 13 | : bodyClass.remove(className); 14 | }, [colorMode]); 15 | 16 | return [colorMode, setColorMode]; 17 | } 18 | -------------------------------------------------------------------------------- /database/factories/CategoryFactory.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class CategoryFactory extends Factory 11 | { 12 | /** 13 | * Define the model's default state. 14 | * 15 | * @return array 16 | */ 17 | public function definition(): array 18 | { 19 | return [ 20 | 'name' => fake()->word() 21 | ]; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/Http/Controllers/CheckoutController.php: -------------------------------------------------------------------------------- 1 | Auth::user()->addresses()->orderBy('default', 'asc')->get(), 18 | 'countries' => Country::all() 19 | ]); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Middleware/ValidateSignature.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 'fbclid', 16 | // 'utm_campaign', 17 | // 'utm_content', 18 | // 'utm_medium', 19 | // 'utm_source', 20 | // 'utm_term', 21 | ]; 22 | } 23 | -------------------------------------------------------------------------------- /app/Models/Payment.php: -------------------------------------------------------------------------------- 1 | belongsTo(Order::class, 'order_id'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /resources/js/Pages/Book/Partials/searchBarTheme.jsx: -------------------------------------------------------------------------------- 1 | const searchFilterTheme = { 2 | textInput: { 3 | field: { 4 | base: "relative w-full p-0 mb-2", 5 | icon: { 6 | base: "pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3", 7 | svg: "h-4 w-4 text-gray-500 dark:text-gray-400", 8 | }, 9 | input: { 10 | base: "block w-full border disabled:cursor-not-allowed disabled:opacity-50 !p-1 !pl-8", 11 | withAddon: { 12 | off: "rounded-full", 13 | }, 14 | }, 15 | }, 16 | }, 17 | }; 18 | 19 | export default searchFilterTheme; 20 | -------------------------------------------------------------------------------- /database/factories/CountryFactory.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class CountryFactory extends Factory 11 | { 12 | /** 13 | * Define the model's default state. 14 | * 15 | * @return array 16 | */ 17 | public function definition(): array 18 | { 19 | return [ 20 | 'name' => fake()->country(), 21 | 'code' => fake()->countryCode() 22 | ]; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /resources/js/app.jsx: -------------------------------------------------------------------------------- 1 | import "./bootstrap"; 2 | import "../css/app.css"; 3 | 4 | import { createRoot } from "react-dom/client"; 5 | import { createInertiaApp } from "@inertiajs/react"; 6 | import { resolvePageComponent } from "laravel-vite-plugin/inertia-helpers"; 7 | 8 | createInertiaApp({ 9 | resolve: (name) => 10 | resolvePageComponent( 11 | `./Pages/${name}.jsx`, 12 | import.meta.glob("./Pages/**/*.jsx") 13 | ), 14 | setup({ el, App, props }) { 15 | const root = createRoot(el); 16 | 17 | root.render(); 18 | }, 19 | progress: { 20 | color: "#22d3ee", 21 | }, 22 | }); 23 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 18 | }); 19 | -------------------------------------------------------------------------------- /resources/css/app.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | .swiper-button-prev, 6 | .swiper-button-next { 7 | color: rgb(8, 145, 178) !important; 8 | } 9 | 10 | .dark .swiper-button-prev, 11 | .dark .swiper-button-next { 12 | color: rgb(6, 182, 212) !important; 13 | } 14 | 15 | .dark .swiper-pagination-bullet { 16 | background: white; 17 | } 18 | 19 | .swiper-pagination-bullet.swiper-pagination-bullet-active { 20 | background: rgb(6, 182, 212); 21 | } 22 | 23 | .quantity-input::-webkit-inner-spin-button, 24 | .quantity-input::-webkit-outer-spin-button { 25 | -webkit-appearance: none; 26 | margin: 0; 27 | } 28 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 18 | return $request->user(); 19 | }); 20 | -------------------------------------------------------------------------------- /app/Models/OrderItem.php: -------------------------------------------------------------------------------- 1 | belongsTo(Order::class, 'order_id'); 21 | } 22 | 23 | public function book(): BelongsTo 24 | { 25 | return $this->belongsTo(Book::class, 'book_id'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $policies = [ 16 | // 17 | ]; 18 | 19 | /** 20 | * Register any authentication / authorization services. 21 | */ 22 | public function boot(): void 23 | { 24 | // 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /resources/js/Pages/Address/Partials/AddressDefault.jsx: -------------------------------------------------------------------------------- 1 | import { RefreshCw } from "lucide-react"; 2 | import { router } from "@inertiajs/react"; 3 | import { Button, Tooltip } from "flowbite-react"; 4 | 5 | export default function AddressDefault({ address }) { 6 | return ( 7 | 8 | 17 | 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 19 | })->purpose('Display an inspiring quote'); 20 | -------------------------------------------------------------------------------- /resources/js/Layouts/FilterLayout.jsx: -------------------------------------------------------------------------------- 1 | import { Accordion } from "flowbite-react"; 2 | 3 | export default function FilterLayout({ title, children }) { 4 | return ( 5 | 6 | 7 | 8 | {title} 9 | 10 | 11 | {children} 12 |
13 |
14 |
15 |
16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /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/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire')->hourly(); 16 | } 17 | 18 | /** 19 | * Register the commands for the application. 20 | */ 21 | protected function commands(): void 22 | { 23 | $this->load(__DIR__.'/Commands'); 24 | 25 | require base_path('routes/console.php'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /resources/js/Layouts/MainLayout.jsx: -------------------------------------------------------------------------------- 1 | import { usePage } from "@inertiajs/react"; 2 | 3 | import Footer from "@/Components/Footer"; 4 | import MainNavbar from "@/Components/MainNavbar"; 5 | import CartDrawer from "@/Components/CartDrawer"; 6 | 7 | export default function MainLayout({ children, filters }) { 8 | const { auth, carts } = usePage().props; 9 | 10 | return ( 11 |
12 | 13 |
14 | {children} 15 |
16 |
17 | 18 |
19 | ); 20 | } 21 | -------------------------------------------------------------------------------- /resources/js/Layouts/ProfileLayout.jsx: -------------------------------------------------------------------------------- 1 | import ProfileBreadcrumb from "@/Components/ProfileBreadcrumb"; 2 | import ProfileCard from "@/Components/ProfileCard"; 3 | 4 | export default function ProfileLayout({ children }) { 5 | return ( 6 |
7 |
8 | 9 |
10 |
11 |
12 | 13 |
14 |
{children}
15 |
16 |
17 | ); 18 | } 19 | -------------------------------------------------------------------------------- /app/Models/Address.php: -------------------------------------------------------------------------------- 1 | belongsTo(User::class, 'user_id'); 19 | } 20 | 21 | public function scopeWithDefault(Builder $query): Builder 22 | { 23 | return $query->where('default', '=', 'yes'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/Http/Controllers/AddressDefaultController.php: -------------------------------------------------------------------------------- 1 | authorize('update', $address); 14 | 15 | // Set address as default 16 | $address->update(['default' => 'yes']); 17 | 18 | // Set other address as not default 19 | Auth::user()->addresses()->whereNotIn('id', [$address->id])->update(['default' => 'no']); 20 | 21 | return redirect()->route('address.index')->with('message', 'Address successfully set as default!'); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /database/migrations/2023_09_10_200332_create_categories_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | 17 | $table->string('name', 255); 18 | 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | */ 26 | public function down(): void 27 | { 28 | Schema::dropIfExists('categories'); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /resources/js/Components/DarkModeToggle.jsx: -------------------------------------------------------------------------------- 1 | import { Moon, Sun } from "lucide-react"; 2 | 3 | import useColorMode from "@/Hooks/useColorMode"; 4 | 5 | export default function DarkModeToggle() { 6 | const [colorMode, setColorMode] = useColorMode(); 7 | 8 | return ( 9 | <> 10 | 18 | 19 | ); 20 | } 21 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | import forms from "@tailwindcss/forms"; 2 | import flowbite from "flowbite/plugin"; 3 | 4 | const { blackA, mauve, violet } = require("@radix-ui/colors"); 5 | 6 | /** @type {import('tailwindcss').Config} */ 7 | export default { 8 | content: [ 9 | "./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php", 10 | "./storage/framework/views/*.php", 11 | "./resources/views/**/*.blade.php", 12 | "./resources/js/**/*.jsx", 13 | "node_modules/flowbite-react/**/*.{js,jsx,ts,tsx}", 14 | ], 15 | theme: { 16 | extend: { 17 | colors: { 18 | ...blackA, 19 | ...mauve, 20 | ...violet, 21 | }, 22 | }, 23 | }, 24 | plugins: [forms, flowbite], 25 | darkMode: "class", 26 | }; 27 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | protected $dontFlash = [ 16 | 'current_password', 17 | 'password', 18 | 'password_confirmation', 19 | ]; 20 | 21 | /** 22 | * Register the exception handling callbacks for the application. 23 | */ 24 | public function register(): void 25 | { 26 | $this->reportable(function (Throwable $e) { 27 | // 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /database/migrations/2023_09_09_082617_create_countries_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('name'); 17 | $table->string('code'); 18 | $table->timestamps(); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | */ 25 | public function down(): void 26 | { 27 | Schema::dropIfExists('countries'); 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php: -------------------------------------------------------------------------------- 1 | string('email')->primary(); 16 | $table->string('token'); 17 | $table->timestamp('created_at')->nullable(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | */ 24 | public function down(): void 25 | { 26 | Schema::dropIfExists('password_reset_tokens'); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /public/avatar.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/Models/Cart.php: -------------------------------------------------------------------------------- 1 | belongsTo(Book::class, 'book_id'); 20 | } 21 | 22 | public function userOwner(): BelongsTo 23 | { 24 | return $this->belongsTo(User::class, 'user_id'); 25 | } 26 | 27 | public function scopeWithoutCheckout(Builder $query): Builder 28 | { 29 | return $query->whereNull('checkout_at'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/PasswordController.php: -------------------------------------------------------------------------------- 1 | validate([ 19 | 'current_password' => ['required', 'current_password'], 20 | 'password' => ['required', Password::defaults(), 'confirmed'], 21 | ]); 22 | 23 | $request->user()->update([ 24 | 'password' => Hash::make($validated['password']), 25 | ]); 26 | 27 | return back(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 24 | return redirect(RouteServiceProvider::HOME); 25 | } 26 | } 27 | 28 | return $next($request); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /resources/js/Pages/Book/Partials/SortBy.jsx: -------------------------------------------------------------------------------- 1 | import { Label, Select } from "flowbite-react"; 2 | 3 | export default function SortBy({ handleSelect, bookFilter }) { 4 | return ( 5 |
6 |
21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('uuid')->unique(); 17 | $table->text('connection'); 18 | $table->text('queue'); 19 | $table->longText('payload'); 20 | $table->longText('exception'); 21 | $table->timestamp('failed_at')->useCurrent(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('failed_jobs'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/migrations/2023_09_10_201516_create_category_book_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | 19 | $table->foreignIdFor(Category::class, 'category_id')->constrained('categories'); 20 | $table->foreignIdFor(Book::class, 'book_id')->constrained('books'); 21 | 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | */ 29 | public function down(): void 30 | { 31 | Schema::dropIfExists('category_book'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "type": "module", 4 | "scripts": { 5 | "dev": "vite", 6 | "build": "vite build" 7 | }, 8 | "devDependencies": { 9 | "@headlessui/react": "^1.4.2", 10 | "@inertiajs/react": "^1.0.0", 11 | "@tailwindcss/forms": "^0.5.3", 12 | "@vitejs/plugin-react": "^4.0.3", 13 | "autoprefixer": "^10.4.12", 14 | "axios": "^1.1.2", 15 | "laravel-vite-plugin": "^0.8.0", 16 | "postcss": "^8.4.18", 17 | "react": "^18.2.0", 18 | "react-dom": "^18.2.0", 19 | "tailwindcss": "^3.2.1", 20 | "vite": "^4.0.0" 21 | }, 22 | "dependencies": { 23 | "@radix-ui/colors": "^2.1.0", 24 | "@radix-ui/react-scroll-area": "^1.0.4", 25 | "flowbite-react": "^0.5.0", 26 | "lodash": "^4.17.21", 27 | "lucide-react": "^0.269.0", 28 | "swiper": "^10.2.0", 29 | "zustand": "^4.4.1" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/Http/Requests/ProfileUpdateRequest.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | public function rules(): array 17 | { 18 | return [ 19 | 'name' => ['string', 'max:255'], 20 | 'email' => ['email', 'max:255', Rule::unique(User::class)->ignore($this->user()->id)], 21 | 'phone' => ['max:15'], 22 | 'avatar' => 'nullable|mimes:jpg,png,jpeg,webp|max:5000' 23 | ]; 24 | } 25 | 26 | public function messages(): array 27 | { 28 | return [ 29 | 'avatar.mimes' => 'The file should be in one of the formats: jpg, png, jpeg, webp', 30 | ]; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /resources/js/Components/ShareLink.jsx: -------------------------------------------------------------------------------- 1 | import { Facebook, Twitter } from "lucide-react"; 2 | 3 | export default function ShareLink({ title, slug }) { 4 | return ( 5 |
6 | 15 | 16 |

Facebook

17 |
18 | 26 | 27 |

Twitter

28 |
29 |
30 | ); 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('name'); 17 | $table->string('email')->unique(); 18 | $table->string('phone')->nullable(); 19 | $table->timestamp('email_verified_at')->nullable(); 20 | $table->string('avatar')->nullable(); 21 | $table->string('password'); 22 | $table->rememberToken(); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | */ 30 | public function down(): void 31 | { 32 | Schema::dropIfExists('users'); 33 | } 34 | }; 35 | -------------------------------------------------------------------------------- /database/migrations/2023_09_24_191038_create_order_items_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | 19 | $table->foreignIdFor(Order::class, 'order_id')->constrained('orders'); 20 | $table->foreignIdFor(Book::class, 'book_id')->constrained('books'); 21 | 22 | $table->unsignedInteger('quantity'); 23 | $table->float('price', 10, 2); 24 | 25 | $table->timestamps(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | */ 32 | public function down(): void 33 | { 34 | Schema::dropIfExists('order_items'); 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->morphs('tokenable'); 17 | $table->string('name'); 18 | $table->string('token', 64)->unique(); 19 | $table->text('abilities')->nullable(); 20 | $table->timestamp('last_used_at')->nullable(); 21 | $table->timestamp('expires_at')->nullable(); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | */ 29 | public function down(): void 30 | { 31 | Schema::dropIfExists('personal_access_tokens'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | > 16 | */ 17 | protected $listen = [ 18 | Registered::class => [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | */ 26 | public function boot(): void 27 | { 28 | // 29 | } 30 | 31 | /** 32 | * Determine if events and listeners should be automatically discovered. 33 | */ 34 | public function shouldDiscoverEvents(): bool 35 | { 36 | return false; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /database/migrations/2023_09_18_231834_create_carts_table.php: -------------------------------------------------------------------------------- 1 | id(); 18 | 19 | $table->foreignIdFor(Book::class, 'book_id')->constrained('books'); 20 | $table->foreignIdFor(User::class, 'user_id')->nullable()->constrained('users'); 21 | $table->unsignedInteger('quantity'); 22 | $table->timestamp('checkout_at')->nullable(); 23 | $table->softDeletes(); 24 | 25 | $table->timestamps(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | */ 32 | public function down(): void 33 | { 34 | Schema::dropIfExists('carts'); 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /database/migrations/2023_09_25_025347_create_payments_table.php: -------------------------------------------------------------------------------- 1 | id(); 17 | 18 | $table->foreignIdFor(Order::class, 'order_id')->constrained('orders'); 19 | 20 | $table->string('refno')->nullable(); 21 | $table->string('status', 10)->nullable(); 22 | $table->string('reason')->nullable(); 23 | $table->string('billcode'); 24 | $table->float('amount', 10, 2); 25 | 26 | $table->timestamps(); 27 | }); 28 | } 29 | 30 | /** 31 | * Reverse the migrations. 32 | */ 33 | public function down(): void 34 | { 35 | Schema::dropIfExists('payments'); 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | 'scheme' => 'https', 22 | ], 23 | 24 | 'postmark' => [ 25 | 'token' => env('POSTMARK_TOKEN'), 26 | ], 27 | 28 | 'ses' => [ 29 | 'key' => env('AWS_ACCESS_KEY_ID'), 30 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 31 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 32 | ], 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /resources/js/Pages/Cart/Partials/CartTable.jsx: -------------------------------------------------------------------------------- 1 | import { Table } from "flowbite-react"; 2 | 3 | import CartItem from "@/Components/CartItem"; 4 | import CartTableRow from "@/Pages/Cart/Partials/CartTableRow"; 5 | 6 | export default function CartTable({ carts }) { 7 | return ( 8 | <> 9 | 10 | 11 | Book 12 | Quantity 13 | Total 14 | 15 | 16 | {carts.map((cart) => ( 17 | 18 | ))} 19 | 20 |
21 |
22 | {carts.map((cart) => ( 23 |
24 | 25 |
26 | ))} 27 |
28 | 29 | ); 30 | } 31 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class UserFactory extends Factory 12 | { 13 | /** 14 | * Define the model's default state. 15 | * 16 | * @return array 17 | */ 18 | public function definition(): array 19 | { 20 | return [ 21 | 'name' => fake()->name(), 22 | 'phone' => fake()->mobileNumber(false, false), 23 | 'email' => fake()->unique()->safeEmail(), 24 | 'email_verified_at' => now(), 25 | 'password' => 'password', 26 | 'remember_token' => Str::random(10), 27 | ]; 28 | } 29 | 30 | /** 31 | * Indicate that the model's email address should be unverified. 32 | */ 33 | public function unverified(): static 34 | { 35 | return $this->state(fn (array $attributes) => [ 36 | 'email_verified_at' => null, 37 | ]); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /resources/js/Components/AddToCart.jsx: -------------------------------------------------------------------------------- 1 | import { useState } from "react"; 2 | import { Button } from "flowbite-react"; 3 | import { router } from "@inertiajs/react"; 4 | 5 | import { useCartDrawer } from "@/Hooks/useCartDrawer"; 6 | 7 | export default function AddToCart({ id, quantity }) { 8 | const drawer = useCartDrawer(); 9 | const [isDisabled, setIsDisabled] = useState(false); 10 | 11 | const handleClick = (e) => { 12 | e.stopPropagation(); 13 | e.preventDefault(); 14 | 15 | router.post( 16 | route("cart.store"), 17 | { bookId: id, bookQuantity: quantity }, 18 | { 19 | preserveScroll: true, 20 | preserveState: false, 21 | onStart: () => { 22 | setIsDisabled(true); 23 | }, 24 | onFinish: () => { 25 | setIsDisabled(false); 26 | drawer.onOpen(); 27 | }, 28 | } 29 | ); 30 | }; 31 | 32 | return ( 33 | 42 | ); 43 | } 44 | -------------------------------------------------------------------------------- /database/factories/BookFactory.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class BookFactory extends Factory 11 | { 12 | /** 13 | * Define the model's default state. 14 | * 15 | * @return array 16 | */ 17 | public function definition(): array 18 | { 19 | return [ 20 | 'type' => fake()->randomElement(['Fiction', 'Non-Fiction']), 21 | 'title' => fake()->sentence(3), 22 | 'description' => fake()->paragraph(), 23 | 'image' => fake()->imageUrl(261, 400, 'book', true), 24 | 'isbn' => fake()->isbn13(), 25 | 'author' => fake()->firstName() . ' ' . fake()->lastName(), 26 | 'publisher' => fake()->company(), 27 | 'stocks' => fake()->numberBetween(0, 100), 28 | 'pages' => fake()->numberBetween(50, 500), 29 | 'weight' => fake()->numberBetween(20, 500), 30 | 'price' => fake()->randomFloat(2, 10, 200) 31 | ]; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /database/factories/AddressFactory.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class AddressFactory extends Factory 11 | { 12 | /** 13 | * Define the model's default state. 14 | * 15 | * @return array 16 | */ 17 | public function definition(): array 18 | { 19 | $negeri = [ 20 | 'Johor', 'Kedah', 'Kelantan', 'Melaka', 'Negeri Sembilan', 'Pahang', 'Perak', 'Perlis', 'Pulau Pinang', 21 | 'Sabah', 'Sarawak', 'Selangor', 'Terengganu', 'Kuala Lumpur', 'Labuan', 'Putrajaya' 22 | ]; 23 | return [ 24 | 'default' => 'no', 25 | 'name' => fake()->firstName() . ' ' . fake()->lastName(), 26 | 'phone' => fake()->mobileNumber(false, false), 27 | 'address' => fake()->streetAddress(), 28 | 'city' => fake()->city(), 29 | 'postal_code' => fake()->postcode(), 30 | 'state' => fake()->randomElement($negeri), 31 | 'country' => 'Malaysia', 32 | ]; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /resources/js/Pages/Book/Partials/ClearFilter.jsx: -------------------------------------------------------------------------------- 1 | import { X } from "lucide-react"; 2 | import { router } from "@inertiajs/react"; 3 | 4 | export default function ClearFilter({ bookFilter }) { 5 | const clearFilter = () => { 6 | router.get( 7 | route("book.index"), 8 | {}, 9 | { 10 | preserveScroll: true, 11 | } 12 | ); 13 | }; 14 | 15 | return ( 16 | 27 | ); 28 | } 29 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /database/migrations/2023_09_08_155432_create_addresses_table.php: -------------------------------------------------------------------------------- 1 | id(); 17 | 18 | $table->foreignIdFor(User::class, 'user_id')->constrained('users'); 19 | 20 | $table->enum('default', ['yes', 'no'])->default('no'); 21 | 22 | $table->string('name'); 23 | $table->string('phone', 50); 24 | $table->string('address'); 25 | $table->string('city', 100); 26 | $table->string('postal_code', 100); 27 | $table->string('state'); 28 | $table->string('country'); 29 | 30 | $table->timestamps(); 31 | }); 32 | } 33 | 34 | /** 35 | * Reverse the migrations. 36 | */ 37 | public function down(): void 38 | { 39 | Schema::dropIfExists('addresses'); 40 | } 41 | }; 42 | -------------------------------------------------------------------------------- /database/seeders/CategoryBookSeeder.php: -------------------------------------------------------------------------------- 1 | insert([ 24 | 'category_id' => rand(1, 16), 25 | 'book_id' => $book->id, 26 | 'created_at' => Carbon::now(), 27 | 'updated_at' => Carbon::now(), 28 | ]); 29 | } 30 | 31 | foreach ($categories as $category) { 32 | DB::table('category_book')->insert([ 33 | 'category_id' => $category->id, 34 | 'book_id' => rand(1, 24), 35 | 'created_at' => Carbon::now(), 36 | 'updated_at' => Carbon::now(), 37 | ]); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /database/seeders/CategorySeeder.php: -------------------------------------------------------------------------------- 1 | 'Fantasy'], 18 | ['name' => 'Romance'], 19 | ['name' => 'General Fiction'], 20 | ['name' => 'Science Fiction'], 21 | ['name' => 'Crime & Thriller'], 22 | ['name' => 'Action & Adventure'], 23 | ['name' => 'Family & Friendship'], 24 | ['name' => 'Horror & Paranormal'], 25 | ['name' => 'Economics'], 26 | ['name' => 'Self Help'], 27 | ['name' => 'Literature'], 28 | ['name' => 'Inspirational'], 29 | ['name' => 'Sports & Hobbies'], 30 | ['name' => 'Science & Medicine'], 31 | ['name' => 'Accounting & Finance'], 32 | ['name' => 'Computing & Internet'], 33 | ]; 34 | 35 | foreach ($categories as $value) { 36 | Category::create($value); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/Models/Order.php: -------------------------------------------------------------------------------- 1 | belongsTo(User::class, 'user_id'); 34 | } 35 | 36 | public function orderItems(): HasMany 37 | { 38 | return $this->hasMany(OrderItem::class, 'order_id'); 39 | } 40 | 41 | public function payments(): HasMany 42 | { 43 | return $this->hasMany(Payment::class, 'order_id'); 44 | } 45 | 46 | public function getRouteKeyName(): string 47 | { 48 | return 'order_no'; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | by($request->user()?->id ?: $request->ip()); 29 | }); 30 | 31 | $this->routes(function () { 32 | Route::middleware('api') 33 | ->prefix('api') 34 | ->group(base_path('routes/api.php')); 35 | 36 | Route::middleware('web') 37 | ->group(base_path('routes/web.php')); 38 | }); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /resources/js/Pages/Book/Breadcrumb/IndexBreadcrumb.jsx: -------------------------------------------------------------------------------- 1 | import { Link } from "@inertiajs/react"; 2 | import { ChevronRight, Home } from "lucide-react"; 3 | 4 | export default function IndexBreadcrumb() { 5 | return ( 6 | 30 | ); 31 | } 32 | -------------------------------------------------------------------------------- /resources/js/Pages/Cart/Breadcrumb/IndexBreadcrumb.jsx: -------------------------------------------------------------------------------- 1 | import { Link } from "@inertiajs/react"; 2 | import { ChevronRight, Home } from "lucide-react"; 3 | 4 | export default function IndexBreadcrumb() { 5 | return ( 6 | 30 | ); 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2023_09_10_170424_create_books_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | 17 | $table->enum('type', ['Fiction', 'Non-Fiction']); 18 | 19 | $table->string('title', 255); 20 | $table->string('slug', 255)->unique(); 21 | $table->text('description'); 22 | $table->string('image'); 23 | $table->string('isbn', 255); 24 | $table->string('author', 255); 25 | $table->string('publisher', 255); 26 | $table->unsignedInteger('stocks'); 27 | $table->unsignedInteger('pages'); 28 | $table->unsignedInteger('weight'); 29 | $table->float('price', 10, 2); 30 | 31 | $table->timestamps(); 32 | }); 33 | } 34 | 35 | /** 36 | * Reverse the migrations. 37 | */ 38 | public function down(): void 39 | { 40 | Schema::dropIfExists('books'); 41 | } 42 | }; 43 | -------------------------------------------------------------------------------- /resources/js/Pages/Checkout/Breadcrumb/IndexBreadcrumb.jsx: -------------------------------------------------------------------------------- 1 | import { Link } from "@inertiajs/react"; 2 | import { ChevronRight, Home } from "lucide-react"; 3 | 4 | export default function IndexBreadcrumb() { 5 | return ( 6 | 30 | ); 31 | } 32 | -------------------------------------------------------------------------------- /resources/js/Components/CartToggle.jsx: -------------------------------------------------------------------------------- 1 | import { ShoppingCart } from "lucide-react"; 2 | 3 | import { useCartDrawer } from "@/Hooks/useCartDrawer"; 4 | 5 | export default function CartToggle({ carts }) { 6 | const pathname = window.location.pathname; 7 | 8 | const drawer = useCartDrawer(); 9 | 10 | const openCartDrawer = () => { 11 | if (pathname !== "/cart") { 12 | drawer.onOpen(); 13 | } 14 | }; 15 | 16 | return ( 17 | <> 18 | 36 | 37 | ); 38 | } 39 | -------------------------------------------------------------------------------- /resources/js/Hooks/useLocalStorage.jsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from "react"; 2 | 3 | export default function useLocalStorage(key, initialValue) { 4 | // State to store our value 5 | // Pass initial state function to useState so logic is only executed once 6 | const [storedValue, setStoredValue] = useState(() => { 7 | try { 8 | // Get from local storage by key 9 | const item = window.localStorage.getItem(key); 10 | // Parse stored json or if none return initialValue 11 | return item ? JSON.parse(item) : initialValue; 12 | } catch (error) { 13 | // If error also return initialValue 14 | console.log(error); 15 | return initialValue; 16 | } 17 | }); 18 | 19 | // useEffect to update local storage when the state changes 20 | useEffect(() => { 21 | try { 22 | // Allow value to be a function so we have same API as useState 23 | const valueToStore = 24 | typeof storedValue === "function" 25 | ? storedValue(storedValue) 26 | : storedValue; 27 | // Save state 28 | window.localStorage.setItem(key, JSON.stringify(valueToStore)); 29 | } catch (error) { 30 | // A more advanced implementation would handle the error case 31 | console.log(error); 32 | } 33 | }, [key, storedValue]); 34 | 35 | return [storedValue, setStoredValue]; 36 | } 37 | -------------------------------------------------------------------------------- /database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create([ 19 | 'name' => 'John Doe', 20 | 'email' => 'johndoe@example.com', 21 | ]); 22 | 23 | User::factory()->create([ 24 | 'name' => 'Si Polan', 25 | 'email' => 'sipolan@example.com', 26 | ]); 27 | 28 | Address::factory(1)->create([ 29 | 'user_id' => 1, 30 | 'default' => 'yes' 31 | ]); 32 | 33 | Address::factory(1)->create([ 34 | 'user_id' => 1, 35 | ]); 36 | 37 | Address::factory(1)->create([ 38 | 'user_id' => 2, 39 | 'default' => 'yes' 40 | ]); 41 | 42 | Address::factory(1)->create([ 43 | 'user_id' => 2, 44 | ]); 45 | 46 | $this->call([ 47 | CountrySeeder::class, 48 | BookSeeder::class, 49 | CategorySeeder::class, 50 | CategoryBookSeeder::class 51 | ]); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * We'll load the axios HTTP library which allows us to easily issue requests 3 | * to our Laravel back-end. This library automatically handles sending the 4 | * CSRF token as a header based on the value of the "XSRF" token cookie. 5 | */ 6 | 7 | import axios from 'axios'; 8 | window.axios = axios; 9 | 10 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 11 | 12 | /** 13 | * Echo exposes an expressive API for subscribing to channels and listening 14 | * for events that are broadcast by Laravel. Echo and event broadcasting 15 | * allows your team to easily build robust real-time web applications. 16 | */ 17 | 18 | // import Echo from 'laravel-echo'; 19 | 20 | // import Pusher from 'pusher-js'; 21 | // window.Pusher = Pusher; 22 | 23 | // window.Echo = new Echo({ 24 | // broadcaster: 'pusher', 25 | // key: import.meta.env.VITE_PUSHER_APP_KEY, 26 | // cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'mt1', 27 | // wsHost: import.meta.env.VITE_PUSHER_HOST ? import.meta.env.VITE_PUSHER_HOST : `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`, 28 | // wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80, 29 | // wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443, 30 | // forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https', 31 | // enabledTransports: ['ws', 'wss'], 32 | // }); 33 | -------------------------------------------------------------------------------- /resources/js/Pages/Profile/Edit.jsx: -------------------------------------------------------------------------------- 1 | import { Card } from "flowbite-react"; 2 | import { Head } from "@inertiajs/react"; 3 | 4 | import MainLayout from "@/Layouts/MainLayout"; 5 | import ProfileLayout from "@/Layouts/ProfileLayout"; 6 | import DeleteUserForm from "@/Pages/Profile/Partials/DeleteUserForm"; 7 | import UpdatePasswordForm from "@/Pages/Profile/Partials/UpdatePasswordForm"; 8 | import UpdateProfileInformationForm from "@/Pages/Profile/Partials/UpdateProfileInformationForm"; 9 | 10 | export default function Edit({ user }) { 11 | return ( 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 |
30 |
31 | ); 32 | } 33 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME="Book Store" 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://127.0.0.1:8000 6 | APP_TIMEZONE=Asia/Kuala_Lumpur 7 | 8 | LOG_CHANNEL=stack 9 | LOG_DEPRECATIONS_CHANNEL=null 10 | LOG_LEVEL=debug 11 | 12 | DB_CONNECTION=mysql 13 | DB_HOST=127.0.0.1 14 | DB_PORT=3306 15 | DB_DATABASE=book_store 16 | DB_USERNAME=root 17 | DB_PASSWORD= 18 | 19 | BROADCAST_DRIVER=log 20 | CACHE_DRIVER=file 21 | FILESYSTEM_DISK=local 22 | QUEUE_CONNECTION=sync 23 | SESSION_DRIVER=file 24 | SESSION_LIFETIME=120 25 | 26 | MEMCACHED_HOST=127.0.0.1 27 | 28 | REDIS_HOST=127.0.0.1 29 | REDIS_PASSWORD=null 30 | REDIS_PORT=6379 31 | 32 | MAIL_MAILER=smtp 33 | MAIL_HOST=mailpit 34 | MAIL_PORT=1025 35 | MAIL_USERNAME=null 36 | MAIL_PASSWORD=null 37 | MAIL_ENCRYPTION=null 38 | MAIL_FROM_ADDRESS="hello@example.com" 39 | MAIL_FROM_NAME="${APP_NAME}" 40 | 41 | AWS_ACCESS_KEY_ID= 42 | AWS_SECRET_ACCESS_KEY= 43 | AWS_DEFAULT_REGION=us-east-1 44 | AWS_BUCKET= 45 | AWS_USE_PATH_STYLE_ENDPOINT=false 46 | 47 | PUSHER_APP_ID= 48 | PUSHER_APP_KEY= 49 | PUSHER_APP_SECRET= 50 | PUSHER_HOST= 51 | PUSHER_PORT=443 52 | PUSHER_SCHEME=https 53 | PUSHER_APP_CLUSTER=mt1 54 | 55 | VITE_APP_NAME="${APP_NAME}" 56 | VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 57 | VITE_PUSHER_HOST="${PUSHER_HOST}" 58 | VITE_PUSHER_PORT="${PUSHER_PORT}" 59 | VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" 60 | VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 61 | 62 | TOYYIBPAY_URL=https://dev.toyyibpay.com 63 | TOYYIBPAY_SECRET= 64 | TOYYIBPAY_CATEGORY= 65 | -------------------------------------------------------------------------------- /resources/js/Components/ProfileBreadcrumb.jsx: -------------------------------------------------------------------------------- 1 | import { Link } from "@inertiajs/react"; 2 | import { ChevronRight, Home } from "lucide-react"; 3 | 4 | export default function ProfileBreadcrumb() { 5 | const pathname = window.location.pathname; 6 | 7 | return ( 8 | 34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /resources/js/Pages/Checkout/Partials/CheckoutItem.jsx: -------------------------------------------------------------------------------- 1 | import { Link } from "@inertiajs/react"; 2 | 3 | export default function CheckoutItem({ cart }) { 4 | const price = (cart.book_owner.price * cart.quantity).toLocaleString( 5 | "en-MY", 6 | { 7 | style: "currency", 8 | currency: "MYR", 9 | maximumFractionDigits: 2, 10 | } 11 | ); 12 | 13 | return ( 14 |
15 | 19 | 23 |
24 | {cart.quantity} 25 |
26 | 27 |
28 | 32 |

{cart.book_owner.title}

33 | 34 |

{price}

35 |
36 |
37 | ); 38 | } 39 | -------------------------------------------------------------------------------- /database/migrations/2023_09_24_182030_create_orders_table.php: -------------------------------------------------------------------------------- 1 | id(); 17 | 18 | $table->foreignIdFor(User::class, 'user_id')->constrained('users'); 19 | 20 | $table->string('order_no', 50)->nullable(); 21 | 22 | $table->string('shipping_name'); 23 | $table->string('shipping_phone', 50); 24 | $table->string('shipping_address'); 25 | $table->string('shipping_city', 100); 26 | $table->string('shipping_postal_code', 100); 27 | $table->string('shipping_state'); 28 | $table->string('shipping_country'); 29 | 30 | $table->float('subtotal', 10, 2); 31 | $table->float('shipping', 10, 2); 32 | $table->float('total', 10, 2); 33 | 34 | $table->timestamp('paid_at')->nullable(); 35 | $table->timestamp('shipped_at')->nullable(); 36 | $table->timestamp('delivered_at')->nullable(); 37 | 38 | $table->timestamps(); 39 | }); 40 | } 41 | 42 | /** 43 | * Reverse the migrations. 44 | */ 45 | public function down(): void 46 | { 47 | Schema::dropIfExists('orders'); 48 | } 49 | }; 50 | -------------------------------------------------------------------------------- /routes/auth.php: -------------------------------------------------------------------------------- 1 | group(function () { 11 | Route::get('register', [RegisteredUserController::class, 'create']) 12 | ->name('register'); 13 | 14 | Route::post('register', [RegisteredUserController::class, 'store']); 15 | 16 | Route::get('login', [AuthenticatedSessionController::class, 'create']) 17 | ->name('login'); 18 | 19 | Route::post('login', [AuthenticatedSessionController::class, 'store']); 20 | 21 | Route::get('forgot-password', [PasswordResetLinkController::class, 'create']) 22 | ->name('password.request'); 23 | 24 | Route::post('forgot-password', [PasswordResetLinkController::class, 'store']) 25 | ->name('password.email'); 26 | 27 | Route::get('reset-password/{token}', [NewPasswordController::class, 'create']) 28 | ->name('password.reset'); 29 | 30 | Route::post('reset-password', [NewPasswordController::class, 'store']) 31 | ->name('password.store'); 32 | }); 33 | 34 | Route::middleware('auth')->group(function () { 35 | Route::put('password', [PasswordController::class, 'update'])->name('password.update'); 36 | 37 | Route::post('logout', [AuthenticatedSessionController::class, 'destroy']) 38 | ->name('logout'); 39 | }); 40 | -------------------------------------------------------------------------------- /app/Http/Controllers/BookController.php: -------------------------------------------------------------------------------- 1 | only([ 17 | 'search', 'page', 'type', 'category', 'author', 'publisher', 'price', 'sort' 18 | ]); 19 | 20 | return inertia('Book/Index', [ 21 | 'filters' => $filters, 22 | 'categories' => Category::orderBy('name', 'asc') 23 | ->get(), 24 | 'authors' => Book::select('author') 25 | ->groupBy('author') 26 | ->orderBy('author', 'asc') 27 | ->get(), 28 | 'publishers' => Book::select('publisher') 29 | ->groupBy('publisher') 30 | ->orderBy('publisher', 'asc') 31 | ->get(), 32 | 'books' => Book::filter($filters) 33 | ->paginate(12) 34 | ->withQueryString() 35 | ]); 36 | } 37 | 38 | /** 39 | * Display the specified resource. 40 | */ 41 | public function show(Book $book) 42 | { 43 | return inertia('Book/Show', [ 44 | 'book' => $book, 45 | 'relatedBooks' => Book::whereNot('id', '=', $book->id) 46 | ->where('type', '=', $book->type) 47 | ->inRandomOrder()->limit(10) 48 | ->get() 49 | ]); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/PasswordResetLinkController.php: -------------------------------------------------------------------------------- 1 | session('status'), 22 | ]); 23 | } 24 | 25 | /** 26 | * Handle an incoming password reset link request. 27 | * 28 | * @throws \Illuminate\Validation\ValidationException 29 | */ 30 | public function store(Request $request): RedirectResponse 31 | { 32 | $request->validate([ 33 | 'email' => 'required|email', 34 | ]); 35 | 36 | // We will send the password reset link to this user. Once we have attempted 37 | // to send the link, we will examine the response then see the message we 38 | // need to show to the user. Finally, we'll send out a proper response. 39 | $status = Password::sendResetLink( 40 | $request->only('email') 41 | ); 42 | 43 | if ($status == Password::RESET_LINK_SENT) { 44 | return back()->with('status', __($status)); 45 | } 46 | 47 | throw ValidationException::withMessages([ 48 | 'email' => [trans($status)], 49 | ]); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /resources/js/Components/BookDescription.jsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useRef, useState } from "react"; 2 | 3 | export default function Description({ description }) { 4 | const descriptionRef = useRef(null); 5 | const [height, setHeight] = useState(0); 6 | const [isViewMore, setIsViewMore] = useState(false); 7 | 8 | useEffect(() => { 9 | setHeight(descriptionRef.current.clientHeight); 10 | }, []); 11 | 12 | const descriptionArr = description.split("\\n"); 13 | 14 | return ( 15 | <> 16 |
250 20 | ? !isViewMore 21 | ? "max-h-[250px] overflow-hidden" 22 | : "" 23 | : "" 24 | }`} 25 | > 26 |

Description:

27 | {descriptionArr.map((desc, index) => ( 28 |

29 | {desc} 30 |

31 | ))} 32 |
250 ? (isViewMore ? "hidden" : "") : "hidden" 35 | }`} 36 | >
37 |
38 | 39 |
250 ? "inline-flex" : "hidden"} justify-center`} 41 | > 42 |
setIsViewMore(!isViewMore)} 44 | className="text-center text-cyan-700 dark:text-cyan-600 hover:opacity-80 hover:cursor-pointer hover:underline font-medium" 45 | > 46 | {!isViewMore ? "View More" : "View Less"} 47 |
48 |
49 | 50 | ); 51 | } 52 | -------------------------------------------------------------------------------- /app/Policies/AddressPolicy.php: -------------------------------------------------------------------------------- 1 | id == $address->user_id; 25 | } 26 | 27 | /** 28 | * Determine whether the user can create models. 29 | */ 30 | public function create(User $user): bool 31 | { 32 | return true; 33 | } 34 | 35 | /** 36 | * Determine whether the user can update the model. 37 | */ 38 | public function update(User $user, Address $address): bool 39 | { 40 | return $user->id == $address->user_id; 41 | } 42 | 43 | /** 44 | * Determine whether the user can delete the model. 45 | */ 46 | public function delete(User $user, Address $address): bool 47 | { 48 | return $user->id == $address->user_id; 49 | } 50 | 51 | /** 52 | * Determine whether the user can restore the model. 53 | */ 54 | public function restore(User $user, Address $address): bool 55 | { 56 | return $user->id == $address->user_id; 57 | } 58 | 59 | /** 60 | * Determine whether the user can permanently delete the model. 61 | */ 62 | public function forceDelete(User $user, Address $address): bool 63 | { 64 | return $user->id == $address->user_id; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/RegisteredUserController.php: -------------------------------------------------------------------------------- 1 | validate([ 35 | 'name' => 'required|string|max:255', 36 | 'email' => 'required|string|email|max:255|unique:' . User::class, 37 | 'phone' => 'max:15', 38 | 'password' => ['required', 'confirmed', Rules\Password::defaults()], 39 | 'accept' => 'accepted' 40 | ]); 41 | 42 | $user = User::create([ 43 | 'name' => $request->name, 44 | 'email' => $request->email, 45 | 'phone' => $request->phone, 46 | 'password' => Hash::make($request->password), 47 | ]); 48 | 49 | event(new Registered($user)); 50 | 51 | Auth::login($user); 52 | 53 | return redirect(RouteServiceProvider::HOME); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /resources/js/Components/CartItem.jsx: -------------------------------------------------------------------------------- 1 | import { useState } from "react"; 2 | import { Link } from "@inertiajs/react"; 3 | 4 | import CartQuantity from "@/Components/CartQuantity"; 5 | 6 | export default function CartItem({ cart }) { 7 | const [isDisabled, setIsDisabled] = useState(false); 8 | 9 | const price = (cart.book_owner.price * cart.quantity).toLocaleString( 10 | "en-MY", 11 | { 12 | style: "currency", 13 | currency: "MYR", 14 | maximumFractionDigits: 2, 15 | } 16 | ); 17 | 18 | return ( 19 |
20 | 24 | 30 | 31 |
32 |

33 | {price} 34 |

35 | 39 |

40 | {cart.book_owner.title} 41 |

42 | 43 | 48 |
49 |
50 | ); 51 | } 52 | -------------------------------------------------------------------------------- /resources/js/Pages/Book/Breadcrumb/ShowBreadcrumb.jsx: -------------------------------------------------------------------------------- 1 | import { Link } from "@inertiajs/react"; 2 | import { ChevronRight, Home } from "lucide-react"; 3 | 4 | export default function ShowBreadcrumb({ title }) { 5 | return ( 6 | 40 | ); 41 | } 42 | -------------------------------------------------------------------------------- /resources/js/Components/Pagination.jsx: -------------------------------------------------------------------------------- 1 | import { Link } from "@inertiajs/react"; 2 | import { ChevronLeft, ChevronRight } from "lucide-react"; 3 | 4 | export default function Pagination({ links }) { 5 | return ( 6 | 41 | ); 42 | } 43 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /resources/js/Layouts/ScrollAreaLayout.jsx: -------------------------------------------------------------------------------- 1 | import * as ScrollArea from "@radix-ui/react-scroll-area"; 2 | 3 | export default function ScrollAreaLayout({ children }) { 4 | return ( 5 | 6 | 7 |
{children}
8 |
9 | 13 | 14 | 15 | 19 | 20 | 21 | 22 |
23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | 20 | */ 21 | protected $fillable = [ 22 | 'name', 23 | 'email', 24 | 'phone', 25 | 'password', 26 | 'avatar' 27 | ]; 28 | 29 | protected $appends = ['src']; 30 | 31 | /** 32 | * The attributes that should be hidden for serialization. 33 | * 34 | * @var array 35 | */ 36 | protected $hidden = [ 37 | 'password', 38 | 'remember_token', 39 | ]; 40 | 41 | /** 42 | * The attributes that should be cast. 43 | * 44 | * @var array 45 | */ 46 | protected $casts = [ 47 | 'email_verified_at' => 'datetime', 48 | 'password' => 'hashed', 49 | ]; 50 | 51 | public function getSrcAttribute() 52 | { 53 | return asset("storage/{$this->avatar}"); 54 | } 55 | 56 | public function addresses(): HasMany 57 | { 58 | return $this->hasMany(Address::class, 'user_id'); 59 | } 60 | 61 | public function carts(): HasMany 62 | { 63 | return $this->hasMany(Cart::class, 'user_id'); 64 | } 65 | 66 | public function orders(): HasMany 67 | { 68 | return $this->hasMany(Order::class, 'user_id'); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/Http/Controllers/PaymentController.php: -------------------------------------------------------------------------------- 1 | only([ 17 | 'status_id', 'billcode', 'order_id' 18 | ]); 19 | 20 | return inertia('Payment/Index', [ 21 | 'params' => $params, 22 | 'order' => !empty($params['order_id']) ? Order::where('id', '=', $params['order_id'])->first() : null 23 | ]); 24 | } 25 | 26 | /** 27 | * Update the order's payment status. 28 | */ 29 | public function update(Request $request) 30 | { 31 | $refno = $request->input('refno'); 32 | $status = $request->input('status'); 33 | $reason = $request->input('reason'); 34 | $billcode = $request->input('billcode'); 35 | $order_id = $request->input('order_id'); 36 | $amount = $request->input('amount'); 37 | 38 | // Update payment data 39 | Payment::where('order_id', '=', $order_id)->where('billcode', '=', $billcode)->update([ 40 | 'refno' => $refno, 41 | 'status' => $status, 42 | 'reason' => $reason, 43 | 'amount' => $amount 44 | ]); 45 | 46 | // Check if payment status is successful 47 | if ($status == 1) { 48 | $order = Order::where('id', '=', $order_id)->first(); 49 | 50 | // Update paid at 51 | if ($order->paid_at === NULL) { 52 | $order->update([ 53 | 'paid_at' => now() 54 | ]); 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/Http/Controllers/ProfileController.php: -------------------------------------------------------------------------------- 1 | Auth::user() 22 | ]); 23 | } 24 | 25 | /** 26 | * Update the user's profile information. 27 | */ 28 | public function update(ProfileUpdateRequest $request): RedirectResponse 29 | { 30 | if ($request->hasFile('avatar')) { 31 | $path = $request->file('avatar')->store('avatars', 'public'); 32 | $request->user()->fill(array_merge($request->validated(), ['avatar' => $path])); 33 | $request->user()->save(); 34 | } else { 35 | $request->user()->fill($request->safe()->except(['avatar'])); 36 | $request->user()->save(); 37 | } 38 | 39 | return Redirect::route('profile.edit'); 40 | } 41 | 42 | /** 43 | * Delete the user's account. 44 | */ 45 | public function destroy(Request $request): RedirectResponse 46 | { 47 | $request->validate([ 48 | 'password' => ['required', 'current_password'], 49 | ]); 50 | 51 | $user = $request->user(); 52 | 53 | Auth::logout(); 54 | 55 | $user->delete(); 56 | 57 | $request->session()->invalidate(); 58 | $request->session()->regenerateToken(); 59 | 60 | return Redirect::to('/'); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /resources/js/Pages/Checkout/Partials/CheckoutTotal.jsx: -------------------------------------------------------------------------------- 1 | import CheckoutItem from "@/Pages/Checkout/Partials/CheckoutItem"; 2 | 3 | export default function CheckoutTotal({ carts }) { 4 | const subTotal = carts 5 | .map((cart) => cart.book_owner.price * cart.quantity) 6 | .reduce((totalPrice, currentPrice) => totalPrice + currentPrice, 0) 7 | .toLocaleString("en-MY", { 8 | style: "currency", 9 | currency: "MYR", 10 | maximumFractionDigits: 2, 11 | }); 12 | 13 | const shipping = (10).toLocaleString("en-MY", { 14 | style: "currency", 15 | currency: "MYR", 16 | maximumFractionDigits: 2, 17 | }); 18 | 19 | const totalAll = ( 20 | carts 21 | .map((cart) => cart.book_owner.price * cart.quantity) 22 | .reduce((totalPrice, currentPrice) => totalPrice + currentPrice, 0) + 10 23 | ).toLocaleString("en-MY", { 24 | style: "currency", 25 | currency: "MYR", 26 | maximumFractionDigits: 2, 27 | }); 28 | 29 | return ( 30 |
31 | {carts.map((cart) => ( 32 | 33 | ))} 34 | 35 |
36 |
37 |

Subtotal

38 |

{subTotal}

39 |
40 |
41 |

Shipping

42 |

{shipping}

43 |
44 |
45 | 46 |
47 |

Total

48 |

{totalAll}

49 |
50 |
51 | ); 52 | } 53 | -------------------------------------------------------------------------------- /resources/js/Components/Address.jsx: -------------------------------------------------------------------------------- 1 | import AddressForm from "@/Pages/Address/Partials/AddressForm"; 2 | import AddressDelete from "@/Pages/Address/Partials/AddressDelete"; 3 | import AddressDefault from "@/Pages/Address/Partials/AddressDefault"; 4 | 5 | export default function Address({ address, countries, first }) { 6 | return ( 7 |
8 | {!first &&
} 9 |
10 |
11 | 12 | 13 | 14 |
15 |
16 |

17 | {address.name} 18 |

19 |

20 | {address.phone} 21 |

22 |
23 |
24 |

25 | {address.address}, 26 |

27 |

28 | {address.postal_code} {address.city}, {address.state}, 29 |

30 |

31 | {address.country} 32 |

33 | {address.default === "yes" && ( 34 |
35 |

36 | Default 37 |

38 |
39 | )} 40 |
41 | ); 42 | } 43 | -------------------------------------------------------------------------------- /resources/js/Components/QuantityInput.jsx: -------------------------------------------------------------------------------- 1 | import { Minus, Plus } from "lucide-react"; 2 | 3 | export default function QuantityInput({ 4 | quantity, 5 | handleAdd, 6 | handleMinus, 7 | handleQuantityChange, 8 | }) { 9 | return ( 10 |
11 | 14 |
15 | 21 | handleQuantityChange(e)} 28 | className="quantity-input block w-12 h-8 border disabled:cursor-not-allowed disabled:opacity-50 bg-gray-50 border-gray-300 text-gray-900 focus:border-cyan-500 focus:ring-cyan-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 dark:focus:border-cyan-500 dark:focus:ring-cyan-500 text-sm font-medium text-center" 29 | /> 30 | 36 |
37 |
38 | ); 39 | } 40 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /resources/js/Components/BookCard.jsx: -------------------------------------------------------------------------------- 1 | import { Link } from "@inertiajs/react"; 2 | import AddToCart from "@/Components/AddToCart"; 3 | 4 | export default function BookCard({ book }) { 5 | const price = book.price.toLocaleString("en-MY", { 6 | style: "currency", 7 | currency: "MYR", 8 | maximumFractionDigits: 2, 9 | }); 10 | return ( 11 | 12 |
13 |
14 | {book.title} 19 |

20 | {book.publisher} 21 |

22 |
23 |

{book.title}

24 |
25 |

26 | {price} 27 |

28 | {book.stocks > 0 && ( 29 |

30 | In Stock 31 |

32 | )} 33 | {book.stocks < 1 && ( 34 |

35 | Out of Stock 36 |

37 | )} 38 |
39 | 40 |
41 |
42 |
43 | 44 | ); 45 | } 46 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /resources/js/Pages/Book/Partials/TypeFilter.jsx: -------------------------------------------------------------------------------- 1 | import { Checkbox, Label } from "flowbite-react"; 2 | 3 | import FilterLayout from "@/Layouts/FilterLayout"; 4 | import ScrollAreaLayout from "@/Layouts/ScrollAreaLayout"; 5 | 6 | export default function TypeFilter({ handleCheckbox, bookFilter, isMobile }) { 7 | return ( 8 | 9 |
10 | 11 |
12 | handleCheckbox(e, "type")} 17 | defaultChecked={ 18 | bookFilter.type && 19 | bookFilter.type.split(",").includes("fiction") 20 | } 21 | /> 22 | 28 |
29 |
30 | handleCheckbox(e, "type")} 35 | defaultChecked={ 36 | bookFilter.type && 37 | bookFilter.type.split(",").includes("non-fiction") 38 | } 39 | /> 40 | 46 |
47 |
48 |
49 |
50 | ); 51 | } 52 | -------------------------------------------------------------------------------- /resources/views/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | @routes 29 | @viteReactRefresh 30 | @vite(['resources/js/app.jsx', "resources/js/Pages/{$page['component']}.jsx"]) 31 | @inertiaHead 32 | 33 | 34 | @inertia 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/Http/Middleware/HandleInertiaRequests.php: -------------------------------------------------------------------------------- 1 | 31 | */ 32 | public function share(Request $request): array 33 | { 34 | return array_merge(parent::share($request), [ 35 | 'flash' => [ 36 | 'message' => fn () => $request->session()->get('message') 37 | ], 38 | 'auth.user' => fn () => $request->user() 39 | ? $request->user()->only('id', 'name', 'email', 'phone', 'avatar', 'src') 40 | : null, 41 | 'ziggy' => function () use ($request) { 42 | return array_merge((new Ziggy)->toArray(), [ 43 | 'location' => $request->url(), 44 | ]); 45 | }, 46 | 'carts' => function () use ($request) { 47 | if ($request->user()) { 48 | return $request->user()->carts()->withoutCheckout()->with('bookOwner')->get(); 49 | } else { 50 | $cartIds = $request->session()->get('carts'); 51 | if ($cartIds) { 52 | return Cart::whereIn('id', $cartIds)->withoutCheckout()->with('bookOwner')->get(); 53 | } else { 54 | return []; 55 | } 56 | } 57 | } 58 | ]); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /resources/js/Components/RelatedBooks.jsx: -------------------------------------------------------------------------------- 1 | import { Swiper, SwiperSlide } from "swiper/react"; 2 | import { Navigation, Pagination } from "swiper/modules"; 3 | 4 | import "swiper/css"; 5 | import "swiper/css/navigation"; 6 | import "swiper/css/pagination"; 7 | 8 | import BookCard from "@/Components/BookCard"; 9 | 10 | export default function RelatedBooks({ books }) { 11 | return ( 12 | <> 13 |
14 |
15 | 16 | Related Books 17 | 18 |
19 | 20 |
21 | 50 | {books.length > 0 && ( 51 | <> 52 | {books.map((book) => ( 53 | 54 | 55 | 56 | ))} 57 | 58 | )} 59 | 60 |
61 | 62 | ); 63 | } 64 | -------------------------------------------------------------------------------- /resources/js/Pages/Order/Index.jsx: -------------------------------------------------------------------------------- 1 | import { Card } from "flowbite-react"; 2 | import { Head } from "@inertiajs/react"; 3 | 4 | import Order from "@/Components/Order"; 5 | import MainLayout from "@/Layouts/MainLayout"; 6 | import ProfileLayout from "@/Layouts/ProfileLayout"; 7 | 8 | export default function Index({ orders }) { 9 | return ( 10 | 11 | 12 | My Orders — Book Store 13 | 17 | 18 | 19 | 20 | 21 |
22 |
23 |
24 |

25 | My Orders 26 |

27 |

28 | These are your list of orders. 29 |

30 |
31 |
32 | 33 | {orders.length > 0 && ( 34 |
35 | {orders.map((order, index) => ( 36 | 37 | ))} 38 |
39 | )} 40 | 41 | {orders.length < 1 && ( 42 |
43 |

44 | There are no orders currently. 45 |

46 |
47 | )} 48 |
49 |
50 |
51 |
52 | ); 53 | } 54 | -------------------------------------------------------------------------------- /resources/js/Components/Modal.jsx: -------------------------------------------------------------------------------- 1 | import { Fragment } from "react"; 2 | import { Dialog, Transition } from "@headlessui/react"; 3 | 4 | export default function Modal({ 5 | children, 6 | show = false, 7 | maxWidth = "2xl", 8 | closeable = true, 9 | onClose = () => {}, 10 | }) { 11 | const close = () => { 12 | if (closeable) { 13 | onClose(); 14 | } 15 | }; 16 | 17 | const maxWidthClass = { 18 | sm: "sm:max-w-sm", 19 | md: "sm:max-w-md", 20 | lg: "sm:max-w-lg", 21 | xl: "sm:max-w-xl", 22 | "2xl": "sm:max-w-xl", 23 | }[maxWidth]; 24 | 25 | return ( 26 | 27 | 33 | 42 |
43 | 44 | 45 | 54 | 57 | {children} 58 | 59 | 60 |
61 |
62 | ); 63 | } 64 | -------------------------------------------------------------------------------- /resources/js/Pages/Address/Partials/AddressDelete.jsx: -------------------------------------------------------------------------------- 1 | import { useState } from "react"; 2 | import { Trash } from "lucide-react"; 3 | import { useForm } from "@inertiajs/react"; 4 | import { Button, Tooltip } from "flowbite-react"; 5 | 6 | import Modal from "@/Components/Modal"; 7 | 8 | export default function AddressDelete({ address }) { 9 | const [openModal, setOpenModal] = useState(false); 10 | 11 | const { delete: destroy, processing } = useForm(); 12 | 13 | const deleteAddress = (e) => { 14 | e.preventDefault(); 15 | 16 | destroy(route("address.destroy", address.id), { 17 | preserveScroll: true, 18 | onSuccess: () => closeModal(), 19 | }); 20 | }; 21 | 22 | const closeModal = () => { 23 | setOpenModal(false); 24 | reset(); 25 | }; 26 | 27 | return ( 28 | <> 29 | 30 | 38 | 39 | 40 | 41 |
42 |

43 | Are you sure you want to delete this address? 44 |

45 | 46 |

47 | Once address is deleted, the data will be permanently deleted. 48 |

49 | 50 |
51 | 54 | 62 |
63 |
64 |
65 | 66 | ); 67 | } 68 | -------------------------------------------------------------------------------- /resources/js/Components/CartTotal.jsx: -------------------------------------------------------------------------------- 1 | import { router } from "@inertiajs/react"; 2 | 3 | import { useCartDrawer } from "@/Hooks/useCartDrawer"; 4 | 5 | export default function CartTotal({ carts }) { 6 | const drawer = useCartDrawer(); 7 | 8 | const price = carts 9 | .map((cart) => cart.book_owner.price * cart.quantity) 10 | .reduce((totalPrice, currentPrice) => totalPrice + currentPrice, 0) 11 | .toLocaleString("en-MY", { 12 | style: "currency", 13 | currency: "MYR", 14 | maximumFractionDigits: 2, 15 | }); 16 | 17 | const viewCart = () => { 18 | drawer.onClose(); 19 | router.get(route("cart.index")); 20 | }; 21 | 22 | const viewCheckout = () => { 23 | drawer.onClose(); 24 | router.get(route("checkout.index")); 25 | }; 26 | 27 | return ( 28 |
29 |

Total

30 |

31 | {price} 32 |

33 |

34 | Tax included. Shipping calculated at checkout. 35 |

36 |
37 | 43 | 49 |
50 |
51 | ); 52 | } 53 | -------------------------------------------------------------------------------- /resources/js/Components/RandomBooks.jsx: -------------------------------------------------------------------------------- 1 | import { Link } from "@inertiajs/react"; 2 | 3 | import { Swiper, SwiperSlide } from "swiper/react"; 4 | import { Navigation, Pagination } from "swiper/modules"; 5 | 6 | import "swiper/css"; 7 | import "swiper/css/navigation"; 8 | import "swiper/css/pagination"; 9 | 10 | import BookCard from "@/Components/BookCard"; 11 | 12 | export default function RandomBooks({ books }) { 13 | return ( 14 |
15 |
16 |

17 | Featured Books 18 |

19 | 23 | View all 24 | 25 |
26 | 27 |
28 | 57 | {books.length > 0 && ( 58 | <> 59 | {books.map((book) => ( 60 | 61 | 62 | 63 | ))} 64 | 65 | )} 66 | 67 |
68 |
69 | ); 70 | } 71 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | only(['index', 'show']); 29 | 30 | Route::resource('cart', CartController::class)->only(['index', 'store', 'update', 'destroy']); 31 | 32 | Route::get('/payment-return', [PaymentController::class, 'index'])->name('payment.index'); 33 | Route::post('/payment-callback', [PaymentController::class, 'update'])->name('payment.update'); 34 | 35 | Route::middleware('auth')->group(function () { 36 | Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit'); 37 | Route::post('/profile', [ProfileController::class, 'update'])->name('profile.update'); 38 | Route::delete('/profile', [ProfileController::class, 'destroy'])->name('profile.destroy'); 39 | 40 | Route::resource('address', AddressController::class)->only(['index', 'store', 'update', 'destroy']); 41 | 42 | Route::name('address.default')->put('address/{address}/default', AddressDefaultController::class); 43 | 44 | Route::resource('checkout', CheckoutController::class)->only(['index']); 45 | 46 | Route::resource('order', OrderController::class)->only(['index', 'store', 'show', 'update']); 47 | }); 48 | 49 | require __DIR__ . '/auth.php'; 50 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The skeleton application for the Laravel framework.", 5 | "keywords": [ 6 | "laravel", 7 | "framework" 8 | ], 9 | "license": "MIT", 10 | "require": { 11 | "php": "^8.1", 12 | "guzzlehttp/guzzle": "^7.2", 13 | "inertiajs/inertia-laravel": "^0.6.3", 14 | "laravel/framework": "^10.10", 15 | "laravel/sanctum": "^3.2", 16 | "laravel/tinker": "^2.8", 17 | "tightenco/ziggy": "^1.0" 18 | }, 19 | "require-dev": { 20 | "barryvdh/laravel-debugbar": "^3.9", 21 | "barryvdh/laravel-ide-helper": "^2.13", 22 | "fakerphp/faker": "^1.9.1", 23 | "laravel/breeze": "^1.23", 24 | "laravel/pint": "^1.0", 25 | "laravel/sail": "^1.18", 26 | "mockery/mockery": "^1.4.4", 27 | "nunomaduro/collision": "^7.0", 28 | "phpunit/phpunit": "^10.1", 29 | "spatie/laravel-ignition": "^2.0" 30 | }, 31 | "autoload": { 32 | "psr-4": { 33 | "App\\": "app/", 34 | "Database\\Factories\\": "database/factories/", 35 | "Database\\Seeders\\": "database/seeders/" 36 | } 37 | }, 38 | "autoload-dev": { 39 | "psr-4": { 40 | "Tests\\": "tests/" 41 | } 42 | }, 43 | "scripts": { 44 | "post-autoload-dump": [ 45 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 46 | "@php artisan package:discover --ansi" 47 | ], 48 | "post-update-cmd": [ 49 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force", 50 | "@php artisan ide-helper:generate", 51 | "@php artisan ide-helper:meta" 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 | "allow-plugins": { 70 | "pestphp/pest-plugin": true, 71 | "php-http/discovery": true 72 | } 73 | }, 74 | "minimum-stability": "stable", 75 | "prefer-stable": true 76 | } 77 | -------------------------------------------------------------------------------- /resources/js/Components/UserDropdown.jsx: -------------------------------------------------------------------------------- 1 | import { Link } from "@inertiajs/react"; 2 | import { Avatar, Dropdown } from "flowbite-react"; 3 | import { User, LogOut, MapPin, ChevronDown, ClipboardList } from "lucide-react"; 4 | 5 | export default function UserDropdown({ user }) { 6 | return ( 7 | 13 |
14 | 21 |
22 | 23 | {user.name} 24 | 25 |
26 | 27 |
28 | 29 | } 30 | > 31 | 32 | {user.name} 33 | {user.email} 34 | 35 | 36 | 37 | My Profile 38 | 39 | 40 | 41 | 42 | My Orders 43 | 44 | 45 | 46 | 47 | My Addresses 48 | 49 | 50 | 51 | 52 | 53 | Sign out 54 | 55 | 56 |
57 | ); 58 | } 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [Book Store](https://book-store.salimi.my) · [![Author Salimi](https://img.shields.io/badge/Author-Salimi-%3C%3E)](https://www.linkedin.com/in/mohamad-salimi/) 2 | 3 | This is an online book store e-commerce app created using Laravel, React and Inertia. Complete with payment gateway using toyyibPay for Online Banking (FPX). 4 | 5 | ## Book Store e-Commerce 6 | 7 | - A complete e-commerce app 8 | - Server side carts 9 | - ToyyibPay payment gateway 10 | 11 | ## Tech/framework used 12 | 13 | - Laravel 14 | - Inertia.js 15 | - React.js 16 | - Tailwind CSS 17 | - MySQL 18 | - Zustand 19 | - ToyyibPay 20 | 21 | ## Starting the project 22 | 23 | Open the .env.example and fill in your database & toyyibPay configurations then save it as .env then run the following command: 24 | 25 | ```bash 26 | #Install dependencies 27 | composer install 28 | npm install 29 | 30 | #Run database migration & seeding 31 | php artisan migrate 32 | php artisan db:seed 33 | 34 | #Start the app 35 | npm run dev 36 | php artisan serve 37 | ``` 38 | 39 | ## Demo 40 | 41 | Hosted privately on personal DigitalOcean Droplet. [Click here](https://book-store.salimi.my) to visit. 42 |
43 | Direct link: `https://book-store.salimi.my` 44 | 45 | ## Screenshots 46 | 47 | #### Landing page 48 | 49 | ![Landing page](/screenshots/screenshot-1.png) 50 | 51 | #### Book page 52 | 53 | ![Book page](/screenshots/screenshot-2.png) 54 | 55 | #### Book details page 56 | 57 | ![Book details page](/screenshots/screenshot-3.png) 58 | 59 | #### Sign in page 60 | 61 | ![Sign in page](/screenshots/screenshot-4.png) 62 | 63 | #### Sign up page 64 | 65 | ![Sign up page](/screenshots/screenshot-5.png) 66 | 67 | #### User account page 68 | 69 | ![User account page](/screenshots/screenshot-6.png) 70 | 71 | #### User addresses page 72 | 73 | ![User addresses page](/screenshots/screenshot-7.png) 74 | 75 | #### Sidebar cart 76 | 77 | ![Sidebar cart](/screenshots/screenshot-8.png) 78 | 79 | #### Cart page 80 | 81 | ![Cart page](/screenshots/screenshot-9.png) 82 | 83 | #### Checkout page 84 | 85 | ![Checkout page](/screenshots/screenshot-10.png) 86 | 87 | #### ToyyibPay payment page 88 | 89 | ![ToyyibPay payment page](/screenshots/screenshot-11.png) 90 | 91 | #### Orders list page 92 | 93 | ![Orders list page](/screenshots/screenshot-12.png) 94 | 95 | #### Order detail page 96 | 97 | ![Order detail page](/screenshots/screenshot-13.png) 98 | -------------------------------------------------------------------------------- /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 | 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 41 | 'port' => env('PUSHER_PORT', 443), 42 | 'scheme' => env('PUSHER_SCHEME', 'https'), 43 | 'encrypted' => true, 44 | 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', 45 | ], 46 | 'client_options' => [ 47 | // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html 48 | ], 49 | ], 50 | 51 | 'ably' => [ 52 | 'driver' => 'ably', 53 | 'key' => env('ABLY_KEY'), 54 | ], 55 | 56 | 'redis' => [ 57 | 'driver' => 'redis', 58 | 'connection' => 'default', 59 | ], 60 | 61 | 'log' => [ 62 | 'driver' => 'log', 63 | ], 64 | 65 | 'null' => [ 66 | 'driver' => 'null', 67 | ], 68 | 69 | ], 70 | 71 | ]; 72 | -------------------------------------------------------------------------------- /resources/js/Pages/Payment/Index.jsx: -------------------------------------------------------------------------------- 1 | import { Button } from "flowbite-react"; 2 | import { Head, router } from "@inertiajs/react"; 3 | import { CheckCircle, XCircle } from "lucide-react"; 4 | 5 | export default function Index({ params, order }) { 6 | return ( 7 | <> 8 | 9 | Payment Return — Book Store 10 | 14 | 15 |
16 |
17 | {params.status_id === "1" && ( 18 |
19 |
20 | 21 |

Payment Success

22 |
23 |

24 | Your payment has been successfully accepted. 25 |

26 |

Thank you!

27 | 33 |
34 | )} 35 | 36 | {params.status_id !== "1" && ( 37 |
38 |
39 | 40 |

Payment Failed

41 |
42 |

43 | Your payment has been failed to be accepted. 44 |

45 |

Please try again!

46 | 52 |
53 | )} 54 |
55 |
56 | 57 | ); 58 | } 59 | -------------------------------------------------------------------------------- /resources/js/Components/BookBanner.jsx: -------------------------------------------------------------------------------- 1 | import { Swiper, SwiperSlide } from "swiper/react"; 2 | import { Navigation, Pagination } from "swiper/modules"; 3 | 4 | import "swiper/css"; 5 | import "swiper/css/navigation"; 6 | import "swiper/css/pagination"; 7 | 8 | export default function BookBanner() { 9 | return ( 10 |
11 | 20 | 21 |
22 |
23 |
24 |

25 | BOOK STORE 26 |

27 |

28 | FIND YOUR FAVOURITE 29 |

30 |

31 | BOOK HERE 32 |

33 |
34 |
35 | book store banner 1 36 |
37 |
38 | 39 |
40 |
41 |
42 |

43 | BOOK STORE 44 |

45 |

46 | FIND YOUR FAVOURITE 47 |

48 |

49 | BOOK HERE 50 |

51 |
52 |
53 | book store banner 2 54 |
55 |
56 |
57 |
58 | ); 59 | } 60 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/AuthenticatedSessionController.php: -------------------------------------------------------------------------------- 1 | Route::has('password.request'), 25 | 'status' => session('status'), 26 | ]); 27 | } 28 | 29 | /** 30 | * Handle an incoming authentication request. 31 | */ 32 | public function store(LoginRequest $request): RedirectResponse 33 | { 34 | $request->authenticate(); 35 | 36 | // associate session cart to logged in user if any 37 | if ($request->session()->has('carts')) { 38 | $cartIds = $request->session()->pull('carts'); 39 | 40 | foreach ($cartIds as $cartId) { 41 | $sessionCart = Cart::where('id', '=', $cartId)->first(); 42 | 43 | if ($sessionCart) { 44 | $userCart = $request->user()->carts()->where('book_id', '=', $sessionCart->book_id)->withoutCheckout()->first(); 45 | 46 | if ($userCart) { 47 | $newQuantity = $userCart->quantity + $sessionCart->quantity; 48 | $userCart->update(['quantity' => $newQuantity]); 49 | 50 | $sessionCart->deleteOrFail(); 51 | } else { 52 | $sessionCart->userOwner()->associate($request->user())->save(); 53 | } 54 | } 55 | } 56 | } 57 | 58 | $request->session()->regenerate(); 59 | 60 | return redirect()->intended(RouteServiceProvider::HOME); 61 | } 62 | 63 | /** 64 | * Destroy an authenticated session. 65 | */ 66 | public function destroy(Request $request): RedirectResponse 67 | { 68 | Auth::guard('web')->logout(); 69 | 70 | $request->session()->invalidate(); 71 | 72 | $request->session()->regenerateToken(); 73 | 74 | return redirect('/'); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /config/sanctum.php: -------------------------------------------------------------------------------- 1 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( 19 | '%s%s', 20 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', 21 | Sanctum::currentApplicationUrlWithPort() 22 | ))), 23 | 24 | /* 25 | |-------------------------------------------------------------------------- 26 | | Sanctum Guards 27 | |-------------------------------------------------------------------------- 28 | | 29 | | This array contains the authentication guards that will be checked when 30 | | Sanctum is trying to authenticate a request. If none of these guards 31 | | are able to authenticate the request, Sanctum will use the bearer 32 | | token that's present on an incoming request for authentication. 33 | | 34 | */ 35 | 36 | 'guard' => ['web'], 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Expiration Minutes 41 | |-------------------------------------------------------------------------- 42 | | 43 | | This value controls the number of minutes until an issued token will be 44 | | considered expired. If this value is null, personal access tokens do 45 | | not expire. This won't tweak the lifetime of first-party sessions. 46 | | 47 | */ 48 | 49 | 'expiration' => null, 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Sanctum Middleware 54 | |-------------------------------------------------------------------------- 55 | | 56 | | When authenticating your first-party SPA with Sanctum you may need to 57 | | customize some of the middleware Sanctum uses while processing the 58 | | request. You may change the middleware listed below as required. 59 | | 60 | */ 61 | 62 | 'middleware' => [ 63 | 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, 64 | 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, 65 | ], 66 | 67 | ]; 68 | -------------------------------------------------------------------------------- /resources/js/Pages/Cart/Partials/CartTableRow.jsx: -------------------------------------------------------------------------------- 1 | import { useState } from "react"; 2 | import { Table } from "flowbite-react"; 3 | import { Link } from "@inertiajs/react"; 4 | 5 | import CartQuantity from "@/Components/CartQuantity"; 6 | 7 | export default function CartTableRow({ cart }) { 8 | const [isDisabled, setIsDisabled] = useState(false); 9 | 10 | const price = cart.book_owner.price.toLocaleString("en-MY", { 11 | style: "currency", 12 | currency: "MYR", 13 | maximumFractionDigits: 2, 14 | }); 15 | 16 | const totalPrice = (cart.book_owner.price * cart.quantity).toLocaleString( 17 | "en-MY", 18 | { 19 | style: "currency", 20 | currency: "MYR", 21 | maximumFractionDigits: 2, 22 | } 23 | ); 24 | 25 | return ( 26 | 27 | 28 |
29 | 33 | 39 | 40 |
41 |

42 | {price} 43 |

44 | 48 |

49 | {cart.book_owner.title} 50 |

51 | 52 |
53 |
54 |
55 | 56 | 61 | 62 | 63 |

68 | {totalPrice} 69 |

70 |
71 |
72 | ); 73 | } 74 | -------------------------------------------------------------------------------- /app/Http/Requests/Auth/LoginRequest.php: -------------------------------------------------------------------------------- 1 | 26 | */ 27 | public function rules(): array 28 | { 29 | return [ 30 | 'email' => ['required', 'string', 'email'], 31 | 'password' => ['required', 'string'], 32 | ]; 33 | } 34 | 35 | /** 36 | * Attempt to authenticate the request's credentials. 37 | * 38 | * @throws \Illuminate\Validation\ValidationException 39 | */ 40 | public function authenticate(): void 41 | { 42 | $this->ensureIsNotRateLimited(); 43 | 44 | if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) { 45 | RateLimiter::hit($this->throttleKey()); 46 | 47 | throw ValidationException::withMessages([ 48 | 'email' => trans('auth.failed'), 49 | ]); 50 | } 51 | 52 | RateLimiter::clear($this->throttleKey()); 53 | } 54 | 55 | /** 56 | * Ensure the login request is not rate limited. 57 | * 58 | * @throws \Illuminate\Validation\ValidationException 59 | */ 60 | public function ensureIsNotRateLimited(): void 61 | { 62 | if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { 63 | return; 64 | } 65 | 66 | event(new Lockout($this)); 67 | 68 | $seconds = RateLimiter::availableIn($this->throttleKey()); 69 | 70 | throw ValidationException::withMessages([ 71 | 'email' => trans('auth.throttle', [ 72 | 'seconds' => $seconds, 73 | 'minutes' => ceil($seconds / 60), 74 | ]), 75 | ]); 76 | } 77 | 78 | /** 79 | * Get the rate limiting throttle key for the request. 80 | */ 81 | public function throttleKey(): string 82 | { 83 | return Str::transliterate(Str::lower($this->input('email')).'|'.$this->ip()); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/NewPasswordController.php: -------------------------------------------------------------------------------- 1 | $request->email, 26 | 'token' => $request->route('token'), 27 | ]); 28 | } 29 | 30 | /** 31 | * Handle an incoming new password request. 32 | * 33 | * @throws \Illuminate\Validation\ValidationException 34 | */ 35 | public function store(Request $request): RedirectResponse 36 | { 37 | $request->validate([ 38 | 'token' => 'required', 39 | 'email' => 'required|email', 40 | 'password' => ['required', 'confirmed', Rules\Password::defaults()], 41 | ]); 42 | 43 | // Here we will attempt to reset the user's password. If it is successful we 44 | // will update the password on an actual user model and persist it to the 45 | // database. Otherwise we will parse the error and return the response. 46 | $status = Password::reset( 47 | $request->only('email', 'password', 'password_confirmation', 'token'), 48 | function ($user) use ($request) { 49 | $user->forceFill([ 50 | 'password' => Hash::make($request->password), 51 | 'remember_token' => Str::random(60), 52 | ])->save(); 53 | 54 | event(new PasswordReset($user)); 55 | } 56 | ); 57 | 58 | // If the password was successfully reset, we will redirect the user back to 59 | // the application's home authenticated view. If there is an error we can 60 | // redirect them back to where they came from with their error message. 61 | if ($status == Password::PASSWORD_RESET) { 62 | return redirect()->route('login')->with('status', __($status)); 63 | } 64 | 65 | throw ValidationException::withMessages([ 66 | 'email' => [trans($status)], 67 | ]); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /resources/js/Pages/Auth/ForgotPassword.jsx: -------------------------------------------------------------------------------- 1 | import { Head, Link, useForm } from "@inertiajs/react"; 2 | import { Button, Card, TextInput } from "flowbite-react"; 3 | 4 | import MainLayout from "@/Layouts/MainLayout"; 5 | import InputError from "@/Components/InputError"; 6 | 7 | export default function ForgotPassword({ status }) { 8 | const { data, setData, post, processing, errors } = useForm({ 9 | email: "", 10 | }); 11 | 12 | const submit = (e) => { 13 | e.preventDefault(); 14 | 15 | post(route("password.email")); 16 | }; 17 | 18 | return ( 19 | 20 | 21 | 22 |
23 | 27 | book store logo 32 | Book Store 33 | 34 | 35 |
36 |
37 | Forgot your password? No problem. Just let us know your email 38 | address and we will email you a password reset link that will 39 | allow you to choose a new one. 40 |
41 | {status && ( 42 |
43 | {status} 44 |
45 | )} 46 |
47 | setData("email", e.target.value)} 55 | /> 56 | 57 |
58 | 61 |
62 | 63 |
64 |
65 |
66 |
67 | ); 68 | } 69 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DISK', '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 set up for each driver as an example of the required values. 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 | 'throw' => false, 37 | ], 38 | 39 | 'public' => [ 40 | 'driver' => 'local', 41 | 'root' => storage_path('app/public'), 42 | 'url' => env('APP_URL').'/storage', 43 | 'visibility' => 'public', 44 | 'throw' => false, 45 | ], 46 | 47 | 's3' => [ 48 | 'driver' => 's3', 49 | 'key' => env('AWS_ACCESS_KEY_ID'), 50 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 51 | 'region' => env('AWS_DEFAULT_REGION'), 52 | 'bucket' => env('AWS_BUCKET'), 53 | 'url' => env('AWS_URL'), 54 | 'endpoint' => env('AWS_ENDPOINT'), 55 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 56 | 'throw' => false, 57 | ], 58 | 59 | ], 60 | 61 | /* 62 | |-------------------------------------------------------------------------- 63 | | Symbolic Links 64 | |-------------------------------------------------------------------------- 65 | | 66 | | Here you may configure the symbolic links that will be created when the 67 | | `storage:link` Artisan command is executed. The array keys should be 68 | | the locations of the links and the values should be their targets. 69 | | 70 | */ 71 | 72 | 'links' => [ 73 | public_path('storage') => storage_path('app/public'), 74 | ], 75 | 76 | ]; 77 | -------------------------------------------------------------------------------- /resources/js/Pages/Book/Partials/AuthorFilter.jsx: -------------------------------------------------------------------------------- 1 | import { debounce } from "lodash"; 2 | import { Search } from "lucide-react"; 3 | import { useCallback, useEffect, useState } from "react"; 4 | import { Checkbox, Flowbite, Label, TextInput } from "flowbite-react"; 5 | 6 | import FilterLayout from "@/Layouts/FilterLayout"; 7 | import ScrollAreaLayout from "@/Layouts/ScrollAreaLayout"; 8 | import searchFilterTheme from "@/Pages/Book/Partials/searchBarTheme"; 9 | 10 | export default function AuthorFilter({ 11 | handleCheckbox, 12 | bookFilter, 13 | authors, 14 | isMobile, 15 | }) { 16 | const [authorList, setAuthorList] = useState(authors); 17 | const [searchVal, setSearchVal] = useState(""); 18 | 19 | const handleFilter = (search) => { 20 | if (search === "") { 21 | setAuthorList(authors); 22 | return; 23 | } 24 | 25 | const filterBySearch = authorList.filter((item) => { 26 | if (item.author.toLowerCase().includes(search.toLowerCase())) { 27 | return item; 28 | } 29 | }); 30 | 31 | setAuthorList(filterBySearch); 32 | }; 33 | 34 | const filterList = useCallback( 35 | debounce((search) => handleFilter(search), 500), 36 | [] 37 | ); 38 | 39 | useEffect(() => { 40 | filterList(searchVal); 41 | }, [searchVal]); 42 | 43 | return ( 44 | 45 |
46 |
47 | 48 | setSearchVal(e.target.value)} 54 | /> 55 | 56 |
57 | 58 | {authorList.map((author, index) => ( 59 |
60 | handleCheckbox(e, "author")} 65 | defaultChecked={ 66 | bookFilter.author && 67 | bookFilter.author.split(",").includes(author.author) 68 | } 69 | /> 70 | 76 |
77 | ))} 78 |
79 |
80 |
81 | ); 82 | } 83 | -------------------------------------------------------------------------------- /resources/js/Pages/Book/Partials/CategoryFilter.jsx: -------------------------------------------------------------------------------- 1 | import { debounce } from "lodash"; 2 | import { Search } from "lucide-react"; 3 | import { useCallback, useEffect, useState } from "react"; 4 | import { Checkbox, Flowbite, Label, TextInput } from "flowbite-react"; 5 | 6 | import FilterLayout from "@/Layouts/FilterLayout"; 7 | import ScrollAreaLayout from "@/Layouts/ScrollAreaLayout"; 8 | import searchFilterTheme from "@/Pages/Book/Partials/searchBarTheme"; 9 | 10 | export default function CategoryFilter({ 11 | handleCheckbox, 12 | bookFilter, 13 | categories, 14 | isMobile, 15 | }) { 16 | const [categoryList, setCategoryList] = useState(categories); 17 | const [searchVal, setSearchVal] = useState(""); 18 | 19 | const handleFilter = (search) => { 20 | if (search === "") { 21 | setCategoryList(categories); 22 | return; 23 | } 24 | 25 | const filterBySearch = categoryList.filter((item) => { 26 | if (item.name.toLowerCase().includes(search.toLowerCase())) { 27 | return item; 28 | } 29 | }); 30 | 31 | setCategoryList(filterBySearch); 32 | }; 33 | 34 | const filterList = useCallback( 35 | debounce((search) => handleFilter(search), 500), 36 | [] 37 | ); 38 | 39 | useEffect(() => { 40 | filterList(searchVal); 41 | }, [searchVal]); 42 | 43 | return ( 44 | 45 |
46 |
47 | 48 | setSearchVal(e.target.value)} 54 | /> 55 | 56 |
57 | 58 | {categoryList.map((category, index) => ( 59 |
60 | handleCheckbox(e, "category")} 65 | defaultChecked={ 66 | bookFilter.category && 67 | bookFilter.category.split(",").includes(category.name) 68 | } 69 | /> 70 | 76 |
77 | ))} 78 |
79 |
80 |
81 | ); 82 | } 83 | -------------------------------------------------------------------------------- /resources/js/Pages/Address/Index.jsx: -------------------------------------------------------------------------------- 1 | import { CheckCircle } from "lucide-react"; 2 | import { useEffect, useState } from "react"; 3 | import { Alert, Card } from "flowbite-react"; 4 | import { Head, usePage } from "@inertiajs/react"; 5 | 6 | import Address from "@/Components/Address"; 7 | import MainLayout from "@/Layouts/MainLayout"; 8 | import ProfileLayout from "@/Layouts/ProfileLayout"; 9 | import AddressForm from "@/Pages/Address/Partials/AddressForm"; 10 | 11 | export default function Index({ addresses, countries }) { 12 | const { flash } = usePage().props; 13 | const [alert, setAlert] = useState(false); 14 | 15 | useEffect(() => { 16 | if (flash.message) { 17 | setAlert(true); 18 | } 19 | }, [flash]); 20 | 21 | return ( 22 | 23 | 24 | 25 | 26 | {alert && ( 27 | setAlert(false)} 31 | > 32 | 33 |

34 | 35 | {flash.message} 36 |

37 |
38 |
39 | )} 40 | 41 |
42 |
43 |
44 |

45 | My Addresses 46 |

47 |

48 | These are your account's addresses details. 49 |

50 |
51 | 52 |
53 | 54 | {addresses.length > 0 && ( 55 |
56 | {addresses.map((address, index) => ( 57 |
63 | ))} 64 |
65 | )} 66 | 67 | {addresses.length < 1 && ( 68 |
69 |

70 | There are no addresses currently. 71 |

72 |
73 | )} 74 |
75 |
76 |
77 |
78 | ); 79 | } 80 | -------------------------------------------------------------------------------- /resources/js/Pages/Book/Partials/PublisherFilter.jsx: -------------------------------------------------------------------------------- 1 | import { debounce } from "lodash"; 2 | import { Search } from "lucide-react"; 3 | import { useCallback, useEffect, useState } from "react"; 4 | import { Checkbox, Flowbite, Label, TextInput } from "flowbite-react"; 5 | 6 | import FilterLayout from "@/Layouts/FilterLayout"; 7 | import ScrollAreaLayout from "@/Layouts/ScrollAreaLayout"; 8 | import searchFilterTheme from "@/Pages/Book/Partials/searchBarTheme"; 9 | 10 | export default function PublisherFilter({ 11 | handleCheckbox, 12 | bookFilter, 13 | publishers, 14 | isMobile, 15 | }) { 16 | const [publisherList, setPublisherList] = useState(publishers); 17 | const [searchVal, setSearchVal] = useState(""); 18 | 19 | const handleFilter = (search) => { 20 | if (search === "") { 21 | setPublisherList(publishers); 22 | return; 23 | } 24 | 25 | const filterBySearch = publisherList.filter((item) => { 26 | if (item.publisher.toLowerCase().includes(search.toLowerCase())) { 27 | return item; 28 | } 29 | }); 30 | 31 | setPublisherList(filterBySearch); 32 | }; 33 | 34 | const filterList = useCallback( 35 | debounce((search) => handleFilter(search), 500), 36 | [] 37 | ); 38 | 39 | useEffect(() => { 40 | filterList(searchVal); 41 | }, [searchVal]); 42 | 43 | return ( 44 | 45 |
46 |
47 | 48 | setSearchVal(e.target.value)} 54 | /> 55 | 56 |
57 | 58 | {publisherList.map((publisher, index) => ( 59 |
60 | handleCheckbox(e, "publisher")} 65 | defaultChecked={ 66 | bookFilter.publisher && 67 | bookFilter.publisher.split(",").includes(publisher.publisher) 68 | } 69 | /> 70 | 76 |
77 | ))} 78 |
79 |
80 |
81 | ); 82 | } 83 | -------------------------------------------------------------------------------- /resources/js/Components/SearchBar.jsx: -------------------------------------------------------------------------------- 1 | import { Search } from "lucide-react"; 2 | import { useForm } from "@inertiajs/react"; 3 | 4 | export default function SearchBar({ filters }) { 5 | const { data, setData, get, transform } = useForm({ 6 | search: filters?.search ?? "", 7 | }); 8 | 9 | const submit = (e) => { 10 | e.preventDefault(); 11 | 12 | transform((data) => ({ 13 | ...(data.search.length > 0 && { 14 | search: data.search, 15 | }), 16 | ...(filters?.type?.length > 0 && { 17 | type: filters.type, 18 | }), 19 | ...(filters?.category?.length > 0 && { 20 | category: filters.category, 21 | }), 22 | ...(filters?.author?.length > 0 && { 23 | author: filters.author, 24 | }), 25 | ...(filters?.publisher?.length > 0 && { 26 | publisher: filters.publisher, 27 | }), 28 | ...(filters?.price?.length > 0 && { 29 | price: filters.price, 30 | }), 31 | ...(filters?.sort?.length > 0 && { 32 | sort: filters.sort, 33 | }), 34 | })); 35 | 36 | get(route("book.index"), { 37 | preserveScroll: true, 38 | }); 39 | }; 40 | 41 | return ( 42 |
43 |
44 |
45 |
46 | 47 |
48 | setData("search", e.target.value)} 52 | placeholder="Search for Title, Author, Keyword or ISBN" 53 | className="block w-full border disabled:cursor-not-allowed disabled:opacity-50 bg-gray-50 border-gray-300 text-gray-900 focus:border-cyan-500 focus:ring-cyan-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 dark:focus:border-cyan-500 dark:focus:ring-cyan-500 p-2.5 text-sm pl-10 pr-20 rounded-full" 54 | /> 55 |
56 | 64 |
65 |
66 |
67 |
68 | ); 69 | } 70 | -------------------------------------------------------------------------------- /resources/js/Components/CartDrawer.jsx: -------------------------------------------------------------------------------- 1 | import { Button } from "flowbite-react"; 2 | import { router } from "@inertiajs/react"; 3 | import { ShoppingCart, X } from "lucide-react"; 4 | 5 | import CartItem from "@/Components/CartItem"; 6 | import CartTotal from "@/Components/CartTotal"; 7 | import { useCartDrawer } from "@/Hooks/useCartDrawer"; 8 | 9 | export default function CartDrawer({ carts }) { 10 | const drawer = useCartDrawer(); 11 | 12 | const continueBrowsing = () => { 13 | drawer.onClose(); 14 | router.get(route("book.index")); 15 | }; 16 | 17 | return ( 18 | <> 19 |
24 |
25 |
26 | 27 | Carts{" "} 28 | 29 | ( 30 | {carts 31 | .map((cart) => cart.quantity) 32 | .reduce( 33 | (totalQuantity, currentQuantity) => 34 | totalQuantity + currentQuantity, 35 | 0 36 | )} 37 | ) 38 | 39 |
40 | 48 |
49 | 50 | {carts.length > 0 && ( 51 |
52 | {carts.map((cart) => ( 53 | 54 | ))} 55 |
56 | )} 57 | 58 | {carts.length > 0 && } 59 | 60 | {carts.length < 1 && ( 61 |
62 |

63 | Your cart is currently empty. 64 |

65 | 66 |
67 | )} 68 |
69 | 70 |
76 | 77 | ); 78 | } 79 | -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | protected $middleware = [ 17 | // \App\Http\Middleware\TrustHosts::class, 18 | \App\Http\Middleware\TrustProxies::class, 19 | \Illuminate\Http\Middleware\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\View\Middleware\ShareErrorsFromSession::class, 37 | \App\Http\Middleware\VerifyCsrfToken::class, 38 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 39 | \App\Http\Middleware\HandleInertiaRequests::class, 40 | \Illuminate\Http\Middleware\AddLinkHeadersForPreloadedAssets::class, 41 | ], 42 | 43 | 'api' => [ 44 | // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, 45 | \Illuminate\Routing\Middleware\ThrottleRequests::class.':api', 46 | \Illuminate\Routing\Middleware\SubstituteBindings::class, 47 | ], 48 | ]; 49 | 50 | /** 51 | * The application's middleware aliases. 52 | * 53 | * Aliases may be used instead of class names to conveniently assign middleware to routes and groups. 54 | * 55 | * @var array 56 | */ 57 | protected $middlewareAliases = [ 58 | 'auth' => \App\Http\Middleware\Authenticate::class, 59 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 60 | 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, 61 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 62 | 'can' => \Illuminate\Auth\Middleware\Authorize::class, 63 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 64 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 65 | 'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, 66 | 'signed' => \App\Http\Middleware\ValidateSignature::class, 67 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 68 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 69 | ]; 70 | } 71 | -------------------------------------------------------------------------------- /resources/js/Components/Order.jsx: -------------------------------------------------------------------------------- 1 | import { Link, router } from "@inertiajs/react"; 2 | import { Button, Tooltip } from "flowbite-react"; 3 | import { Eye } from "lucide-react"; 4 | 5 | export default function Order({ order, first }) { 6 | const order_date = new Date(order.created_at).toLocaleDateString("en-MY", { 7 | year: "numeric", 8 | month: "short", 9 | day: "numeric", 10 | }); 11 | 12 | const order_total = order.total.toLocaleString("en-MY", { 13 | style: "currency", 14 | currency: "MYR", 15 | maximumFractionDigits: 2, 16 | }); 17 | 18 | return ( 19 |
20 | {!first &&
} 21 |
22 |
23 | 24 | 32 | 33 |
34 |
35 | 39 | Order ID: {order.order_no} 40 | 41 |

42 | {order.paid_at && ( 43 | 44 | PAID 45 | 46 | )} 47 | {!order.paid_at && ( 48 | 49 | UNPAID 50 | 51 | )} 52 |

53 |
54 |
55 |
56 |
57 |
Created
58 |
:
59 |
{order_date}
60 |
61 |
62 |
Collection Method
63 |
:
64 |
Shipping
65 |
66 |
67 |
Order Total
68 |
:
69 |
{order_total}
70 |
71 |
72 |
Payment Method
73 |
:
74 |
Online Banking
75 |
76 |
77 |
78 | ); 79 | } 80 | --------------------------------------------------------------------------------