├── database ├── .gitignore └── migrations │ ├── 2025_08_01_091059_create_courses_table.php │ ├── 2025_08_01_104300_create_sessions_table.php │ ├── 2025_08_01_093317_create_orders_table.php │ ├── 2025_08_01_093315_create_menu_items_table.php │ ├── 2025_08_03_131948_create_cache_table.php │ ├── 2025_08_14_132327_create_comments_table.php │ ├── 2025_08_01_091110_create_users_table.php │ ├── 2025_08_01_093318_create_order_items_table.php │ ├── 2025_08_01_093316_create_group_orders_table.php │ └── 2025_08_01_092437_create_stores_table.php ├── resources ├── css │ ├── app │ │ ├── _util.sass │ │ ├── _color.sass │ │ └── _container.sass │ ├── app.sass │ └── quasar-variables.sass ├── js │ ├── types │ │ ├── packages.d.ts │ │ ├── ziggy.d.ts │ │ ├── globals.d.ts │ │ └── index.d.ts │ ├── utils │ │ └── url.ts │ ├── composables │ │ ├── useInitials.ts │ │ └── useAppearance.ts │ ├── ssr.ts │ ├── components │ │ ├── OrderCard.vue │ │ ├── GroupOrderCard.vue │ │ ├── StoreCard.vue │ │ └── RandomDialog.vue │ ├── app.ts │ ├── pages │ │ ├── Login.vue │ │ ├── orders │ │ │ └── Index.vue │ │ ├── groupOrders │ │ │ ├── Index.vue │ │ │ └── Order.vue │ │ └── stores │ │ │ └── Index.vue │ └── layouts │ │ └── MainLayout.vue ├── assets │ └── images │ │ ├── background.webp │ │ └── placeholder.webp └── views │ └── app.blade.php ├── bootstrap ├── cache │ └── .gitignore ├── providers.php └── app.php ├── storage ├── logs │ └── .gitignore ├── app │ ├── private │ │ └── .gitignore │ ├── public │ │ └── .gitignore │ └── .gitignore └── framework │ ├── testing │ └── .gitignore │ ├── views │ └── .gitignore │ ├── cache │ ├── data │ │ └── .gitignore │ └── .gitignore │ ├── sessions │ └── .gitignore │ └── .gitignore ├── public ├── robots.txt ├── favicon.ico ├── apple-touch-icon.png ├── index.php └── .htaccess ├── .prettierignore ├── app ├── Http │ ├── Controllers │ │ ├── Controller.php │ │ ├── CommentController.php │ │ ├── Auth │ │ │ └── AuthenticatedSessionController.php │ │ ├── GroupOrderController.php │ │ ├── OrderController.php │ │ └── StoreController.php │ ├── Middleware │ │ ├── HandleAppearance.php │ │ └── HandleInertiaRequests.php │ └── Requests │ │ └── Auth │ │ └── LoginRequest.php ├── Providers │ └── AppServiceProvider.php └── Models │ ├── Comment.php │ ├── MenuItem.php │ ├── OrderItem.php │ ├── Course.php │ ├── Order.php │ ├── Store.php │ ├── User.php │ └── GroupOrder.php ├── .gitattributes ├── routes ├── console.php └── web.php ├── .editorconfig ├── .gitignore ├── .prettierrc ├── artisan ├── components.json ├── eslint.config.js ├── config ├── services.php ├── inertia.php ├── filesystems.php ├── cache.php ├── mail.php ├── queue.php ├── auth.php ├── app.php ├── logging.php ├── database.php └── session.php ├── phpunit.xml ├── .github └── workflows │ └── deploy.yml ├── .env.example ├── vite.config.ts ├── package.json ├── composer.json └── tsconfig.json /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /resources/css/app/_util.sass: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /storage/app/private/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /resources/js/types/packages.d.ts: -------------------------------------------------------------------------------- 1 | declare module '@fullcalendar/list'; 2 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !private/ 3 | !public/ 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /resources/css/app.sass: -------------------------------------------------------------------------------- 1 | @import ./app/container 2 | @import ./app/color 3 | @import ./app/util 4 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | resources/js/components/ui/* 2 | resources/js/ziggy.js 3 | resources/views/mail/* 4 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogeraabbccdd/PHP-Dinbendon/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /bootstrap/providers.php: -------------------------------------------------------------------------------- 1 | { 2 | window.open(url, '_blank'); 3 | }; 4 | -------------------------------------------------------------------------------- /resources/assets/images/background.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogeraabbccdd/PHP-Dinbendon/HEAD/resources/assets/images/background.webp -------------------------------------------------------------------------------- /resources/assets/images/placeholder.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogeraabbccdd/PHP-Dinbendon/HEAD/resources/assets/images/placeholder.webp -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 8 | })->purpose('Display an inspiring quote'); 9 | -------------------------------------------------------------------------------- /resources/js/types/ziggy.d.ts: -------------------------------------------------------------------------------- 1 | import { route } from 'ziggy-js'; 2 | 3 | declare global { 4 | let route: typeof route; 5 | } 6 | 7 | declare module 'vue' { 8 | interface ComponentCustomProperties { 9 | route: typeof route; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /resources/css/quasar-variables.sass: -------------------------------------------------------------------------------- 1 | $primary: #1976D2 2 | $secondary: #26A69A 3 | $accent: #9C27B0 4 | 5 | $dark: #1D1D1D 6 | 7 | $positive: #21BA45 8 | $negative: #C10015 9 | $info: #31CCEC 10 | $warning: #F2C037 11 | 12 | $img-content-background: rgba(0, 0, 0, .65) !default 13 | -------------------------------------------------------------------------------- /resources/css/app/_container.sass: -------------------------------------------------------------------------------- 1 | @use "quasar/src/css/variables" as q 2 | 3 | .container 4 | width: 100% 5 | padding-right: 0.75rem 6 | padding-left: 0.75rem 7 | margin-right: auto 8 | margin-left: auto 9 | 10 | @media (min-width: q.$breakpoint-md-min) 11 | .container 12 | max-width: 1440px 13 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 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 = 4 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.phpunit.cache 2 | /bootstrap/ssr 3 | /node_modules 4 | /public/build 5 | /public/hot 6 | /public/storage 7 | /storage/*.key 8 | /storage/pail 9 | /vendor 10 | .env 11 | .env.backup 12 | .env.production 13 | .phpactor.json 14 | .phpunit.result.cache 15 | Homestead.json 16 | Homestead.yaml 17 | npm-debug.log 18 | yarn-error.log 19 | /auth.json 20 | /.fleet 21 | /.idea 22 | /.nova 23 | /.vscode 24 | /.zed 25 | -------------------------------------------------------------------------------- /resources/js/composables/useInitials.ts: -------------------------------------------------------------------------------- 1 | export function getInitials(fullName?: string): string { 2 | if (!fullName) return ''; 3 | 4 | const names = fullName.trim().split(' '); 5 | 6 | if (names.length === 0) return ''; 7 | if (names.length === 1) return names[0].charAt(0).toUpperCase(); 8 | 9 | return `${names[0].charAt(0)}${names[names.length - 1].charAt(0)}`.toUpperCase(); 10 | } 11 | 12 | export function useInitials() { 13 | return { getInitials }; 14 | } 15 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "singleQuote": true, 4 | "singleAttributePerLine": false, 5 | "htmlWhitespaceSensitivity": "css", 6 | "printWidth": 150, 7 | "plugins": ["prettier-plugin-organize-imports"], 8 | "tailwindFunctions": ["clsx", "cn", "cva"], 9 | "tabWidth": 4, 10 | "overrides": [ 11 | { 12 | "files": "**/*.yml", 13 | "options": { 14 | "tabWidth": 2 15 | } 16 | } 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | handleCommand(new ArgvInput); 17 | 18 | exit($status); 19 | -------------------------------------------------------------------------------- /components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://shadcn-vue.com/schema.json", 3 | "style": "default", 4 | "tsx": true, 5 | "tailwind": { 6 | "config": "tailwind.config.js", 7 | "css": "resources/css/app.css", 8 | "baseColor": "neutral", 9 | "cssVariables": true, 10 | "prefix": "" 11 | }, 12 | "aliases": { 13 | "components": "@/components", 14 | "composables": "@/composables", 15 | "utils": "@/lib/utils", 16 | "ui": "@/components/ui", 17 | "lib": "@/lib" 18 | }, 19 | "iconLibrary": "lucide" 20 | } 21 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | handleRequest(Request::capture()); 21 | -------------------------------------------------------------------------------- /app/Http/Middleware/HandleAppearance.php: -------------------------------------------------------------------------------- 1 | cookie('appearance') ?? 'system'); 20 | 21 | return $next($request); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'; 2 | import prettier from 'eslint-config-prettier'; 3 | import vue from 'eslint-plugin-vue'; 4 | import vuePug from 'eslint-plugin-vue-pug'; 5 | 6 | export default defineConfigWithVueTs( 7 | vue.configs['flat/recommended'], 8 | vuePug.configs['flat/recommended'], 9 | vueTsConfigs.recommended, 10 | { 11 | ignores: ['vendor', 'node_modules', 'public', 'bootstrap/ssr'], 12 | }, 13 | { 14 | rules: { 15 | 'vue/multi-word-component-names': 'off', 16 | '@typescript-eslint/no-explicit-any': 'off', 17 | }, 18 | }, 19 | prettier, 20 | ); 21 | -------------------------------------------------------------------------------- /resources/js/types/globals.d.ts: -------------------------------------------------------------------------------- 1 | import { AppPageProps } from '@/types/index'; 2 | 3 | // Extend ImportMeta interface for Vite... 4 | declare module 'vite/client' { 5 | interface ImportMetaEnv { 6 | readonly VITE_APP_NAME: string; 7 | [key: string]: string | boolean | undefined; 8 | } 9 | 10 | interface ImportMeta { 11 | readonly env: ImportMetaEnv; 12 | readonly glob: (pattern: string) => Record Promise>; 13 | } 14 | } 15 | 16 | declare module '@inertiajs/core' { 17 | interface PageProps extends InertiaPageProps, AppPageProps {} 18 | } 19 | 20 | declare module 'vue' { 21 | interface ComponentCustomProperties { 22 | $inertia: typeof Router; 23 | $page: Page; 24 | $headManager: ReturnType; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /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 | # Handle X-XSRF-Token Header 13 | RewriteCond %{HTTP:x-xsrf-token} . 14 | RewriteRule .* - [E=HTTP_X_XSRF_TOKEN:%{HTTP:X-XSRF-Token}] 15 | 16 | # Redirect Trailing Slashes If Not A Folder... 17 | RewriteCond %{REQUEST_FILENAME} !-d 18 | RewriteCond %{REQUEST_URI} (.+)/$ 19 | RewriteRule ^ %1 [L,R=301] 20 | 21 | # Send Requests To Front Controller... 22 | RewriteCond %{REQUEST_FILENAME} !-d 23 | RewriteCond %{REQUEST_FILENAME} !-f 24 | RewriteRule ^ index.php [L] 25 | 26 | -------------------------------------------------------------------------------- /app/Http/Controllers/CommentController.php: -------------------------------------------------------------------------------- 1 | validate([ 13 | 'store_id' => 'required|exists:stores,id', 14 | 'rating' => 'required|integer|between:1,5', 15 | 'content' => 'required|string|max:200', 16 | ]); 17 | 18 | Comment::updateOrCreate( 19 | [ 20 | 'user_id' => $request->user()->id, 21 | 'store_id' => $validated['store_id'], 22 | ], 23 | [ 24 | 'rating' => $validated['rating'], 25 | 'content' => $validated['content'], 26 | ] 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /database/migrations/2025_08_01_091059_create_courses_table.php: -------------------------------------------------------------------------------- 1 | id()->comment('班級 ID'); 16 | $table->string('name')->comment('班級名稱'); 17 | $table->year('year')->comment('學年'); 18 | $table->tinyInteger('term')->unsigned()->comment('學期'); 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | */ 26 | public function down(): void 27 | { 28 | Schema::dropIfExists('courses'); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /app/Models/Comment.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | protected $fillable = [ 19 | 'user_id', 20 | 'store_id', 21 | 'rating', 22 | 'content', 23 | ]; 24 | 25 | /** 26 | * Get the user that owns the comment. 27 | */ 28 | public function user(): BelongsTo 29 | { 30 | return $this->belongsTo(User::class); 31 | } 32 | 33 | /** 34 | * Get the store that the comment belongs to. 35 | */ 36 | public function store(): BelongsTo 37 | { 38 | return $this->belongsTo(Store::class); 39 | } 40 | } -------------------------------------------------------------------------------- /database/migrations/2025_08_01_104300_create_sessions_table.php: -------------------------------------------------------------------------------- 1 | string('id')->primary(); 16 | $table->foreignId('user_id')->nullable()->index(); 17 | $table->string('ip_address', 45)->nullable(); 18 | $table->text('user_agent')->nullable(); 19 | $table->longText('payload'); 20 | $table->integer('last_activity')->index(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | */ 27 | public function down(): void 28 | { 29 | Schema::dropIfExists('sessions'); 30 | } 31 | }; 32 | -------------------------------------------------------------------------------- /database/migrations/2025_08_01_093317_create_orders_table.php: -------------------------------------------------------------------------------- 1 | id()->comment('個人訂單 ID'); 16 | $table->foreignId('group_order_id')->comment('所屬團購單 ID')->constrained()->cascadeOnDelete(); 17 | $table->foreignId('user_id')->comment('下訂學生 ID')->constrained()->cascadeOnDelete(); 18 | $table->decimal('total_price', 8, 2)->comment('個人訂單總金額'); 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | */ 26 | public function down(): void 27 | { 28 | Schema::dropIfExists('orders'); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | withRouting( 12 | web: __DIR__.'/../routes/web.php', 13 | commands: __DIR__.'/../routes/console.php', 14 | health: '/up', 15 | ) 16 | ->withMiddleware(function (Middleware $middleware) { 17 | $middleware->encryptCookies(except: ['appearance', 'sidebar_state']); 18 | 19 | $middleware->web(append: [ 20 | HandleAppearance::class, 21 | HandleInertiaRequests::class, 22 | AddLinkHeadersForPreloadedAssets::class, 23 | ]); 24 | }) 25 | ->withExceptions(function (Exceptions $exceptions) { 26 | // 27 | })->create(); 28 | -------------------------------------------------------------------------------- /database/migrations/2025_08_01_093315_create_menu_items_table.php: -------------------------------------------------------------------------------- 1 | id()->comment('菜單品項 ID'); 16 | $table->foreignId('store_id')->comment('所屬店家 ID')->constrained()->cascadeOnDelete(); 17 | $table->string('name')->comment('品項名稱'); 18 | $table->decimal('price', 8, 2)->comment('目前的價格'); 19 | $table->boolean('is_available')->default(true)->comment('目前是否供應中'); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | */ 27 | public function down(): void 28 | { 29 | Schema::dropIfExists('menu_items'); 30 | } 31 | }; 32 | -------------------------------------------------------------------------------- /database/migrations/2025_08_03_131948_create_cache_table.php: -------------------------------------------------------------------------------- 1 | string('key')->primary(); 16 | $table->mediumText('value'); 17 | $table->integer('expiration'); 18 | }); 19 | 20 | Schema::create('cache_locks', function (Blueprint $table) { 21 | $table->string('key')->primary(); 22 | $table->string('owner'); 23 | $table->integer('expiration'); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | */ 30 | public function down(): void 31 | { 32 | Schema::dropIfExists('cache'); 33 | Schema::dropIfExists('cache_locks'); 34 | } 35 | }; 36 | -------------------------------------------------------------------------------- /app/Models/MenuItem.php: -------------------------------------------------------------------------------- 1 | 'boolean', 27 | 'price' => 'float', 28 | ]; 29 | } 30 | 31 | public function store(): BelongsTo 32 | { 33 | return $this->belongsTo(Store::class); 34 | } 35 | 36 | /** 37 | * Get the order items for the menu item. 38 | */ 39 | public function orderItems(): HasMany 40 | { 41 | return $this->hasMany(OrderItem::class); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /database/migrations/2025_08_14_132327_create_comments_table.php: -------------------------------------------------------------------------------- 1 | id()->comment('評論 ID'); 16 | $table->foreignId('user_id')->comment('評論者 ID')->constrained()->cascadeOnDelete(); 17 | $table->foreignId('store_id')->comment('店家 ID')->constrained()->cascadeOnDelete(); 18 | $table->unsignedTinyInteger('rating')->comment('評分 (1-5)'); 19 | $table->text('content')->nullable()->comment('評論內容'); 20 | $table->timestamps(); 21 | 22 | $table->unique(['user_id', 'store_id']); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | */ 29 | public function down(): void 30 | { 31 | Schema::dropIfExists('comments'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /app/Models/OrderItem.php: -------------------------------------------------------------------------------- 1 | 'integer', 27 | 'price' => 'float', 28 | ]; 29 | } 30 | 31 | /** 32 | * Get the order that the item belongs to. 33 | */ 34 | public function order(): BelongsTo 35 | { 36 | return $this->belongsTo(Order::class); 37 | } 38 | 39 | /** 40 | * Get the menu item that the item belongs to. 41 | */ 42 | public function menuItem(): BelongsTo 43 | { 44 | return $this->belongsTo(MenuItem::class); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /database/migrations/2025_08_01_091110_create_users_table.php: -------------------------------------------------------------------------------- 1 | id()->comment('學生 ID'); 16 | $table->string('student_id')->unique()->comment('學號'); 17 | $table->string('password')->comment('密碼'); 18 | $table->string('name')->nullable()->comment('姓名'); 19 | $table->foreignId('course_id')->comment('所屬班級 ID')->constrained()->cascadeOnDelete(); 20 | $table->tinyInteger('seat_number')->unsigned()->comment('座號'); 21 | $table->boolean('enabled')->default(true)->comment('帳號是否啟用'); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | */ 29 | public function down(): void 30 | { 31 | Schema::dropIfExists('users'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /database/migrations/2025_08_01_093318_create_order_items_table.php: -------------------------------------------------------------------------------- 1 | id()->comment('訂單品項 ID'); 16 | $table->foreignId('order_id')->comment('所屬個人訂單 ID')->constrained()->cascadeOnDelete(); 17 | $table->foreignId('menu_item_id')->comment('所屬菜單品項 ID')->constrained()->cascadeOnDelete(); 18 | $table->string('name')->comment('品項名稱 (快照)'); 19 | $table->decimal('price', 8, 2)->comment('品項單價 (快照)'); 20 | $table->integer('quantity')->comment('購買數量'); 21 | $table->string('comment')->nullable()->comment('備註'); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | */ 29 | public function down(): void 30 | { 31 | Schema::dropIfExists('order_items'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'token' => env('POSTMARK_TOKEN'), 19 | ], 20 | 21 | 'ses' => [ 22 | 'key' => env('AWS_ACCESS_KEY_ID'), 23 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 24 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 25 | ], 26 | 27 | 'resend' => [ 28 | 'key' => env('RESEND_KEY'), 29 | ], 30 | 31 | 'slack' => [ 32 | 'notifications' => [ 33 | 'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'), 34 | 'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'), 35 | ], 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /database/migrations/2025_08_01_093316_create_group_orders_table.php: -------------------------------------------------------------------------------- 1 | id()->comment('團購單 ID'); 16 | $table->foreignId('course_id')->comment('開團班級 ID')->constrained()->cascadeOnDelete(); 17 | $table->foreignId('store_id')->comment('訂購店家 ID')->constrained()->cascadeOnDelete(); 18 | $table->foreignId('user_id')->comment('開團者 ID')->constrained()->cascadeOnDelete(); 19 | $table->enum('status', ['open', 'closed', 'ordered'])->default('open')->comment('團購單狀態'); 20 | $table->json('menu_snapshot')->comment('開團時的菜單快照'); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('group_orders'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /resources/js/ssr.ts: -------------------------------------------------------------------------------- 1 | import { createInertiaApp } from '@inertiajs/vue3'; 2 | import createServer from '@inertiajs/vue3/server'; 3 | import { renderToString } from 'vue/server-renderer'; 4 | import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; 5 | import { createSSRApp, DefineComponent, h } from 'vue'; 6 | import { ZiggyVue } from 'ziggy-js'; 7 | 8 | const appName = import.meta.env.VITE_APP_NAME || 'DinBenDon'; 9 | 10 | createServer((page) => 11 | createInertiaApp({ 12 | page, 13 | render: renderToString, 14 | title: (title) => title ? `${title} - ${appName}` : appName, 15 | resolve: resolvePage, 16 | setup: ({ App, props, plugin }) => 17 | createSSRApp({ render: () => h(App, props) }) 18 | .use(plugin) 19 | .use(ZiggyVue, { 20 | ...page.props.ziggy, 21 | location: new URL(page.props.ziggy.location), 22 | }), 23 | }), 24 | { cluster: true }, 25 | ); 26 | 27 | function resolvePage(name: string) { 28 | const pages = import.meta.glob('./pages/**/*.vue'); 29 | 30 | return resolvePageComponent(`./pages/${name}.vue`, pages); 31 | } 32 | -------------------------------------------------------------------------------- /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 | 33 | 34 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy 2 | 3 | on: 4 | push: 5 | branches: 6 | - laravel 7 | 8 | jobs: 9 | deploy: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | 14 | - name: Setup PHP 15 | uses: shivammathur/setup-php@v2 16 | with: 17 | php-version: '8.4' 18 | 19 | - name: Setup Bun 20 | uses: oven-sh/setup-bun@v2 21 | with: 22 | bun-version: latest 23 | 24 | - name: Cache Composer packages 25 | id: composer-cache 26 | uses: actions/cache@v4 27 | with: 28 | path: vendor 29 | key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} 30 | restore-keys: | 31 | ${{ runner.os }}-php- 32 | 33 | - name: Install dependencies (Composer) 34 | run: composer install --optimize-autoloader --no-dev 35 | 36 | - name: Install dependencies (Bun) 37 | run: bun install 38 | 39 | - name: Build frontend assets 40 | run: bun run build 41 | 42 | - name: Sync files 43 | uses: SamKirkland/FTP-Deploy-Action@4.0.0 44 | with: 45 | server: ${{ secrets.FTP_HOST }} 46 | username: ${{ secrets.FTP_USERNAME }} 47 | password: ${{ secrets.FTP_PASSWORD }} 48 | server-dir: / 49 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | APP_LOCALE=en 8 | APP_FALLBACK_LOCALE=en 9 | APP_FAKER_LOCALE=en_US 10 | 11 | APP_MAINTENANCE_DRIVER=file 12 | # APP_MAINTENANCE_STORE=database 13 | 14 | PHP_CLI_SERVER_WORKERS=4 15 | 16 | BCRYPT_ROUNDS=12 17 | 18 | LOG_CHANNEL=stack 19 | LOG_STACK=single 20 | LOG_DEPRECATIONS_CHANNEL=null 21 | LOG_LEVEL=debug 22 | 23 | DB_CONNECTION=sqlite 24 | # DB_HOST=127.0.0.1 25 | # DB_PORT=3306 26 | # DB_DATABASE=laravel 27 | # DB_USERNAME=root 28 | # DB_PASSWORD= 29 | 30 | SESSION_DRIVER=database 31 | SESSION_LIFETIME=120 32 | SESSION_ENCRYPT=false 33 | SESSION_PATH=/ 34 | SESSION_DOMAIN=null 35 | 36 | BROADCAST_CONNECTION=log 37 | FILESYSTEM_DISK=local 38 | QUEUE_CONNECTION=database 39 | 40 | CACHE_STORE=database 41 | # CACHE_PREFIX= 42 | 43 | MEMCACHED_HOST=127.0.0.1 44 | 45 | REDIS_CLIENT=phpredis 46 | REDIS_HOST=127.0.0.1 47 | REDIS_PASSWORD=null 48 | REDIS_PORT=6379 49 | 50 | MAIL_MAILER=log 51 | MAIL_SCHEME=null 52 | MAIL_HOST=127.0.0.1 53 | MAIL_PORT=2525 54 | MAIL_USERNAME=null 55 | MAIL_PASSWORD=null 56 | MAIL_FROM_ADDRESS="hello@example.com" 57 | MAIL_FROM_NAME="${APP_NAME}" 58 | 59 | AWS_ACCESS_KEY_ID= 60 | AWS_SECRET_ACCESS_KEY= 61 | AWS_DEFAULT_REGION=us-east-1 62 | AWS_BUCKET= 63 | AWS_USE_PATH_STYLE_ENDPOINT=false 64 | 65 | VITE_APP_NAME="${APP_NAME}" 66 | -------------------------------------------------------------------------------- /resources/js/components/OrderCard.vue: -------------------------------------------------------------------------------- 1 | 30 | 31 | 36 | -------------------------------------------------------------------------------- /database/migrations/2025_08_01_092437_create_stores_table.php: -------------------------------------------------------------------------------- 1 | id()->comment('店家 ID'); 16 | $table->string('name')->comment('店家名稱'); 17 | $table->string('address')->nullable()->comment('地址'); 18 | $table->string('google_map')->nullable()->comment('Google 地圖連結'); 19 | $table->string('facebook')->nullable()->comment('Facebook 頁面'); 20 | $table->string('instagram')->nullable()->comment('Instagram 頁面'); 21 | $table->string('business_hours')->nullable()->comment('營業時間'); 22 | $table->string('phone')->comment('聯絡電話'); 23 | $table->string('image')->comment('店家圖片 URL'); 24 | $table->string('delivery_conditions')->nullable()->comment('外送條件'); 25 | $table->boolean('is_closed')->default(true)->comment('是否歇業'); 26 | $table->timestamps(); 27 | }); 28 | } 29 | 30 | /** 31 | * Reverse the migrations. 32 | */ 33 | public function down(): void 34 | { 35 | Schema::dropIfExists('stores'); 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/AuthenticatedSessionController.php: -------------------------------------------------------------------------------- 1 | $request->session()->get('status'), 23 | ]); 24 | } 25 | 26 | /** 27 | * Handle an incoming authentication request. 28 | */ 29 | public function store(LoginRequest $request): RedirectResponse 30 | { 31 | $request->authenticate(); 32 | 33 | $request->session()->regenerate(); 34 | 35 | return redirect()->intended(route('groupOrders', absolute: false)); 36 | } 37 | 38 | /** 39 | * Destroy an authenticated session. 40 | */ 41 | public function destroy(Request $request): RedirectResponse 42 | { 43 | Auth::guard('web')->logout(); 44 | 45 | $request->session()->invalidate(); 46 | $request->session()->regenerateToken(); 47 | 48 | return redirect('/login'); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | import { fileURLToPath } from 'node:url' 2 | import { quasar } from '@quasar/vite-plugin'; 3 | import vue from '@vitejs/plugin-vue'; 4 | import laravel from 'laravel-vite-plugin'; 5 | import { defineConfig } from 'vite'; 6 | import checker from 'vite-plugin-checker' 7 | import vueDevTools from 'vite-plugin-vue-devtools' 8 | 9 | export default defineConfig({ 10 | base: './', 11 | plugins: [ 12 | vueDevTools({ 13 | appendTo: 'resources/js/app.ts' 14 | }), 15 | laravel({ 16 | input: ['resources/js/app.ts'], 17 | ssr: 'resources/js/ssr.ts', 18 | refresh: true, 19 | }), 20 | vue({ 21 | template: { 22 | transformAssetUrls: { 23 | base: null, 24 | includeAbsolute: false, 25 | }, 26 | }, 27 | }), 28 | quasar({ 29 | sassVariables: fileURLToPath(new URL('./resources/css/quasar-variables.sass', import.meta.url)), 30 | }), 31 | checker({ 32 | typescript: true, 33 | vueTsc: true, 34 | eslint: { 35 | lintCommand: 'eslint -c ./eslint.config.js "./resources/**/*.{js,mjs,cjs,ts,vue}"', 36 | useFlatConfig: true, 37 | }, 38 | }), 39 | ], 40 | resolve: { 41 | alias: { 42 | '$': fileURLToPath(new URL('./resources/assets', import.meta.url)), 43 | }, 44 | }, 45 | }); 46 | -------------------------------------------------------------------------------- /app/Models/Course.php: -------------------------------------------------------------------------------- 1 | */ 13 | use HasFactory; 14 | 15 | /** 16 | * The attributes that are mass assignable. 17 | * 18 | * @var list 19 | */ 20 | protected $fillable = [ 21 | ]; 22 | 23 | /** 24 | * Get the attributes that should be cast. 25 | * 26 | * @return array 27 | */ 28 | protected function casts(): array 29 | { 30 | return [ 31 | 'year' => 'integer', 32 | 'term' => 'integer', 33 | ]; 34 | } 35 | 36 | /** 37 | * The users that belong to the course. 38 | */ 39 | public function users(): HasMany 40 | { 41 | return $this->hasMany(User::class); 42 | } 43 | 44 | /** 45 | * Get the group orders for the course. 46 | */ 47 | public function groupOrders(): HasMany 48 | { 49 | return $this->hasMany(GroupOrder::class); 50 | } 51 | 52 | /** 53 | * Get the Taiwan year. 54 | */ 55 | protected function year(): Attribute 56 | { 57 | return Attribute::make( 58 | get: fn ($value) => $value - 1911 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/Http/Middleware/HandleInertiaRequests.php: -------------------------------------------------------------------------------- 1 | 37 | */ 38 | public function share(Request $request): array 39 | { 40 | [$message, $author] = str(Inspiring::quotes()->random())->explode('-'); 41 | 42 | return [ 43 | ...parent::share($request), 44 | 'name' => config('app.name', 'DinBenDon'), 45 | 'auth' => [ 46 | 'user' => $request->user(), 47 | ], 48 | 'ziggy' => [ 49 | ...(new Ziggy)->toArray(), 50 | 'location' => $request->url(), 51 | ], 52 | ]; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/Models/Order.php: -------------------------------------------------------------------------------- 1 | 'float', 26 | ]; 27 | } 28 | 29 | /** 30 | * Get the group order that the order belongs to. 31 | */ 32 | public function groupOrder(): BelongsTo 33 | { 34 | return $this->belongsTo(GroupOrder::class); 35 | } 36 | 37 | /** 38 | * Get the user that the order belongs to. 39 | */ 40 | public function user(): BelongsTo 41 | { 42 | return $this->belongsTo(User::class); 43 | } 44 | 45 | /** 46 | * Get the order items for the order. 47 | */ 48 | public function orderItems(): HasMany 49 | { 50 | return $this->hasMany(OrderItem::class); 51 | } 52 | 53 | /** 54 | * Get the store for the order. 55 | */ 56 | public function store(): HasOneThrough 57 | { 58 | return $this->hasOneThrough(Store::class, GroupOrder::class, 'id', 'id', 'group_order_id', 'store_id'); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /app/Models/Store.php: -------------------------------------------------------------------------------- 1 | 'boolean', 33 | 'rating_avg' => 'float', 34 | 'course_rating_avg' => 'float', 35 | ]; 36 | } 37 | 38 | protected function image(): Attribute 39 | { 40 | return Attribute::make( 41 | get: fn (?string $value) => $value ? asset($value) : null, 42 | ); 43 | } 44 | 45 | public function menuItems(): HasMany 46 | { 47 | return $this->hasMany(MenuItem::class); 48 | } 49 | 50 | /** 51 | * Get the group orders for the store. 52 | */ 53 | public function groupOrders(): HasMany 54 | { 55 | return $this->hasMany(GroupOrder::class); 56 | } 57 | 58 | public function comments(): HasMany 59 | { 60 | return $this->hasMany(Comment::class); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /config/inertia.php: -------------------------------------------------------------------------------- 1 | [ 19 | 'enabled' => true, 20 | 'url' => 'http://127.0.0.1:13714', 21 | // 'bundle' => base_path('bootstrap/ssr/ssr.mjs'), 22 | ], 23 | 24 | /* 25 | |-------------------------------------------------------------------------- 26 | | Testing 27 | |-------------------------------------------------------------------------- 28 | | 29 | | The values described here are used to locate Inertia components on the 30 | | filesystem. For instance, when using `assertInertia`, the assertion 31 | | attempts to locate the component as a file relative to the paths. 32 | | 33 | */ 34 | 35 | 'testing' => [ 36 | 'ensure_pages_exist' => true, 37 | 38 | 'page_paths' => [ 39 | resource_path('js/pages'), 40 | ], 41 | 42 | 'page_extensions' => [ 43 | 'js', 44 | 'jsx', 45 | 'svelte', 46 | 'ts', 47 | 'tsx', 48 | 'vue', 49 | ], 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /resources/views/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | ($appearance ?? 'system') == 'dark'])> 3 | 4 | 5 | 6 | 7 | {{-- Inline script to detect system dark mode preference and apply it immediately --}} 8 | 21 | 22 | {{ config('app.name', 'DinBenDon') }} 23 | 24 | 25 | 26 | 27 | 28 | @routes 29 | 30 | @if (app()->environment('local')) 31 | 32 | @endif 33 | 34 | @vite(['resources/js/app.ts', "resources/js/pages/{$page['component']}.vue"]) 35 | 36 | @inertiaHead 37 | 38 | 39 | @inertia 40 | 41 | 42 | -------------------------------------------------------------------------------- /resources/js/components/GroupOrderCard.vue: -------------------------------------------------------------------------------- 1 | 33 | 34 | 39 | -------------------------------------------------------------------------------- /resources/js/app.ts: -------------------------------------------------------------------------------- 1 | import { createInertiaApp } from '@inertiajs/vue3'; 2 | import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; 3 | import type { DefineComponent } from 'vue'; 4 | import { createApp, h } from 'vue'; 5 | import { ZiggyVue } from 'ziggy-js'; 6 | import { initializeTheme } from './composables/useAppearance'; 7 | 8 | import '@quasar/extras/material-icons/material-icons.css'; 9 | import '@quasar/extras/fontawesome-v6/fontawesome-v6.css' 10 | import '@quasar/extras/roboto-font/roboto-font.css'; 11 | import { Quasar, Notify, Dialog } from 'quasar'; 12 | import quasarIconSet from 'quasar/icon-set/svg-material-icons'; 13 | import quasarLang from 'quasar/lang/zh-TW'; 14 | import 'quasar/src/css/index.sass'; 15 | import 'quasar/src/css/flex-addon.sass' 16 | 17 | import '../css/app.sass'; 18 | 19 | const appName = import.meta.env.VITE_APP_NAME || 'DinBenDon'; 20 | 21 | const quasarConfig = { 22 | plugins: { 23 | Notify, 24 | Dialog 25 | }, 26 | lang: quasarLang, 27 | iconSet: quasarIconSet, 28 | extras: [ 29 | 'fontawesome-v6', 30 | ] 31 | } 32 | 33 | createInertiaApp({ 34 | title: (title) => (title ? `${title} - ${appName}` : appName), 35 | resolve: (name) => resolvePageComponent(`./pages/${name}.vue`, import.meta.glob('./pages/**/*.vue')), 36 | setup({ el, App, props, plugin }) { 37 | createApp({ render: () => h(App, props) }) 38 | .use(plugin) 39 | .use(ZiggyVue) 40 | .use(Quasar, quasarConfig) 41 | .mount(el); 42 | }, 43 | progress: { 44 | color: '#4B5563', 45 | }, 46 | }); 47 | 48 | // This will set light / dark mode on page load... 49 | initializeTheme(); 50 | -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | */ 14 | use HasFactory, Notifiable; 15 | 16 | /** 17 | * The attributes that are mass assignable. 18 | * 19 | * @var list 20 | */ 21 | protected $fillable = [ 22 | ]; 23 | 24 | /** 25 | * The attributes that should be hidden for serialization. 26 | * 27 | * @var list 28 | */ 29 | protected $hidden = [ 30 | 'password', 31 | 'student_id' 32 | ]; 33 | 34 | /** 35 | * Get the attributes that should be cast. 36 | * 37 | * @return array 38 | */ 39 | protected function casts(): array 40 | { 41 | return [ 42 | 'seat_number' => 'integer', 43 | 'enabled' => 'boolean', 44 | ]; 45 | } 46 | 47 | /** 48 | * Get the course that the user belongs to. 49 | */ 50 | public function course(): BelongsTo 51 | { 52 | return $this->belongsTo(Course::class); 53 | } 54 | 55 | /** 56 | * Get the group orders for the user. 57 | */ 58 | public function groupOrders(): HasMany 59 | { 60 | return $this->hasMany(GroupOrder::class); 61 | } 62 | 63 | /** 64 | * Get the orders for the user. 65 | */ 66 | public function orders(): HasMany 67 | { 68 | return $this->hasMany(Order::class); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "type": "module", 4 | "scripts": { 5 | "build": "vite build", 6 | "build:ssr": "vite build && vite build --ssr", 7 | "dev": "vite", 8 | "format": "prettier --write resources/", 9 | "format:check": "prettier --check resources/", 10 | "lint": "eslint . --fix" 11 | }, 12 | "devDependencies": { 13 | "@eslint/js": "^9.19.0", 14 | "@quasar/vite-plugin": "^1.10.0", 15 | "@types/lodash": "^4.17.20", 16 | "@types/node": "^22.13.5", 17 | "@vue/eslint-config-typescript": "^14.3.0", 18 | "@vue/language-plugin-pug": "^3.0.4", 19 | "eslint": "^9.17.0", 20 | "eslint-config-prettier": "^10.0.1", 21 | "eslint-plugin-vue": "^10.3.0", 22 | "eslint-plugin-vue-pug": "^1.0.0-alpha.3", 23 | "prettier": "^3.4.2", 24 | "prettier-plugin-organize-imports": "^4.1.0", 25 | "pug": "^3.0.3", 26 | "sass-embedded": "1.80.2", 27 | "typescript-eslint": "^8.23.0", 28 | "vite-plugin-checker": "^0.10.2", 29 | "vite-plugin-vue-devtools": "^8.0.0", 30 | "vue-tsc": "^2.2.4" 31 | }, 32 | "dependencies": { 33 | "@fullcalendar/core": "^6.1.19", 34 | "@fullcalendar/list": "^6.1.19", 35 | "@fullcalendar/vue3": "^6.1.19", 36 | "@inertiajs/vue3": "^2.0.0", 37 | "@quasar/extras": "^1.17.0", 38 | "@vee-validate/zod": "^4.15.1", 39 | "@vitejs/plugin-vue": "^6.0.0", 40 | "@vueuse/core": "^12.8.2", 41 | "concurrently": "^9.0.1", 42 | "laravel-vite-plugin": "^2.0.0", 43 | "lodash": "^4.17.21", 44 | "quasar": "^2.18.2", 45 | "typescript": "^5.2.2", 46 | "vee-validate": "^4.15.1", 47 | "vite": "^7.0.4", 48 | "vue": "^3.5.13", 49 | "vue-github-button": "^3.1.3", 50 | "xlsx": "^0.18.5", 51 | "ziggy-js": "^2.4.2", 52 | "zod": "^4.0.14" 53 | }, 54 | "optionalDependencies": { 55 | "@rollup/rollup-linux-x64-gnu": "4.9.5" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/Models/GroupOrder.php: -------------------------------------------------------------------------------- 1 | 'string', 28 | ]; 29 | } 30 | 31 | public function store(): BelongsTo 32 | { 33 | return $this->belongsTo(Store::class); 34 | } 35 | 36 | public function user(): BelongsTo 37 | { 38 | return $this->belongsTo(User::class); 39 | } 40 | 41 | /** 42 | * Get the course that the group order belongs to. 43 | */ 44 | public function course(): BelongsTo 45 | { 46 | return $this->belongsTo(Course::class); 47 | } 48 | 49 | /** 50 | * Get the orders for the group order. 51 | */ 52 | public function orders(): HasMany 53 | { 54 | return $this->hasMany(Order::class); 55 | } 56 | 57 | /** 58 | * Get all of the order items for the group order. 59 | */ 60 | public function orderItems(): HasManyThrough 61 | { 62 | return $this->hasManyThrough(OrderItem::class, Order::class); 63 | } 64 | 65 | /** 66 | * Interact with the group order's menu snapshot. 67 | * 68 | */ 69 | protected function menuSnapshot(): Attribute 70 | { 71 | return Attribute::make( 72 | get: function (?string $value) { 73 | if ($value === null) { 74 | return []; 75 | } 76 | $menu = json_decode($value, true); 77 | 78 | return array_map(function ($item) { 79 | if (isset($item['price'])) { 80 | $item['price'] = (float) $item['price']; 81 | } 82 | 83 | return $item; 84 | }, $menu); 85 | }, 86 | set: fn ($value) => json_encode($value), 87 | ); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /routes/web.php: -------------------------------------------------------------------------------- 1 | route('stores'); 14 | } else { 15 | return redirect()->route('login'); 16 | } 17 | })->name('home'); 18 | 19 | Route::middleware('guest')->group(function () { 20 | Route::get('login', [AuthenticatedSessionController::class, 'create']) 21 | ->name('login'); 22 | 23 | Route::post('login', [AuthenticatedSessionController::class, 'store']); 24 | }); 25 | 26 | Route::middleware('auth')->group(function () { 27 | Route::post('logout', [AuthenticatedSessionController::class, 'destroy']) 28 | ->name('logout'); 29 | 30 | Route::get('stores', [StoreController::class, 'index']) 31 | ->name('stores'); 32 | 33 | Route::get('stores/new', [StoreController::class, 'createForm']) 34 | ->name('stores.new'); 35 | 36 | Route::get('stores/{id}', [StoreController::class, 'show']) 37 | ->name('stores.show'); 38 | 39 | Route::get('stores/{id}/edit', [StoreController::class, 'editForm']) 40 | ->name('stores.edit'); 41 | 42 | Route::post('stores', [StoreController::class, 'editFormSubmit']) 43 | ->name('stores.edit.submit'); 44 | 45 | Route::get('group-orders', [GroupOrderController::class, 'index']) 46 | ->name('groupOrders'); 47 | 48 | Route::post('group-orders', [GroupOrderController::class, 'create']) 49 | ->name('groupOrders.create'); 50 | 51 | Route::get('group-orders/{id}', [GroupOrderController::class, 'show']) 52 | ->name('groupOrders.show'); 53 | 54 | Route::post('group-orders/{id}', [GroupOrderController::class, 'update']) 55 | ->name('groupOrders.update'); 56 | 57 | Route::get('group-orders/{id}/order', [OrderController::class, 'showForm']) 58 | ->name('groupOrders.order'); 59 | 60 | Route::post('group-orders/{id}/order', [OrderController::class, 'create']) 61 | ->name('groupOrders.order.create'); 62 | 63 | Route::get('orders', [OrderController::class, 'index']) 64 | ->name('orders'); 65 | 66 | Route::delete('orders/{id}', [OrderController::class, 'cancel']) 67 | ->name('orders.cancel'); 68 | 69 | Route::post('comments', [CommentController::class, 'submit']) 70 | ->name('comments.submit'); 71 | }); 72 | -------------------------------------------------------------------------------- /app/Http/Requests/Auth/LoginRequest.php: -------------------------------------------------------------------------------- 1 | |string> 26 | */ 27 | public function rules(): array 28 | { 29 | return [ 30 | 'student_id' => ['required', 'string'], 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('student_id', 'password'))) { 45 | RateLimiter::hit($this->throttleKey()); 46 | 47 | throw ValidationException::withMessages([ 48 | 'student_id' => '學號或密碼錯誤', 49 | ]); 50 | } 51 | 52 | if (! Auth::user()->enabled) { 53 | Auth::logout(); 54 | 55 | throw ValidationException::withMessages([ 56 | 'student_id' => '此帳號已被停用。', 57 | ]); 58 | } 59 | 60 | RateLimiter::clear($this->throttleKey()); 61 | } 62 | 63 | /** 64 | * Ensure the login request is not rate limited. 65 | * 66 | * @throws \Illuminate\Validation\ValidationException 67 | */ 68 | public function ensureIsNotRateLimited(): void 69 | { 70 | if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) { 71 | return; 72 | } 73 | 74 | event(new Lockout($this)); 75 | 76 | $seconds = RateLimiter::availableIn($this->throttleKey()); 77 | 78 | throw ValidationException::withMessages([ 79 | 'student_id' => '太多嘗試登入,請在 '.ceil($seconds / 60).' 分 '.$seconds.' 秒後再試。', 80 | ]); 81 | } 82 | 83 | /** 84 | * Get the rate limiting throttle key for the request. 85 | */ 86 | public function throttleKey(): string 87 | { 88 | return Str::transliterate(Str::lower($this->string('user_id')).'|'.$this->ip()); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /resources/js/composables/useAppearance.ts: -------------------------------------------------------------------------------- 1 | import { onMounted, ref } from 'vue'; 2 | 3 | type Appearance = 'light' | 'dark' | 'system'; 4 | 5 | export function updateTheme(value: Appearance) { 6 | if (typeof window === 'undefined') { 7 | return; 8 | } 9 | 10 | if (value === 'system') { 11 | const mediaQueryList = window.matchMedia('(prefers-color-scheme: dark)'); 12 | const systemTheme = mediaQueryList.matches ? 'dark' : 'light'; 13 | 14 | document.documentElement.classList.toggle('dark', systemTheme === 'dark'); 15 | } else { 16 | document.documentElement.classList.toggle('dark', value === 'dark'); 17 | } 18 | } 19 | 20 | const setCookie = (name: string, value: string, days = 365) => { 21 | if (typeof document === 'undefined') { 22 | return; 23 | } 24 | 25 | const maxAge = days * 24 * 60 * 60; 26 | 27 | document.cookie = `${name}=${value};path=/;max-age=${maxAge};SameSite=Lax`; 28 | }; 29 | 30 | const mediaQuery = () => { 31 | if (typeof window === 'undefined') { 32 | return null; 33 | } 34 | 35 | return window.matchMedia('(prefers-color-scheme: dark)'); 36 | }; 37 | 38 | const getStoredAppearance = () => { 39 | if (typeof window === 'undefined') { 40 | return null; 41 | } 42 | 43 | return localStorage.getItem('appearance') as Appearance | null; 44 | }; 45 | 46 | const handleSystemThemeChange = () => { 47 | const currentAppearance = getStoredAppearance(); 48 | 49 | updateTheme(currentAppearance || 'system'); 50 | }; 51 | 52 | export function initializeTheme() { 53 | if (typeof window === 'undefined') { 54 | return; 55 | } 56 | 57 | // Initialize theme from saved preference or default to system... 58 | const savedAppearance = getStoredAppearance(); 59 | updateTheme(savedAppearance || 'system'); 60 | 61 | // Set up system theme change listener... 62 | mediaQuery()?.addEventListener('change', handleSystemThemeChange); 63 | } 64 | 65 | const appearance = ref('system'); 66 | 67 | export function useAppearance() { 68 | onMounted(() => { 69 | const savedAppearance = localStorage.getItem('appearance') as Appearance | null; 70 | 71 | if (savedAppearance) { 72 | appearance.value = savedAppearance; 73 | } 74 | }); 75 | 76 | function updateAppearance(value: Appearance) { 77 | appearance.value = value; 78 | 79 | // Store in localStorage for client-side persistence... 80 | localStorage.setItem('appearance', value); 81 | 82 | // Store in cookie for SSR... 83 | setCookie('appearance', value); 84 | 85 | updateTheme(value); 86 | } 87 | 88 | return { 89 | appearance, 90 | updateAppearance, 91 | }; 92 | } 93 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DISK', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Filesystem Disks 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Below you may configure as many filesystem disks as necessary, and you 24 | | may even configure multiple disks for the same driver. Examples for 25 | | most supported storage drivers are configured here for reference. 26 | | 27 | | Supported drivers: "local", "ftp", "sftp", "s3" 28 | | 29 | */ 30 | 31 | 'disks' => [ 32 | 33 | 'local' => [ 34 | 'driver' => 'local', 35 | 'root' => storage_path('app/private'), 36 | 'serve' => true, 37 | 'throw' => false, 38 | 'report' => false, 39 | ], 40 | 41 | 'public' => [ 42 | 'driver' => 'local', 43 | 'root' => storage_path('app/public'), 44 | 'url' => env('APP_URL').'/storage', 45 | 'visibility' => 'public', 46 | 'throw' => false, 47 | 'report' => false, 48 | ], 49 | 50 | 's3' => [ 51 | 'driver' => 's3', 52 | 'key' => env('AWS_ACCESS_KEY_ID'), 53 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 54 | 'region' => env('AWS_DEFAULT_REGION'), 55 | 'bucket' => env('AWS_BUCKET'), 56 | 'url' => env('AWS_URL'), 57 | 'endpoint' => env('AWS_ENDPOINT'), 58 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 59 | 'throw' => false, 60 | 'report' => false, 61 | ], 62 | 63 | ], 64 | 65 | /* 66 | |-------------------------------------------------------------------------- 67 | | Symbolic Links 68 | |-------------------------------------------------------------------------- 69 | | 70 | | Here you may configure the symbolic links that will be created when the 71 | | `storage:link` Artisan command is executed. The array keys should be 72 | | the locations of the links and the values should be their targets. 73 | | 74 | */ 75 | 76 | 'links' => [ 77 | public_path('storage') => storage_path('app/public'), 78 | ], 79 | 80 | ]; 81 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://getcomposer.org/schema.json", 3 | "name": "laravel/vue-starter-kit", 4 | "type": "project", 5 | "description": "The skeleton application for the Laravel framework.", 6 | "keywords": [ 7 | "laravel", 8 | "framework" 9 | ], 10 | "license": "MIT", 11 | "require": { 12 | "php": "^8.2", 13 | "inertiajs/inertia-laravel": "^2.0", 14 | "laravel/framework": "^12.0", 15 | "laravel/tinker": "^2.10.1", 16 | "tightenco/ziggy": "^2.4" 17 | }, 18 | "require-dev": { 19 | "fakerphp/faker": "^1.23", 20 | "laravel/pail": "^1.2.2", 21 | "laravel/pint": "^1.18", 22 | "laravel/sail": "^1.41", 23 | "mockery/mockery": "^1.6", 24 | "nunomaduro/collision": "^8.6", 25 | "pestphp/pest": "^3.8", 26 | "pestphp/pest-plugin-laravel": "^3.2" 27 | }, 28 | "autoload": { 29 | "psr-4": { 30 | "App\\": "app/", 31 | "Database\\Factories\\": "database/factories/", 32 | "Database\\Seeders\\": "database/seeders/" 33 | } 34 | }, 35 | "autoload-dev": { 36 | "psr-4": { 37 | "Tests\\": "tests/" 38 | } 39 | }, 40 | "scripts": { 41 | "post-autoload-dump": [ 42 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 43 | "@php artisan package:discover --ansi" 44 | ], 45 | "post-update-cmd": [ 46 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force" 47 | ], 48 | "post-root-package-install": [ 49 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 50 | ], 51 | "post-create-project-cmd": [ 52 | "@php artisan key:generate --ansi", 53 | "@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"", 54 | "@php artisan migrate --graceful --ansi" 55 | ], 56 | "dev": [ 57 | "Composer\\Config::disableProcessTimeout", 58 | "bunx --bun concurrently -c \"#93c5fd,#c4b5fd,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"bun run dev\" --names='server,queue,vite'" 59 | ], 60 | "dev:ssr": [ 61 | "bun run build:ssr", 62 | "Composer\\Config::disableProcessTimeout", 63 | "bunx --bun concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"php artisan inertia:start-ssr\" --names=server,queue,logs,ssr --kill-others" 64 | ], 65 | "test": [ 66 | "@php artisan config:clear --ansi", 67 | "@php artisan test" 68 | ] 69 | }, 70 | "extra": { 71 | "laravel": { 72 | "dont-discover": [] 73 | } 74 | }, 75 | "config": { 76 | "optimize-autoloader": true, 77 | "preferred-install": "dist", 78 | "sort-packages": true, 79 | "allow-plugins": { 80 | "pestphp/pest-plugin": true, 81 | "php-http/discovery": true 82 | } 83 | }, 84 | "minimum-stability": "stable", 85 | "prefer-stable": true 86 | } 87 | -------------------------------------------------------------------------------- /resources/js/pages/Login.vue: -------------------------------------------------------------------------------- 1 | 34 | 35 | 80 | -------------------------------------------------------------------------------- /resources/js/components/StoreCard.vue: -------------------------------------------------------------------------------- 1 | 71 | 72 | 77 | 78 | 85 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_STORE', 'database'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | | Supported drivers: "array", "database", "file", "memcached", 30 | | "redis", "dynamodb", "octane", "null" 31 | | 32 | */ 33 | 34 | 'stores' => [ 35 | 36 | 'array' => [ 37 | 'driver' => 'array', 38 | 'serialize' => false, 39 | ], 40 | 41 | 'database' => [ 42 | 'driver' => 'database', 43 | 'connection' => env('DB_CACHE_CONNECTION'), 44 | 'table' => env('DB_CACHE_TABLE', 'cache'), 45 | 'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'), 46 | 'lock_table' => env('DB_CACHE_LOCK_TABLE'), 47 | ], 48 | 49 | 'file' => [ 50 | 'driver' => 'file', 51 | 'path' => storage_path('framework/cache/data'), 52 | 'lock_path' => storage_path('framework/cache/data'), 53 | ], 54 | 55 | 'memcached' => [ 56 | 'driver' => 'memcached', 57 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 58 | 'sasl' => [ 59 | env('MEMCACHED_USERNAME'), 60 | env('MEMCACHED_PASSWORD'), 61 | ], 62 | 'options' => [ 63 | // Memcached::OPT_CONNECT_TIMEOUT => 2000, 64 | ], 65 | 'servers' => [ 66 | [ 67 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 68 | 'port' => env('MEMCACHED_PORT', 11211), 69 | 'weight' => 100, 70 | ], 71 | ], 72 | ], 73 | 74 | 'redis' => [ 75 | 'driver' => 'redis', 76 | 'connection' => env('REDIS_CACHE_CONNECTION', 'cache'), 77 | 'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'), 78 | ], 79 | 80 | 'dynamodb' => [ 81 | 'driver' => 'dynamodb', 82 | 'key' => env('AWS_ACCESS_KEY_ID'), 83 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 84 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 85 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 86 | 'endpoint' => env('DYNAMODB_ENDPOINT'), 87 | ], 88 | 89 | 'octane' => [ 90 | 'driver' => 'octane', 91 | ], 92 | 93 | ], 94 | 95 | /* 96 | |-------------------------------------------------------------------------- 97 | | Cache Key Prefix 98 | |-------------------------------------------------------------------------- 99 | | 100 | | When utilizing the APC, database, memcached, Redis, and DynamoDB cache 101 | | stores, there might be other applications using the same cache. For 102 | | that reason, you may prefix every cache key to avoid collisions. 103 | | 104 | */ 105 | 106 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'), 107 | 108 | ]; 109 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_MAILER', 'log'), 18 | 19 | /* 20 | |-------------------------------------------------------------------------- 21 | | Mailer Configurations 22 | |-------------------------------------------------------------------------- 23 | | 24 | | Here you may configure all of the mailers used by your application plus 25 | | their respective settings. Several examples have been configured for 26 | | you and you are free to add your own as your application requires. 27 | | 28 | | Laravel supports a variety of mail "transport" drivers that can be used 29 | | when delivering an email. You may specify which one you're using for 30 | | your mailers below. You may also add additional mailers if needed. 31 | | 32 | | Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2", 33 | | "postmark", "resend", "log", "array", 34 | | "failover", "roundrobin" 35 | | 36 | */ 37 | 38 | 'mailers' => [ 39 | 40 | 'smtp' => [ 41 | 'transport' => 'smtp', 42 | 'scheme' => env('MAIL_SCHEME'), 43 | 'url' => env('MAIL_URL'), 44 | 'host' => env('MAIL_HOST', '127.0.0.1'), 45 | 'port' => env('MAIL_PORT', 2525), 46 | 'username' => env('MAIL_USERNAME'), 47 | 'password' => env('MAIL_PASSWORD'), 48 | 'timeout' => null, 49 | 'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)), 50 | ], 51 | 52 | 'ses' => [ 53 | 'transport' => 'ses', 54 | ], 55 | 56 | 'postmark' => [ 57 | 'transport' => 'postmark', 58 | // 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'), 59 | // 'client' => [ 60 | // 'timeout' => 5, 61 | // ], 62 | ], 63 | 64 | 'resend' => [ 65 | 'transport' => 'resend', 66 | ], 67 | 68 | 'sendmail' => [ 69 | 'transport' => 'sendmail', 70 | 'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'), 71 | ], 72 | 73 | 'log' => [ 74 | 'transport' => 'log', 75 | 'channel' => env('MAIL_LOG_CHANNEL'), 76 | ], 77 | 78 | 'array' => [ 79 | 'transport' => 'array', 80 | ], 81 | 82 | 'failover' => [ 83 | 'transport' => 'failover', 84 | 'mailers' => [ 85 | 'smtp', 86 | 'log', 87 | ], 88 | ], 89 | 90 | 'roundrobin' => [ 91 | 'transport' => 'roundrobin', 92 | 'mailers' => [ 93 | 'ses', 94 | 'postmark', 95 | ], 96 | ], 97 | 98 | ], 99 | 100 | /* 101 | |-------------------------------------------------------------------------- 102 | | Global "From" Address 103 | |-------------------------------------------------------------------------- 104 | | 105 | | You may wish for all emails sent by your application to be sent from 106 | | the same address. Here you may specify a name and address that is 107 | | used globally for all emails that are sent by your application. 108 | | 109 | */ 110 | 111 | 'from' => [ 112 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 113 | 'name' => env('MAIL_FROM_NAME', 'Example'), 114 | ], 115 | 116 | ]; 117 | -------------------------------------------------------------------------------- /resources/js/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from 'ziggy-js'; 2 | 3 | export type AppPageProps = Record> = T & { 4 | name: string; 5 | ziggy: Config & { location: string }; 6 | }; 7 | 8 | export interface AuthPageProps extends AppPageProps { 9 | auth: Auth; 10 | } 11 | 12 | export interface StorePageProps extends AuthPageProps { 13 | stores: Store[]; 14 | } 15 | 16 | export interface StoreShowPageProps extends AuthPageProps { 17 | store: Store; 18 | menuItems: MenuItem[]; 19 | groupOrders: GroupOrderBase[]; 20 | myComment: Comment; 21 | comments: Comment[]; 22 | } 23 | 24 | export interface StoreEditPageProps extends AuthPageProps { 25 | store?: Store; 26 | menuItems?: MenuItem[]; 27 | } 28 | 29 | export interface GroupOrderPageProps extends AuthPageProps { 30 | groupOrders: GroupOrder[]; 31 | } 32 | 33 | export interface GroupOrderShowPageProps extends AuthPageProps { 34 | groupOrder: GroupOrderWithMenuSnapshot; 35 | orders: Order[]; 36 | myOrder: Order | null; 37 | } 38 | 39 | export interface GroupOrdersOrderPageProps extends AuthPageProps { 40 | groupOrder: GroupOrderWithMenuSnapshot; 41 | myOrder: Order | null; 42 | } 43 | 44 | export interface OrderPageProps extends AuthPageProps { 45 | orders: Order[]; 46 | } 47 | 48 | export interface Auth { 49 | user?: User 50 | } 51 | 52 | export interface User { 53 | id: number; 54 | student_id: string; 55 | name: string; 56 | course_id: number; 57 | seat_number: number; 58 | enabled: number; 59 | created_at: string; 60 | updated_at: string; 61 | course?: Course; 62 | } 63 | 64 | export interface Store { 65 | id: number; 66 | name: string; 67 | address: string; 68 | google_map: string; 69 | facebook: string; 70 | instagram: string; 71 | business_hours: string; 72 | delivery_conditions: string; 73 | phone: string; 74 | image: string; 75 | is_closed: boolean; 76 | created_at: string; 77 | updated_at: string; 78 | ordered_group_orders_count: number; 79 | course_ordered_group_orders_count: number; 80 | rating_avg?: number | null; 81 | rating_count?: number | null; 82 | course_rating_avg?: number | null; 83 | course_rating_count?: number | null; 84 | } 85 | 86 | export interface MenuItem { 87 | id: number; 88 | store_id: number; 89 | name: string; 90 | price: number; 91 | is_available: boolean; 92 | created_at: string; 93 | updated_at: string; 94 | total_ordered_count?: number; 95 | course_ordered_count?: number; 96 | } 97 | 98 | export type GroupOrderStatus = 'open' | 'closed' | 'ordered'; 99 | export interface GroupOrderBase { 100 | id: number; 101 | store_id: number; 102 | user_id: number; 103 | status: GroupOrderStatus; 104 | store: Store; 105 | user: User; 106 | created_at: string; 107 | updated_at: string; 108 | } 109 | 110 | export interface GroupOrderWithStore extends GroupOrderBase { 111 | store: Store; 112 | } 113 | 114 | export interface GroupOrderWithMenuSnapshot extends GroupOrderBase { 115 | menu_snapshot: MenuItem[]; 116 | } 117 | 118 | export interface Order { 119 | id: number; 120 | total_price: number; 121 | user: User; 122 | order_items: OrderItem[]; 123 | created_at: string; 124 | updated_at: string; 125 | group_order?: GroupOrderWithStore; 126 | } 127 | 128 | export interface OrderItem { 129 | id: number; 130 | order_id: number; 131 | menu_item_id: number; 132 | name: string; 133 | price: number; 134 | quantity: number; 135 | comment: string; 136 | } 137 | 138 | export interface Course { 139 | id: number; 140 | year: number; 141 | term: number; 142 | name: string; 143 | created_at: string; 144 | updated_at: string; 145 | } 146 | 147 | export interface Comment { 148 | id: number; 149 | store_id: number; 150 | rating: number; 151 | content: string; 152 | created_at: string; 153 | updated_at: string; 154 | } 155 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_CONNECTION', 'database'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Queue Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure the connection options for every queue backend 24 | | used by your application. An example configuration is provided for 25 | | each backend supported by Laravel. You're also free to add more. 26 | | 27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'connection' => env('DB_QUEUE_CONNECTION'), 40 | 'table' => env('DB_QUEUE_TABLE', 'jobs'), 41 | 'queue' => env('DB_QUEUE', 'default'), 42 | 'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90), 43 | 'after_commit' => false, 44 | ], 45 | 46 | 'beanstalkd' => [ 47 | 'driver' => 'beanstalkd', 48 | 'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'), 49 | 'queue' => env('BEANSTALKD_QUEUE', 'default'), 50 | 'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90), 51 | 'block_for' => 0, 52 | 'after_commit' => false, 53 | ], 54 | 55 | 'sqs' => [ 56 | 'driver' => 'sqs', 57 | 'key' => env('AWS_ACCESS_KEY_ID'), 58 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 59 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 60 | 'queue' => env('SQS_QUEUE', 'default'), 61 | 'suffix' => env('SQS_SUFFIX'), 62 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 63 | 'after_commit' => false, 64 | ], 65 | 66 | 'redis' => [ 67 | 'driver' => 'redis', 68 | 'connection' => env('REDIS_QUEUE_CONNECTION', 'default'), 69 | 'queue' => env('REDIS_QUEUE', 'default'), 70 | 'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90), 71 | 'block_for' => null, 72 | 'after_commit' => false, 73 | ], 74 | 75 | ], 76 | 77 | /* 78 | |-------------------------------------------------------------------------- 79 | | Job Batching 80 | |-------------------------------------------------------------------------- 81 | | 82 | | The following options configure the database and table that store job 83 | | batching information. These options can be updated to any database 84 | | connection and table which has been defined by your application. 85 | | 86 | */ 87 | 88 | 'batching' => [ 89 | 'database' => env('DB_CONNECTION', 'sqlite'), 90 | 'table' => 'job_batches', 91 | ], 92 | 93 | /* 94 | |-------------------------------------------------------------------------- 95 | | Failed Queue Jobs 96 | |-------------------------------------------------------------------------- 97 | | 98 | | These options configure the behavior of failed queue job logging so you 99 | | can control how and where failed jobs are stored. Laravel ships with 100 | | support for storing failed jobs in a simple file or in a database. 101 | | 102 | | Supported drivers: "database-uuids", "dynamodb", "file", "null" 103 | | 104 | */ 105 | 106 | 'failed' => [ 107 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 108 | 'database' => env('DB_CONNECTION', 'sqlite'), 109 | 'table' => 'failed_jobs', 110 | ], 111 | 112 | ]; 113 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => env('AUTH_GUARD', 'web'), 18 | 'passwords' => env('AUTH_PASSWORD_BROKER', 'users'), 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | which utilizes session storage plus the Eloquent user provider. 29 | | 30 | | All authentication guards have a user provider, which defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | system used by the application. Typically, Eloquent is utilized. 33 | | 34 | | Supported: "session" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | ], 44 | 45 | /* 46 | |-------------------------------------------------------------------------- 47 | | User Providers 48 | |-------------------------------------------------------------------------- 49 | | 50 | | All authentication guards have a user provider, which defines how the 51 | | users are actually retrieved out of your database or other storage 52 | | system used by the application. Typically, Eloquent is utilized. 53 | | 54 | | If you have multiple user tables or models you may configure multiple 55 | | providers to represent the model / table. These providers may then 56 | | be assigned to any extra authentication guards you have defined. 57 | | 58 | | Supported: "database", "eloquent" 59 | | 60 | */ 61 | 62 | 'providers' => [ 63 | 'users' => [ 64 | 'driver' => 'eloquent', 65 | 'model' => env('AUTH_MODEL', App\Models\User::class), 66 | ], 67 | 68 | // 'users' => [ 69 | // 'driver' => 'database', 70 | // 'table' => 'users', 71 | // ], 72 | ], 73 | 74 | /* 75 | |-------------------------------------------------------------------------- 76 | | Resetting Passwords 77 | |-------------------------------------------------------------------------- 78 | | 79 | | These configuration options specify the behavior of Laravel's password 80 | | reset functionality, including the table utilized for token storage 81 | | and the user provider that is invoked to actually retrieve users. 82 | | 83 | | The expiry time is the number of minutes that each reset token will be 84 | | considered valid. This security feature keeps tokens short-lived so 85 | | they have less time to be guessed. You may change this as needed. 86 | | 87 | | The throttle setting is the number of seconds a user must wait before 88 | | generating more password reset tokens. This prevents the user from 89 | | quickly generating a very large amount of password reset tokens. 90 | | 91 | */ 92 | 93 | 'passwords' => [ 94 | 'users' => [ 95 | 'provider' => 'users', 96 | 'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'), 97 | 'expire' => 60, 98 | 'throttle' => 60, 99 | ], 100 | ], 101 | 102 | /* 103 | |-------------------------------------------------------------------------- 104 | | Password Confirmation Timeout 105 | |-------------------------------------------------------------------------- 106 | | 107 | | Here you may define the amount of seconds before a password confirmation 108 | | window expires and users are asked to re-enter their password via the 109 | | confirmation screen. By default, the timeout lasts for three hours. 110 | | 111 | */ 112 | 113 | 'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800), 114 | 115 | ]; 116 | -------------------------------------------------------------------------------- /app/Http/Controllers/GroupOrderController.php: -------------------------------------------------------------------------------- 1 | function ($query) { 24 | $query->where('is_available', true); 25 | }])->findOrFail($request->input('store_id')); 26 | 27 | if ($store->is_closed) { 28 | return redirect()->route('stores.show', $store->id); 29 | } 30 | 31 | $groupOrder = GroupOrder::create([ 32 | 'store_id' => $store->id, 33 | 'course_id' => $request->user()->course_id, 34 | 'user_id' => $request->user()->id, 35 | 'status' => 'open', 36 | 'menu_snapshot' => $store->menuItems->toArray(), 37 | ]); 38 | 39 | return redirect()->intended(route('groupOrders.show', $groupOrder->id)); 40 | } 41 | 42 | /** 43 | * 更新團購狀態. 44 | */ 45 | public function update(Request $request, int $id): RedirectResponse 46 | { 47 | $updated = GroupOrder::where('id', $id) 48 | ->where('user_id', $request->user()->id) 49 | ->update(['status' => $request->input('status')]); 50 | 51 | return redirect()->intended(route('groupOrders.show', $id)); 52 | } 53 | 54 | /** 55 | * 顯示單筆團購. 56 | */ 57 | public function show(Request $request, int $id): Response|RedirectResponse 58 | { 59 | $courseId = $request->user()->course_id; 60 | 61 | $groupOrder = GroupOrder::with([ 62 | 'store' => function ($query) use ($courseId) { 63 | $query->withAvg('comments as rating_avg', 'rating') 64 | ->withCount('comments as rating_count') 65 | ->withAvg([ 66 | 'comments as course_rating_avg' => function ($query) use ($courseId) { 67 | $query->whereHas('user', function ($q) use ($courseId) { 68 | $q->where('course_id', $courseId); 69 | }); 70 | } 71 | ], 'rating') 72 | ->withCount([ 73 | 'comments as course_rating_count' => function ($query) use ($courseId) { 74 | $query->whereHas('user', function ($q) use ($courseId) { 75 | $q->where('course_id', $courseId); 76 | }); 77 | } 78 | ]); 79 | }, 80 | 'user', 81 | 'orders.user', 82 | 'orders.orderItems' 83 | ])->findOrFail($id); 84 | 85 | if ($groupOrder->course_id !== $request->user()->course_id) { 86 | return redirect()->route('groupOrders'); 87 | } 88 | 89 | $orders = $groupOrder->orders 90 | ->sortBy(function ($order) { 91 | return $order->user->seat_number; 92 | }) 93 | ->values(); 94 | 95 | $myOrder = $orders->firstWhere('user_id', $request->user()->id); 96 | 97 | return Inertia::render('groupOrders/Show', [ 98 | 'groupOrder' => $groupOrder, 99 | 'orders' => $orders, 100 | 'myOrder' => $myOrder, 101 | ]); 102 | } 103 | 104 | /** 105 | * 顯示所有團購. 106 | */ 107 | public function index(Request $request): Response 108 | { 109 | $user = $request->user(); 110 | $groupOrders = GroupOrder::where('course_id', $user->course_id) 111 | ->with([ 112 | 'store' => function ($query) use ($user) { 113 | $query->withCount([ 114 | 'groupOrders as course_ordered_group_orders_count' => function ($subQuery) use ($user) { 115 | $subQuery->where('course_id', $user->course_id) 116 | ->where('status', 'ordered'); 117 | } 118 | ]); 119 | }, 120 | 'user' 121 | ]) 122 | ->orderByDesc('created_at') 123 | ->get(); 124 | 125 | $groupOrders->makeHidden('menu_snapshot'); 126 | 127 | return Inertia::render('groupOrders/Index', [ 128 | 'groupOrders' => $groupOrders, 129 | ]); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_NAME', 'DinBenDon'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Application Environment 21 | |-------------------------------------------------------------------------- 22 | | 23 | | This value determines the "environment" your application is currently 24 | | running in. This may determine how you prefer to configure various 25 | | services the application utilizes. Set this in your ".env" file. 26 | | 27 | */ 28 | 29 | 'env' => env('APP_ENV', 'production'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Application Debug Mode 34 | |-------------------------------------------------------------------------- 35 | | 36 | | When your application is in debug mode, detailed error messages with 37 | | stack traces will be shown on every error that occurs within your 38 | | application. If disabled, a simple generic error page is shown. 39 | | 40 | */ 41 | 42 | 'debug' => (bool) env('APP_DEBUG', false), 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Application URL 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This URL is used by the console to properly generate URLs when using 50 | | the Artisan command line tool. You should set this to the root of 51 | | the application so that it's available within Artisan commands. 52 | | 53 | */ 54 | 55 | 'url' => env('APP_URL', 'http://localhost'), 56 | 57 | /* 58 | |-------------------------------------------------------------------------- 59 | | Application Timezone 60 | |-------------------------------------------------------------------------- 61 | | 62 | | Here you may specify the default timezone for your application, which 63 | | will be used by the PHP date and date-time functions. The timezone 64 | | is set to "UTC" by default as it is suitable for most use cases. 65 | | 66 | */ 67 | 68 | 'timezone' => 'Asia/Taipei', 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Application Locale Configuration 73 | |-------------------------------------------------------------------------- 74 | | 75 | | The application locale determines the default locale that will be used 76 | | by Laravel's translation / localization methods. This option can be 77 | | set to any locale for which you plan to have translation strings. 78 | | 79 | */ 80 | 81 | 'locale' => env('APP_LOCALE', 'zh_TW'), 82 | 83 | 'fallback_locale' => env('APP_FALLBACK_LOCALE', 'zh_TW'), 84 | 85 | 'faker_locale' => env('APP_FAKER_LOCALE', 'zh_TW'), 86 | 87 | /* 88 | |-------------------------------------------------------------------------- 89 | | Encryption Key 90 | |-------------------------------------------------------------------------- 91 | | 92 | | This key is utilized by Laravel's encryption services and should be set 93 | | to a random, 32 character string to ensure that all encrypted values 94 | | are secure. You should do this prior to deploying the application. 95 | | 96 | */ 97 | 98 | 'cipher' => 'AES-256-CBC', 99 | 100 | 'key' => env('APP_KEY'), 101 | 102 | 'previous_keys' => [ 103 | ...array_filter( 104 | explode(',', env('APP_PREVIOUS_KEYS', '')) 105 | ), 106 | ], 107 | 108 | /* 109 | |-------------------------------------------------------------------------- 110 | | Maintenance Mode Driver 111 | |-------------------------------------------------------------------------- 112 | | 113 | | These configuration options determine the driver used to determine and 114 | | manage Laravel's "maintenance mode" status. The "cache" driver will 115 | | allow maintenance mode to be controlled across multiple machines. 116 | | 117 | | Supported drivers: "file", "cache" 118 | | 119 | */ 120 | 121 | 'maintenance' => [ 122 | 'driver' => env('APP_MAINTENANCE_DRIVER', 'file'), 123 | 'store' => env('APP_MAINTENANCE_STORE', 'database'), 124 | ], 125 | 126 | ]; 127 | -------------------------------------------------------------------------------- /config/logging.php: -------------------------------------------------------------------------------- 1 | env('LOG_CHANNEL', 'stack'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Deprecations Log Channel 26 | |-------------------------------------------------------------------------- 27 | | 28 | | This option controls the log channel that should be used to log warnings 29 | | regarding deprecated PHP and library features. This allows you to get 30 | | your application ready for upcoming major versions of dependencies. 31 | | 32 | */ 33 | 34 | 'deprecations' => [ 35 | 'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'), 36 | 'trace' => env('LOG_DEPRECATIONS_TRACE', false), 37 | ], 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Log Channels 42 | |-------------------------------------------------------------------------- 43 | | 44 | | Here you may configure the log channels for your application. Laravel 45 | | utilizes the Monolog PHP logging library, which includes a variety 46 | | of powerful log handlers and formatters that you're free to use. 47 | | 48 | | Available drivers: "single", "daily", "slack", "syslog", 49 | | "errorlog", "monolog", "custom", "stack" 50 | | 51 | */ 52 | 53 | 'channels' => [ 54 | 55 | 'stack' => [ 56 | 'driver' => 'stack', 57 | 'channels' => explode(',', env('LOG_STACK', 'single')), 58 | 'ignore_exceptions' => false, 59 | ], 60 | 61 | 'single' => [ 62 | 'driver' => 'single', 63 | 'path' => storage_path('logs/laravel.log'), 64 | 'level' => env('LOG_LEVEL', 'debug'), 65 | 'replace_placeholders' => true, 66 | ], 67 | 68 | 'daily' => [ 69 | 'driver' => 'daily', 70 | 'path' => storage_path('logs/laravel.log'), 71 | 'level' => env('LOG_LEVEL', 'debug'), 72 | 'days' => env('LOG_DAILY_DAYS', 14), 73 | 'replace_placeholders' => true, 74 | ], 75 | 76 | 'slack' => [ 77 | 'driver' => 'slack', 78 | 'url' => env('LOG_SLACK_WEBHOOK_URL'), 79 | 'username' => env('LOG_SLACK_USERNAME', 'Laravel Log'), 80 | 'emoji' => env('LOG_SLACK_EMOJI', ':boom:'), 81 | 'level' => env('LOG_LEVEL', 'critical'), 82 | 'replace_placeholders' => true, 83 | ], 84 | 85 | 'papertrail' => [ 86 | 'driver' => 'monolog', 87 | 'level' => env('LOG_LEVEL', 'debug'), 88 | 'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class), 89 | 'handler_with' => [ 90 | 'host' => env('PAPERTRAIL_URL'), 91 | 'port' => env('PAPERTRAIL_PORT'), 92 | 'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'), 93 | ], 94 | 'processors' => [PsrLogMessageProcessor::class], 95 | ], 96 | 97 | 'stderr' => [ 98 | 'driver' => 'monolog', 99 | 'level' => env('LOG_LEVEL', 'debug'), 100 | 'handler' => StreamHandler::class, 101 | 'handler_with' => [ 102 | 'stream' => 'php://stderr', 103 | ], 104 | 'formatter' => env('LOG_STDERR_FORMATTER'), 105 | 'processors' => [PsrLogMessageProcessor::class], 106 | ], 107 | 108 | 'syslog' => [ 109 | 'driver' => 'syslog', 110 | 'level' => env('LOG_LEVEL', 'debug'), 111 | 'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER), 112 | 'replace_placeholders' => true, 113 | ], 114 | 115 | 'errorlog' => [ 116 | 'driver' => 'errorlog', 117 | 'level' => env('LOG_LEVEL', 'debug'), 118 | 'replace_placeholders' => true, 119 | ], 120 | 121 | 'null' => [ 122 | 'driver' => 'monolog', 123 | 'handler' => NullHandler::class, 124 | ], 125 | 126 | 'emergency' => [ 127 | 'path' => storage_path('logs/laravel.log'), 128 | ], 129 | 130 | ], 131 | 132 | ]; 133 | -------------------------------------------------------------------------------- /resources/js/pages/orders/Index.vue: -------------------------------------------------------------------------------- 1 | 55 | 56 | 86 | 87 | 106 | -------------------------------------------------------------------------------- /resources/js/components/RandomDialog.vue: -------------------------------------------------------------------------------- 1 | 5 | 36 | 37 | 117 | 118 | 167 | -------------------------------------------------------------------------------- /app/Http/Controllers/OrderController.php: -------------------------------------------------------------------------------- 1 | user()->id) 24 | ->whereHas('groupOrder', fn ($query) => $query->where('status', 'ordered')) 25 | ->with([ 26 | 'groupOrder' => fn ($query) => $query 27 | ->select('id', 'course_id', 'store_id', 'user_id', 'status', 'created_at', 'updated_at'), 28 | 'groupOrder.store' => fn ($query) => $query->select('id', 'name'), 29 | 'orderItems', 30 | ]) 31 | ->orderBy('created_at', 'desc') 32 | ->get(); 33 | 34 | return Inertia::render('orders/Index', [ 35 | 'orders' => $orders, 36 | ]); 37 | } 38 | 39 | /** 40 | * 建立團購內訂單. 41 | */ 42 | public function create(Request $request): RedirectResponse 43 | { 44 | $validated = $request->validate([ 45 | 'group_order_id' => 'required|exists:group_orders,id', 46 | 'total_price' => 'required|integer|min:1', 47 | 'items' => 'required|array', 48 | 'items.*.menu_item_id' => 'required|exists:menu_items,id', 49 | 'items.*.name' => 'required|string|max:255', 50 | 'items.*.price' => 'required|integer|min:1', 51 | 'items.*.quantity' => 'required|integer|min:1', 52 | 'items.*.comment' => 'nullable|string|max:50', 53 | ]); 54 | 55 | $groupOrder = GroupOrder::with('store')->findOrFail($validated['group_order_id']); 56 | if ($groupOrder->store->is_closed) { 57 | return redirect()->intended(route('groupOrders.show', $groupOrder->id)); 58 | } 59 | 60 | $order = \DB::transaction(function () use ($validated, $request) { 61 | $order = Order::updateOrCreate( 62 | [ 63 | 'group_order_id' => $validated['group_order_id'], 64 | 'user_id' => $request->user()->id, 65 | ], 66 | [ 67 | 'total_price' => $validated['total_price'], 68 | ] 69 | ); 70 | 71 | $order->orderItems()->delete(); 72 | $order->orderItems()->createMany($validated['items']); 73 | 74 | return $order; 75 | }); 76 | 77 | return redirect()->intended(route('groupOrders.show', $order->group_order_id)); 78 | } 79 | 80 | 81 | /** 82 | * 顯示團購內訂單表單. 83 | */ 84 | public function showForm(Request $request, int $id): Response|RedirectResponse 85 | { 86 | $userId = $request->user()->id; 87 | $groupOrder = GroupOrder::with([ 88 | 'store', 89 | 'user', 90 | 'orders' => function ($query) use ($userId) { 91 | $query->where('user_id', $userId)->with('orderItems'); 92 | } 93 | ])->findOrFail($id); 94 | 95 | // 若 course_id 不同則導向 stores 頁面 96 | if ($groupOrder->course_id !== $request->user()->course_id) { 97 | return redirect()->route('groupOrders'); 98 | } 99 | 100 | $myOrder = $groupOrder->orders->first(); 101 | $groupOrder->makeHidden(['orders']); 102 | 103 | $courseId = $request->user()->course_id; 104 | $menuItemIds = collect($groupOrder->menu_snapshot)->pluck('id'); 105 | 106 | $menuItemsWithCounts = MenuItem::whereIn('id', $menuItemIds) 107 | ->withSum([ 108 | 'orderItems as total_ordered_count' => function ($query) { 109 | $query->whereHas('order.groupOrder', fn ($q) => $q->where('status', 'ordered')); 110 | } 111 | ], 'quantity') 112 | ->when($courseId, function ($query) use ($courseId) { 113 | $query->withSum([ 114 | 'orderItems as course_ordered_count' => function ($query) use ($courseId) { 115 | $query->whereHas('order', function ($q) use ($courseId) { 116 | $q->whereHas('groupOrder', fn ($subQ) => $subQ->where('status', 'ordered')) 117 | ->whereHas('user', fn ($subQ) => $subQ->where('course_id', $courseId)); 118 | }); 119 | } 120 | ], 'quantity'); 121 | }) 122 | ->get() 123 | ->keyBy('id'); 124 | 125 | $menuSnapshotWithCounts = collect($groupOrder->menu_snapshot)->map(function ($item) use ($menuItemsWithCounts, $courseId) { 126 | $itemWithCount = $menuItemsWithCounts->get($item['id']); 127 | if ($itemWithCount) { 128 | $item['total_ordered_count'] = (int) $itemWithCount->total_ordered_count; 129 | $item['course_ordered_count'] = $courseId ? (int) $itemWithCount->course_ordered_count : 0; 130 | } else { 131 | $item['total_ordered_count'] = 0; 132 | $item['course_ordered_count'] = 0; 133 | } 134 | return $item; 135 | }); 136 | 137 | $groupOrder->menu_snapshot = $menuSnapshotWithCounts; 138 | 139 | return Inertia::render('groupOrders/Order', [ 140 | 'groupOrder' => $groupOrder, 141 | 'myOrder' => $myOrder, 142 | ]); 143 | } 144 | 145 | /** 146 | * 取消訂單 147 | */ 148 | public function cancel(Request $request, int $id): RedirectResponse 149 | { 150 | $order = Order::with('groupOrder')->findOrFail($id); 151 | 152 | if ($order->user_id !== $request->user()->id || $order->groupOrder->status !== 'open') { 153 | return redirect()->route('groupOrders.show', $order->group_order_id); 154 | } 155 | 156 | $order->orderItems()->delete(); 157 | $order->delete(); 158 | 159 | return redirect()->route('groupOrders.show', $order->group_order_id); 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /resources/js/pages/groupOrders/Index.vue: -------------------------------------------------------------------------------- 1 | 76 | 77 | 152 | -------------------------------------------------------------------------------- /resources/js/layouts/MainLayout.vue: -------------------------------------------------------------------------------- 1 | 102 | 103 | 139 | 140 | 160 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | env('DB_CONNECTION', 'sqlite'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Database Connections 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Below are all of the database connections defined for your application. 27 | | An example configuration is provided for each database system which 28 | | is supported by Laravel. You're free to add / remove connections. 29 | | 30 | */ 31 | 32 | 'connections' => [ 33 | 34 | 'sqlite' => [ 35 | 'driver' => 'sqlite', 36 | 'url' => env('DB_URL'), 37 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 38 | 'prefix' => '', 39 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 40 | 'busy_timeout' => null, 41 | 'journal_mode' => null, 42 | 'synchronous' => null, 43 | ], 44 | 45 | 'mysql' => [ 46 | 'driver' => 'mysql', 47 | 'url' => env('DB_URL'), 48 | 'host' => env('DB_HOST', '127.0.0.1'), 49 | 'port' => env('DB_PORT', '3306'), 50 | 'database' => env('DB_DATABASE', 'laravel'), 51 | 'username' => env('DB_USERNAME', 'root'), 52 | 'password' => env('DB_PASSWORD', ''), 53 | 'unix_socket' => env('DB_SOCKET', ''), 54 | 'charset' => env('DB_CHARSET', 'utf8mb4'), 55 | 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'), 56 | 'prefix' => '', 57 | 'prefix_indexes' => true, 58 | 'strict' => true, 59 | 'engine' => null, 60 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 61 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 62 | ]) : [], 63 | ], 64 | 65 | 'mariadb' => [ 66 | 'driver' => 'mariadb', 67 | 'url' => env('DB_URL'), 68 | 'host' => env('DB_HOST', '127.0.0.1'), 69 | 'port' => env('DB_PORT', '3306'), 70 | 'database' => env('DB_DATABASE', 'laravel'), 71 | 'username' => env('DB_USERNAME', 'root'), 72 | 'password' => env('DB_PASSWORD', ''), 73 | 'unix_socket' => env('DB_SOCKET', ''), 74 | 'charset' => env('DB_CHARSET', 'utf8mb4'), 75 | 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'), 76 | 'prefix' => '', 77 | 'prefix_indexes' => true, 78 | 'strict' => true, 79 | 'engine' => null, 80 | 'options' => extension_loaded('pdo_mysql') ? array_filter([ 81 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), 82 | ]) : [], 83 | ], 84 | 85 | 'pgsql' => [ 86 | 'driver' => 'pgsql', 87 | 'url' => env('DB_URL'), 88 | 'host' => env('DB_HOST', '127.0.0.1'), 89 | 'port' => env('DB_PORT', '5432'), 90 | 'database' => env('DB_DATABASE', 'laravel'), 91 | 'username' => env('DB_USERNAME', 'root'), 92 | 'password' => env('DB_PASSWORD', ''), 93 | 'charset' => env('DB_CHARSET', 'utf8'), 94 | 'prefix' => '', 95 | 'prefix_indexes' => true, 96 | 'search_path' => 'public', 97 | 'sslmode' => 'prefer', 98 | ], 99 | 100 | 'sqlsrv' => [ 101 | 'driver' => 'sqlsrv', 102 | 'url' => env('DB_URL'), 103 | 'host' => env('DB_HOST', 'localhost'), 104 | 'port' => env('DB_PORT', '1433'), 105 | 'database' => env('DB_DATABASE', 'laravel'), 106 | 'username' => env('DB_USERNAME', 'root'), 107 | 'password' => env('DB_PASSWORD', ''), 108 | 'charset' => env('DB_CHARSET', 'utf8'), 109 | 'prefix' => '', 110 | 'prefix_indexes' => true, 111 | // 'encrypt' => env('DB_ENCRYPT', 'yes'), 112 | // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), 113 | ], 114 | 115 | ], 116 | 117 | /* 118 | |-------------------------------------------------------------------------- 119 | | Migration Repository Table 120 | |-------------------------------------------------------------------------- 121 | | 122 | | This table keeps track of all the migrations that have already run for 123 | | your application. Using this information, we can determine which of 124 | | the migrations on disk haven't actually been run on the database. 125 | | 126 | */ 127 | 128 | 'migrations' => [ 129 | 'table' => 'migrations', 130 | 'update_date_on_publish' => true, 131 | ], 132 | 133 | /* 134 | |-------------------------------------------------------------------------- 135 | | Redis Databases 136 | |-------------------------------------------------------------------------- 137 | | 138 | | Redis is an open source, fast, and advanced key-value store that also 139 | | provides a richer body of commands than a typical key-value system 140 | | such as Memcached. You may define your connection settings here. 141 | | 142 | */ 143 | 144 | 'redis' => [ 145 | 146 | 'client' => env('REDIS_CLIENT', 'phpredis'), 147 | 148 | 'options' => [ 149 | 'cluster' => env('REDIS_CLUSTER', 'redis'), 150 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), 151 | 'persistent' => env('REDIS_PERSISTENT', false), 152 | ], 153 | 154 | 'default' => [ 155 | 'url' => env('REDIS_URL'), 156 | 'host' => env('REDIS_HOST', '127.0.0.1'), 157 | 'username' => env('REDIS_USERNAME'), 158 | 'password' => env('REDIS_PASSWORD'), 159 | 'port' => env('REDIS_PORT', '6379'), 160 | 'database' => env('REDIS_DB', '0'), 161 | ], 162 | 163 | 'cache' => [ 164 | 'url' => env('REDIS_URL'), 165 | 'host' => env('REDIS_HOST', '127.0.0.1'), 166 | 'username' => env('REDIS_USERNAME'), 167 | 'password' => env('REDIS_PASSWORD'), 168 | 'port' => env('REDIS_PORT', '6379'), 169 | 'database' => env('REDIS_CACHE_DB', '1'), 170 | ], 171 | 172 | ], 173 | 174 | ]; 175 | -------------------------------------------------------------------------------- /resources/js/pages/stores/Index.vue: -------------------------------------------------------------------------------- 1 | 106 | 107 | 171 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'database'), 22 | 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Session Lifetime 26 | |-------------------------------------------------------------------------- 27 | | 28 | | Here you may specify the number of minutes that you wish the session 29 | | to be allowed to remain idle before it expires. If you want them 30 | | to expire immediately when the browser is closed then you may 31 | | indicate that via the expire_on_close configuration option. 32 | | 33 | */ 34 | 35 | 'lifetime' => (int) env('SESSION_LIFETIME', 120), 36 | 37 | 'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false), 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Session Encryption 42 | |-------------------------------------------------------------------------- 43 | | 44 | | This option allows you to easily specify that all of your session data 45 | | should be encrypted before it's stored. All encryption is performed 46 | | automatically by Laravel and you may use the session like normal. 47 | | 48 | */ 49 | 50 | 'encrypt' => env('SESSION_ENCRYPT', false), 51 | 52 | /* 53 | |-------------------------------------------------------------------------- 54 | | Session File Location 55 | |-------------------------------------------------------------------------- 56 | | 57 | | When utilizing the "file" session driver, the session files are placed 58 | | on disk. The default storage location is defined here; however, you 59 | | are free to provide another location where they should be stored. 60 | | 61 | */ 62 | 63 | 'files' => storage_path('framework/sessions'), 64 | 65 | /* 66 | |-------------------------------------------------------------------------- 67 | | Session Database Connection 68 | |-------------------------------------------------------------------------- 69 | | 70 | | When using the "database" or "redis" session drivers, you may specify a 71 | | connection that should be used to manage these sessions. This should 72 | | correspond to a connection in your database configuration options. 73 | | 74 | */ 75 | 76 | 'connection' => env('SESSION_CONNECTION'), 77 | 78 | /* 79 | |-------------------------------------------------------------------------- 80 | | Session Database Table 81 | |-------------------------------------------------------------------------- 82 | | 83 | | When using the "database" session driver, you may specify the table to 84 | | be used to store sessions. Of course, a sensible default is defined 85 | | for you; however, you're welcome to change this to another table. 86 | | 87 | */ 88 | 89 | 'table' => env('SESSION_TABLE', 'sessions'), 90 | 91 | /* 92 | |-------------------------------------------------------------------------- 93 | | Session Cache Store 94 | |-------------------------------------------------------------------------- 95 | | 96 | | When using one of the framework's cache driven session backends, you may 97 | | define the cache store which should be used to store the session data 98 | | between requests. This must match one of your defined cache stores. 99 | | 100 | | Affects: "apc", "dynamodb", "memcached", "redis" 101 | | 102 | */ 103 | 104 | 'store' => env('SESSION_STORE'), 105 | 106 | /* 107 | |-------------------------------------------------------------------------- 108 | | Session Sweeping Lottery 109 | |-------------------------------------------------------------------------- 110 | | 111 | | Some session drivers must manually sweep their storage location to get 112 | | rid of old sessions from storage. Here are the chances that it will 113 | | happen on a given request. By default, the odds are 2 out of 100. 114 | | 115 | */ 116 | 117 | 'lottery' => [2, 100], 118 | 119 | /* 120 | |-------------------------------------------------------------------------- 121 | | Session Cookie Name 122 | |-------------------------------------------------------------------------- 123 | | 124 | | Here you may change the name of the session cookie that is created by 125 | | the framework. Typically, you should not need to change this value 126 | | since doing so does not grant a meaningful security improvement. 127 | | 128 | */ 129 | 130 | 'cookie' => env( 131 | 'SESSION_COOKIE', 132 | Str::slug(env('APP_NAME', 'laravel'), '_').'_session' 133 | ), 134 | 135 | /* 136 | |-------------------------------------------------------------------------- 137 | | Session Cookie Path 138 | |-------------------------------------------------------------------------- 139 | | 140 | | The session cookie path determines the path for which the cookie will 141 | | be regarded as available. Typically, this will be the root path of 142 | | your application, but you're free to change this when necessary. 143 | | 144 | */ 145 | 146 | 'path' => env('SESSION_PATH', '/'), 147 | 148 | /* 149 | |-------------------------------------------------------------------------- 150 | | Session Cookie Domain 151 | |-------------------------------------------------------------------------- 152 | | 153 | | This value determines the domain and subdomains the session cookie is 154 | | available to. By default, the cookie will be available to the root 155 | | domain and all subdomains. Typically, this shouldn't be changed. 156 | | 157 | */ 158 | 159 | 'domain' => env('SESSION_DOMAIN'), 160 | 161 | /* 162 | |-------------------------------------------------------------------------- 163 | | HTTPS Only Cookies 164 | |-------------------------------------------------------------------------- 165 | | 166 | | By setting this option to true, session cookies will only be sent back 167 | | to the server if the browser has a HTTPS connection. This will keep 168 | | the cookie from being sent to you when it can't be done securely. 169 | | 170 | */ 171 | 172 | 'secure' => env('SESSION_SECURE_COOKIE'), 173 | 174 | /* 175 | |-------------------------------------------------------------------------- 176 | | HTTP Access Only 177 | |-------------------------------------------------------------------------- 178 | | 179 | | Setting this value to true will prevent JavaScript from accessing the 180 | | value of the cookie and the cookie will only be accessible through 181 | | the HTTP protocol. It's unlikely you should disable this option. 182 | | 183 | */ 184 | 185 | 'http_only' => env('SESSION_HTTP_ONLY', true), 186 | 187 | /* 188 | |-------------------------------------------------------------------------- 189 | | Same-Site Cookies 190 | |-------------------------------------------------------------------------- 191 | | 192 | | This option determines how your cookies behave when cross-site requests 193 | | take place, and can be used to mitigate CSRF attacks. By default, we 194 | | will set this value to "lax" to permit secure cross-site requests. 195 | | 196 | | See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value 197 | | 198 | | Supported: "lax", "strict", "none", null 199 | | 200 | */ 201 | 202 | 'same_site' => env('SESSION_SAME_SITE', 'lax'), 203 | 204 | /* 205 | |-------------------------------------------------------------------------- 206 | | Partitioned Cookies 207 | |-------------------------------------------------------------------------- 208 | | 209 | | Setting this value to true will tie the cookie to the top-level site for 210 | | a cross-site context. Partitioned cookies are accepted by the browser 211 | | when flagged "secure" and the Same-Site attribute is set to "none". 212 | | 213 | */ 214 | 215 | 'partitioned' => env('SESSION_PARTITIONED_COOKIE', false), 216 | 217 | ]; 218 | -------------------------------------------------------------------------------- /app/Http/Controllers/StoreController.php: -------------------------------------------------------------------------------- 1 | user()->course_id; 24 | 25 | $stores = Store::withCount([ 26 | 'groupOrders as ordered_group_orders_count' => function ($query) { 27 | $query->where('status', 'ordered'); 28 | }, 29 | 'groupOrders as course_ordered_group_orders_count' => function ($query) use ($courseId) { 30 | $query->where('course_id', $courseId) 31 | ->where('status', 'ordered'); 32 | } 33 | ]) 34 | ->withAvg('comments as rating_avg', 'rating') 35 | ->withCount('comments as rating_count') 36 | ->withAvg([ 37 | 'comments as course_rating_avg' => function ($query) use ($courseId) { 38 | $query->whereHas('user', function ($q) use ($courseId) { 39 | $q->where('course_id', $courseId); 40 | }); 41 | } 42 | ], 'rating') 43 | ->withCount([ 44 | 'comments as course_rating_count' => function ($query) use ($courseId) { 45 | $query->whereHas('user', function ($q) use ($courseId) { 46 | $q->where('course_id', $courseId); 47 | }); 48 | } 49 | ]) 50 | ->get(); 51 | 52 | return Inertia::render('stores/Index', [ 53 | 'stores' => $stores, 54 | ]); 55 | } 56 | 57 | /** 58 | * 顯示單一店家資訊. 59 | */ 60 | public function show(Request $request, int $id): Response 61 | { 62 | $courseId = $request->user()->course_id; 63 | 64 | $store = Store::withCount([ 65 | 'groupOrders as ordered_group_orders_count' => function ($query) { 66 | $query->where('status', 'ordered'); 67 | }, 68 | 'groupOrders as course_ordered_group_orders_count' => function ($query) use ($request) { 69 | $query->where('course_id', $request->user()->course_id) 70 | ->where('status', 'ordered'); 71 | } 72 | ]) 73 | ->withAvg('comments as rating_avg', 'rating') 74 | ->withCount('comments as rating_count') 75 | ->withAvg([ 76 | 'comments as course_rating_avg' => function ($query) use ($courseId) { 77 | $query->whereHas('user', function ($q) use ($courseId) { 78 | $q->where('course_id', $courseId); 79 | }); 80 | } 81 | ], 'rating') 82 | ->withCount([ 83 | 'comments as course_rating_count' => function ($query) use ($courseId) { 84 | $query->whereHas('user', function ($q) use ($courseId) { 85 | $q->where('course_id', $courseId); 86 | }); 87 | } 88 | ]) 89 | ->findOrFail($id); 90 | 91 | $courseId = $request->user()->course_id; 92 | 93 | $menuItemsQuery = $store->menuItems()->where('is_available', true); 94 | 95 | $menuItemsQuery->withSum([ 96 | 'orderItems as total_ordered_count' => function ($query) { 97 | $query->whereHas('order.groupOrder', function ($q) { 98 | $q->where('status', 'ordered'); 99 | }); 100 | } 101 | ], 'quantity'); 102 | 103 | $menuItemsQuery->withSum([ 104 | 'orderItems as course_ordered_count' => function ($query) use ($courseId) { 105 | $query->whereHas('order', function ($q) use ($courseId) { 106 | $q->whereHas('groupOrder', function ($subQ) { 107 | $subQ->where('status', 'ordered'); 108 | })->whereHas('user', function ($subQ) use ($courseId) { 109 | $subQ->where('course_id', $courseId); 110 | }); 111 | }); 112 | } 113 | ], 'quantity'); 114 | 115 | $menuItems = $menuItemsQuery->get(); 116 | 117 | $menuItems->each(function ($item) use ($courseId) { 118 | $item->total_ordered_count = (int) $item->total_ordered_count; 119 | $item->course_ordered_count = $courseId ? (int) $item->course_ordered_count : 0; 120 | }); 121 | 122 | $groupOrders = $store->groupOrders() 123 | ->with('user') 124 | ->where('status', 'open') 125 | ->where('course_id', $request->user()->course_id) 126 | ->orderByDesc('created_at') 127 | ->get(); 128 | $groupOrders->makeHidden('menu_snapshot'); 129 | $groupOrders->store = $store; 130 | 131 | $myComment = $store->comments()->where('user_id', $request->user()->id)->first(); 132 | 133 | $comments = $store->comments()->get(); 134 | 135 | return Inertia::render('stores/Show', [ 136 | 'store' => $store, 137 | 'menuItems' => $menuItems, 138 | 'groupOrders' => $groupOrders, 139 | 'myComment' => $myComment, 140 | 'comments' => $comments, 141 | ]); 142 | } 143 | 144 | /** 145 | * 顯示單一店家資訊表單. 146 | */ 147 | public function editForm(Request $request, int $id): Response 148 | { 149 | $store = Store::withCount(['groupOrders as ordered_group_orders_count' => function ($query) { 150 | $query->where('status', 'ordered'); 151 | }])->findOrFail($id); 152 | $menuItems = $store->menuItems()->get(); 153 | 154 | return Inertia::render('stores/Edit', [ 155 | 'store' => $store, 156 | 'menuItems' => $menuItems, 157 | ]); 158 | } 159 | 160 | public function createForm(Request $request): Response 161 | { 162 | return Inertia::render('stores/Edit', [ 163 | 'store' => null, 164 | 'menuItems' => null, 165 | ]); 166 | } 167 | 168 | /** 169 | * 更新單一店家資訊. 170 | */ 171 | public function editFormSubmit(Request $request): RedirectResponse 172 | { 173 | $validated = $request->validate([ 174 | 'store' => 'nullable|integer', 175 | 'name' => 'required|string|max:255', 176 | 'address' => 'nullable|string|max:255', 177 | 'phone' => 'required|string|max:255', 178 | 'business_hours' => 'nullable|string|max:255', 179 | 'delivery_conditions' => 'nullable|string|max:255', 180 | 'google_map' => 'nullable|string|max:255', 181 | 'facebook' => 'nullable|string|max:255', 182 | 'instagram' => 'nullable|string|max:255', 183 | 'image' => 'nullable|image|mimes:jpeg,png,jpg|max:1024', 184 | 'is_closed' => 'required|boolean', 185 | 'menuItems' => 'present|array', 186 | 'menuItems.*.id' => 'nullable|integer', 187 | 'menuItems.*.name' => 'required|string|max:255', 188 | 'menuItems.*.price' => 'required|numeric|min:0', 189 | 'menuItems.*.is_available' => 'required|boolean', 190 | ]); 191 | 192 | $store = null; 193 | if ($validated['store']) { 194 | $store = Store::findOrFail($validated['store']); 195 | } 196 | 197 | if ($request->hasFile('image')) { 198 | if ($store) { 199 | $oldImagePath = $store->getRawOriginal('image'); 200 | if ($oldImagePath && File::exists(public_path($oldImagePath))) { 201 | File::delete(public_path($oldImagePath)); 202 | } 203 | } 204 | 205 | $file = $request->file('image'); 206 | $filename = (string) Str::uuid() . '.' . $file->extension(); 207 | $request->image->move(public_path('storage/store'), $filename); 208 | $validated['image'] = 'storage/store/' . $filename; 209 | } else { 210 | unset($validated['image']); 211 | } 212 | 213 | $store = Store::updateOrCreate( 214 | ['id' => $validated['store']], 215 | $validated 216 | ); 217 | 218 | foreach ($validated['menuItems'] as $menuItemData) { 219 | MenuItem::updateOrCreate( 220 | [ 221 | 'id' => $menuItemData['id'], 222 | 'store_id' => $store->id, 223 | ], 224 | $menuItemData 225 | ); 226 | } 227 | 228 | return redirect()->route('stores.show', $store); 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, 15 | "useDefineForClassFields": true, 16 | "lib": [ 17 | "ESNext", 18 | "DOM", 19 | "DOM.Iterable" 20 | ] /* Specify a set of bundled library declaration files that describe the target runtime environment. */, 21 | "jsx": "preserve" /* Specify what JSX code is generated. */, 22 | "jsxImportSource": "vue" /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */, 23 | // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ 24 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 25 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 26 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 27 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 28 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 29 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 30 | 31 | /* Modules */ 32 | "module": "ESNext" /* Specify what module code is generated. */, 33 | // "rootDir": "./", /* Specify the root folder within your source files. */ 34 | "moduleResolution": "bundler" /* Specify how TypeScript looks up a file from a given module specifier. */, 35 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 36 | "paths": { 37 | /* Specify a set of entries that re-map imports to additional lookup locations. */ "@/*": ["./resources/js/*"], 38 | }, 39 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 40 | // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ 41 | "types": [ 42 | "vite/client", 43 | "./resources/js/types" 44 | ] /* Specify type package names to be included without being referenced in a source file. */, 45 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 46 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 47 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 48 | // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */ 49 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 50 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 51 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 52 | // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ 53 | "resolveJsonModule": true /* Enable importing .json files. */, 54 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 55 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 56 | 57 | /* JavaScript Support */ 58 | "allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */, 59 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 60 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 61 | 62 | /* Emit */ 63 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 64 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 65 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 66 | "sourceMap": true /* Create source map files for emitted JavaScript files. */, 67 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 68 | "noEmit": true /* Disable emitting files from a compilation. */, 69 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ 70 | // "outDir": "./", /* Specify an output folder for all emitted files. */ 71 | // "removeComments": true, /* Disable emitting comments. */ 72 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 73 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 74 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 75 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 76 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 77 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 78 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 79 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 80 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 81 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 82 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 83 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 84 | 85 | /* Interop Constraints */ 86 | "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */, 87 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ 88 | // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ 89 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 90 | "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, 91 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 92 | "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, 93 | 94 | /* Type Checking */ 95 | "strict": true /* Enable all strict type-checking options. */, 96 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 97 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 98 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 99 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 100 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 101 | // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ 102 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 103 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 104 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 105 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 106 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 107 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 108 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 109 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 110 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 111 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 112 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 113 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 114 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 115 | 116 | /* Completeness */ 117 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 118 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 119 | }, 120 | "include": [ 121 | "resources/js/**/*.ts", 122 | "resources/js/**/*.d.ts", 123 | "resources/js/**/*.tsx", 124 | "resources/js/**/*.vue" 125 | ], 126 | "vueCompilerOptions": { 127 | "plugins": ["@vue/language-plugin-pug"] 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /resources/js/pages/groupOrders/Order.vue: -------------------------------------------------------------------------------- 1 | 175 | 176 | 327 | 328 | 335 | --------------------------------------------------------------------------------