Autosave: 20260406-061053
This commit is contained in:
parent
4939586371
commit
d844b2d94f
18
.editorconfig
Normal file
18
.editorconfig
Normal file
@ -0,0 +1,18 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.{yml,yaml}]
|
||||
indent_size = 2
|
||||
|
||||
[compose.yaml]
|
||||
indent_size = 4
|
||||
65
.env.example
Normal file
65
.env.example
Normal file
@ -0,0 +1,65 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
APP_FAKER_LOCALE=en_US
|
||||
|
||||
APP_MAINTENANCE_DRIVER=file
|
||||
# APP_MAINTENANCE_STORE=database
|
||||
|
||||
# PHP_CLI_SERVER_WORKERS=4
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
# DB_HOST=127.0.0.1
|
||||
# DB_PORT=3306
|
||||
# DB_DATABASE=laravel
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
SESSION_ENCRYPT=false
|
||||
SESSION_PATH=/
|
||||
SESSION_DOMAIN=null
|
||||
|
||||
BROADCAST_CONNECTION=log
|
||||
FILESYSTEM_DISK=local
|
||||
QUEUE_CONNECTION=database
|
||||
|
||||
CACHE_STORE=database
|
||||
# CACHE_PREFIX=
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_CLIENT=phpredis
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=log
|
||||
MAIL_SCHEME=null
|
||||
MAIL_HOST=127.0.0.1
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_FROM_ADDRESS="hello@example.com"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
11
.gitattributes
vendored
Normal file
11
.gitattributes
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
* text=auto eol=lf
|
||||
|
||||
*.blade.php diff=html
|
||||
*.css diff=css
|
||||
*.html diff=html
|
||||
*.md diff=markdown
|
||||
*.php diff=php
|
||||
|
||||
/.github export-ignore
|
||||
CHANGELOG.md export-ignore
|
||||
.styleci.yml export-ignore
|
||||
27
.gitignore
vendored
27
.gitignore
vendored
@ -1,3 +1,24 @@
|
||||
node_modules/
|
||||
*/node_modules/
|
||||
*/build/
|
||||
*.log
|
||||
.DS_Store
|
||||
.env
|
||||
.env.backup
|
||||
.env.production
|
||||
.phpactor.json
|
||||
.phpunit.result.cache
|
||||
/.fleet
|
||||
/.idea
|
||||
/.nova
|
||||
/.phpunit.cache
|
||||
/.vscode
|
||||
/.zed
|
||||
/auth.json
|
||||
/node_modules
|
||||
/public/build
|
||||
/public/hot
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/pail
|
||||
/vendor
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
Thumbs.db
|
||||
|
||||
7
.htaccess
Normal file
7
.htaccess
Normal file
@ -0,0 +1,7 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
</IfModule>
|
||||
59
README.md
Normal file
59
README.md
Normal file
@ -0,0 +1,59 @@
|
||||
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||
</p>
|
||||
|
||||
## About Laravel
|
||||
|
||||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||
|
||||
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||
|
||||
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||
|
||||
## Learning Laravel
|
||||
|
||||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. You can also check out [Laravel Learn](https://laravel.com/learn), where you will be guided through building a modern Laravel application.
|
||||
|
||||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||
|
||||
## Laravel Sponsors
|
||||
|
||||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
|
||||
|
||||
### Premium Partners
|
||||
|
||||
- **[Vehikl](https://vehikl.com)**
|
||||
- **[Tighten Co.](https://tighten.co)**
|
||||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||
- **[64 Robots](https://64robots.com)**
|
||||
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
|
||||
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
|
||||
- **[Redberry](https://redberry.international/laravel-development)**
|
||||
- **[Active Logic](https://activelogic.com)**
|
||||
|
||||
## Contributing
|
||||
|
||||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||
|
||||
## Security Vulnerabilities
|
||||
|
||||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||
|
||||
## License
|
||||
|
||||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
64
api/chat.php
64
api/chat.php
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once __DIR__ . '/../db/config.php';
|
||||
require_once __DIR__ . '/../ai/LocalAIApi.php';
|
||||
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
$message = $input['message'] ?? '';
|
||||
|
||||
if (empty($message)) {
|
||||
echo json_encode(['reply' => "I didn't catch that. Could you repeat?"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
// 1. Fetch Knowledge Base (FAQs)
|
||||
$stmt = db()->query("SELECT keywords, answer FROM faqs");
|
||||
$faqs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$knowledgeBase = "Here is the knowledge base for this website:\n\n";
|
||||
foreach ($faqs as $faq) {
|
||||
$knowledgeBase .= "Q: " . $faq['keywords'] . "\nA: " . $faq['answer'] . "\n---\n";
|
||||
}
|
||||
|
||||
// 2. Construct Prompt for AI
|
||||
$systemPrompt = "You are a helpful, friendly AI assistant for this website. " .
|
||||
"Use the provided Knowledge Base to answer user questions accurately. " .
|
||||
"If the answer is found in the Knowledge Base, rephrase it naturally. " .
|
||||
"If the answer is NOT in the Knowledge Base, use your general knowledge to help, " .
|
||||
"but politely mention that you don't have specific information about that if it seems like a site-specific question. " .
|
||||
"Keep answers concise and professional.\n\n" .
|
||||
$knowledgeBase;
|
||||
|
||||
// 3. Call AI API
|
||||
$response = LocalAIApi::createResponse([
|
||||
'model' => 'gpt-4o-mini',
|
||||
'input' => [
|
||||
['role' => 'system', 'content' => $systemPrompt],
|
||||
['role' => 'user', 'content' => $message],
|
||||
]
|
||||
]);
|
||||
|
||||
if (!empty($response['success'])) {
|
||||
$aiReply = LocalAIApi::extractText($response);
|
||||
|
||||
// 4. Save to Database
|
||||
try {
|
||||
$stmt = db()->prepare("INSERT INTO messages (user_message, ai_response) VALUES (?, ?)");
|
||||
$stmt->execute([$message, $aiReply]);
|
||||
} catch (Exception $e) {
|
||||
error_log("DB Save Error: " . $e->getMessage());
|
||||
// Continue even if save fails, so the user still gets a reply
|
||||
}
|
||||
|
||||
echo json_encode(['reply' => $aiReply]);
|
||||
} else {
|
||||
// Fallback if AI fails
|
||||
error_log("AI Error: " . ($response['error'] ?? 'Unknown'));
|
||||
echo json_encode(['reply' => "I'm having trouble connecting to my brain right now. Please try again later."]);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log("Chat Error: " . $e->getMessage());
|
||||
echo json_encode(['reply' => "An internal error occurred."]);
|
||||
}
|
||||
@ -1,91 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../db/config.php';
|
||||
require_once __DIR__ . '/../ai/LocalAIApi.php';
|
||||
|
||||
// Get Telegram Update
|
||||
$content = file_get_contents("php://input");
|
||||
$update = json_decode($content, true);
|
||||
|
||||
if (!$update || !isset($update['message'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$message = $update['message'];
|
||||
$chatId = $message['chat']['id'];
|
||||
$text = $message['text'] ?? '';
|
||||
|
||||
if (empty($text)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get Telegram Token from DB
|
||||
$stmt = db()->query("SELECT setting_value FROM settings WHERE setting_key = 'telegram_token'");
|
||||
$token = $stmt->fetchColumn();
|
||||
|
||||
if (!$token) {
|
||||
error_log("Telegram Error: No bot token found in settings.");
|
||||
exit;
|
||||
}
|
||||
|
||||
function sendTelegramMessage($chatId, $text, $token) {
|
||||
$url = "https://api.telegram.org/bot$token/sendMessage";
|
||||
$data = [
|
||||
'chat_id' => $chatId,
|
||||
'text' => $text,
|
||||
'parse_mode' => 'Markdown'
|
||||
];
|
||||
|
||||
$options = [
|
||||
'http' => [
|
||||
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
||||
'method' => 'POST',
|
||||
'content' => http_build_query($data),
|
||||
],
|
||||
];
|
||||
$context = stream_context_create($options);
|
||||
return file_get_contents($url, false, $context);
|
||||
}
|
||||
|
||||
// Process with AI (Similar logic to api/chat.php)
|
||||
try {
|
||||
// 1. Fetch Knowledge Base
|
||||
$stmt = db()->query("SELECT keywords, answer FROM faqs");
|
||||
$faqs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$knowledgeBase = "Here is the knowledge base for this website:\n\n";
|
||||
foreach ($faqs as $faq) {
|
||||
$knowledgeBase .= "Q: " . $faq['keywords'] . "\nA: " . $faq['answer'] . "\n---\n";
|
||||
}
|
||||
|
||||
$systemPrompt = "You are a helpful AI assistant integrated with Telegram. " .
|
||||
"Use the provided Knowledge Base to answer user questions. " .
|
||||
"Keep answers concise for mobile reading. Use Markdown for formatting.\n\n" .
|
||||
$knowledgeBase;
|
||||
|
||||
// 2. Call AI
|
||||
$response = LocalAIApi::createResponse([
|
||||
'model' => 'gpt-4o-mini',
|
||||
'input' => [
|
||||
['role' => 'system', 'content' => $systemPrompt],
|
||||
['role' => 'user', 'content' => $text],
|
||||
]
|
||||
]);
|
||||
|
||||
if (!empty($response['success'])) {
|
||||
$aiReply = LocalAIApi::extractText($response);
|
||||
|
||||
// 3. Save History
|
||||
try {
|
||||
$stmt = db()->prepare("INSERT INTO messages (user_message, ai_response) VALUES (?, ?)");
|
||||
$stmt->execute(["[Telegram] " . $text, $aiReply]);
|
||||
} catch (Exception $e) {}
|
||||
|
||||
// 4. Send back to Telegram
|
||||
sendTelegramMessage($chatId, $aiReply, $token);
|
||||
} else {
|
||||
sendTelegramMessage($chatId, "I'm sorry, I encountered an error processing your request.", $token);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
error_log("Telegram Webhook Error: " . $e->getMessage());
|
||||
}
|
||||
547
app.php
547
app.php
@ -1,547 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/db/config.php';
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
function h(?string $value): string
|
||||
{
|
||||
return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
function app_name(): string
|
||||
{
|
||||
return trim((string) ($_SERVER['PROJECT_NAME'] ?? 'TaxiLanz')) ?: 'TaxiLanz';
|
||||
}
|
||||
|
||||
function project_description_fallback(): string
|
||||
{
|
||||
$envDescription = trim((string) ($_SERVER['PROJECT_DESCRIPTION'] ?? ''));
|
||||
if ($envDescription !== '') {
|
||||
return $envDescription;
|
||||
}
|
||||
|
||||
return 'TaxiLanz is a web MVP for taxi requests, contextual offers, and fast booking attribution for restaurants and experiences.';
|
||||
}
|
||||
|
||||
function asset_url(string $path): string
|
||||
{
|
||||
$fullPath = __DIR__ . '/' . ltrim($path, '/');
|
||||
$version = file_exists($fullPath) ? (string) filemtime($fullPath) : (string) time();
|
||||
|
||||
return ltrim($path, '/') . '?v=' . urlencode($version);
|
||||
}
|
||||
|
||||
function destination_options(): array
|
||||
{
|
||||
return [
|
||||
'airport' => 'Airport / arrivals',
|
||||
'marina' => 'Marina / waterfront',
|
||||
'old-town' => 'Old Town / historic center',
|
||||
'beach-strip' => 'Beach strip',
|
||||
'volcano-route' => 'Volcano route / excursion area',
|
||||
];
|
||||
}
|
||||
|
||||
function source_channel_options(): array
|
||||
{
|
||||
return [
|
||||
'hotel' => 'Hotel desk',
|
||||
'web' => 'Website',
|
||||
'reception' => 'Reception',
|
||||
'partner' => 'Partner concierge',
|
||||
];
|
||||
}
|
||||
|
||||
function source_channel_label(string $key): string
|
||||
{
|
||||
$channels = source_channel_options();
|
||||
return $channels[$key] ?? ucfirst(str_replace('-', ' ', $key));
|
||||
}
|
||||
|
||||
function destination_label(string $key): string
|
||||
{
|
||||
$destinations = destination_options();
|
||||
return $destinations[$key] ?? ucfirst(str_replace('-', ' ', $key));
|
||||
}
|
||||
|
||||
function offer_catalog(): array
|
||||
{
|
||||
return [
|
||||
'harbor-lunch' => [
|
||||
'slug' => 'harbor-lunch',
|
||||
'title' => 'Harbor Lunch Terrace',
|
||||
'sector' => 'Restaurant',
|
||||
'description' => 'A polished lunch stop with sea views, fast table turnover, and vegetarian options for travelers arriving near the marina.',
|
||||
'location' => 'Marina',
|
||||
'price_from' => 28,
|
||||
'duration' => '60–75 min',
|
||||
'quality' => 94,
|
||||
'strategic' => 6,
|
||||
'time_fit' => ['lunch', 'afternoon'],
|
||||
'destinations' => ['marina' => 18, 'airport' => 8],
|
||||
'commission' => '12%',
|
||||
'availability' => 'Open daily · 12:00–18:00',
|
||||
'meeting_point' => '3 minutes from the waterfront drop-off',
|
||||
],
|
||||
'sunset-wine' => [
|
||||
'slug' => 'sunset-wine',
|
||||
'title' => 'Sunset Wine Tasting',
|
||||
'sector' => 'Experience',
|
||||
'description' => 'A small-group tasting with island wines, designed for couples and premium travelers heading toward scenic evening areas.',
|
||||
'location' => 'Volcano route',
|
||||
'price_from' => 45,
|
||||
'duration' => '90 min',
|
||||
'quality' => 92,
|
||||
'strategic' => 7,
|
||||
'time_fit' => ['sunset', 'night'],
|
||||
'destinations' => ['volcano-route' => 20, 'old-town' => 9],
|
||||
'commission' => '14%',
|
||||
'availability' => 'Limited seats · 17:30–21:00',
|
||||
'meeting_point' => 'Pickup-friendly venue by the ridge viewpoint',
|
||||
],
|
||||
'old-town-tapas' => [
|
||||
'slug' => 'old-town-tapas',
|
||||
'title' => 'Old Town Tapas Table',
|
||||
'sector' => 'Restaurant',
|
||||
'description' => 'A trusted tapas venue with flexible seating for spontaneous arrivals and a menu suited to mixed groups.',
|
||||
'location' => 'Old Town',
|
||||
'price_from' => 24,
|
||||
'duration' => '75 min',
|
||||
'quality' => 90,
|
||||
'strategic' => 5,
|
||||
'time_fit' => ['lunch', 'night'],
|
||||
'destinations' => ['old-town' => 20, 'marina' => 7],
|
||||
'commission' => '11%',
|
||||
'availability' => 'Walk-ins prioritized · 13:00–23:00',
|
||||
'meeting_point' => 'Just inside the historic pedestrian zone',
|
||||
],
|
||||
'beach-club-pass' => [
|
||||
'slug' => 'beach-club-pass',
|
||||
'title' => 'Beach Club Day Pass',
|
||||
'sector' => 'Experience',
|
||||
'description' => 'A relaxed day-pass option with loungers, showers, and easy handoff from taxi to venue staff.',
|
||||
'location' => 'Beach strip',
|
||||
'price_from' => 39,
|
||||
'duration' => 'Half day',
|
||||
'quality' => 88,
|
||||
'strategic' => 6,
|
||||
'time_fit' => ['breakfast', 'lunch', 'afternoon'],
|
||||
'destinations' => ['beach-strip' => 20, 'marina' => 8],
|
||||
'commission' => '10%',
|
||||
'availability' => 'Best before 17:00',
|
||||
'meeting_point' => 'Dedicated taxi bay at the entrance',
|
||||
],
|
||||
'family-brunch' => [
|
||||
'slug' => 'family-brunch',
|
||||
'title' => 'Family Brunch Patio',
|
||||
'sector' => 'Restaurant',
|
||||
'description' => 'Comfortable seating, quick service, and child-friendly portions for airport arrivals or early drop-offs.',
|
||||
'location' => 'Airport corridor',
|
||||
'price_from' => 22,
|
||||
'duration' => '50 min',
|
||||
'quality' => 87,
|
||||
'strategic' => 4,
|
||||
'time_fit' => ['breakfast', 'lunch'],
|
||||
'destinations' => ['airport' => 18, 'beach-strip' => 6],
|
||||
'commission' => '9%',
|
||||
'availability' => 'Open from 08:00',
|
||||
'meeting_point' => 'Along the arrivals-to-resort route',
|
||||
],
|
||||
'chef-table' => [
|
||||
'slug' => 'chef-table',
|
||||
'title' => 'Chef Table Reserve',
|
||||
'sector' => 'Restaurant',
|
||||
'description' => 'A higher-value dinner reservation with premium conversion potential and a clear confirmation flow.',
|
||||
'location' => 'Marina',
|
||||
'price_from' => 62,
|
||||
'duration' => '120 min',
|
||||
'quality' => 95,
|
||||
'strategic' => 8,
|
||||
'time_fit' => ['night'],
|
||||
'destinations' => ['marina' => 14, 'old-town' => 10, 'beach-strip' => 8],
|
||||
'commission' => '16%',
|
||||
'availability' => 'Reservation only · 19:00–23:30',
|
||||
'meeting_point' => 'Inside the marina promenade',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
function current_time_bucket(DateTimeImmutable $dateTime): string
|
||||
{
|
||||
$hour = (int) $dateTime->format('G');
|
||||
|
||||
if ($hour < 11) {
|
||||
return 'breakfast';
|
||||
}
|
||||
if ($hour < 15) {
|
||||
return 'lunch';
|
||||
}
|
||||
if ($hour < 18) {
|
||||
return 'afternoon';
|
||||
}
|
||||
if ($hour < 21) {
|
||||
return 'sunset';
|
||||
}
|
||||
|
||||
return 'night';
|
||||
}
|
||||
|
||||
function recommend_offers(string $destinationArea, string $pickupTime, int $limit = 3): array
|
||||
{
|
||||
$catalog = offer_catalog();
|
||||
$dateTime = new DateTimeImmutable($pickupTime);
|
||||
$timeBucket = current_time_bucket($dateTime);
|
||||
$scored = [];
|
||||
|
||||
foreach ($catalog as $offer) {
|
||||
$destinationScore = $offer['destinations'][$destinationArea] ?? 0;
|
||||
$timeScore = in_array($timeBucket, $offer['time_fit'], true) ? 14 : 4;
|
||||
$qualityScore = (int) round($offer['quality'] / 10);
|
||||
$strategicScore = (int) $offer['strategic'];
|
||||
$score = $destinationScore + $timeScore + $qualityScore + $strategicScore;
|
||||
|
||||
$reasons = [];
|
||||
if ($destinationScore >= 14) {
|
||||
$reasons[] = 'Strong geographic fit for ' . strtolower(destination_label($destinationArea));
|
||||
}
|
||||
if ($timeScore >= 14) {
|
||||
$reasons[] = 'Best matched to the current arrival window';
|
||||
}
|
||||
if ($offer['quality'] >= 92) {
|
||||
$reasons[] = 'High validation score for a premium first recommendation';
|
||||
}
|
||||
if ($reasons === []) {
|
||||
$reasons[] = 'Qualified fallback with suitable availability and commission potential';
|
||||
}
|
||||
|
||||
$offer['score'] = $score;
|
||||
$offer['reasons'] = array_slice($reasons, 0, 2);
|
||||
$scored[] = $offer;
|
||||
}
|
||||
|
||||
usort($scored, static function (array $a, array $b): int {
|
||||
return $b['score'] <=> $a['score'];
|
||||
});
|
||||
|
||||
return array_slice($scored, 0, $limit);
|
||||
}
|
||||
|
||||
function estimate_eta_minutes(string $destinationArea): int
|
||||
{
|
||||
return [
|
||||
'airport' => 7,
|
||||
'marina' => 8,
|
||||
'old-town' => 10,
|
||||
'beach-strip' => 12,
|
||||
'volcano-route' => 14,
|
||||
][$destinationArea] ?? 9;
|
||||
}
|
||||
|
||||
function ensure_schema(): void
|
||||
{
|
||||
static $initialized = false;
|
||||
|
||||
if ($initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
db()->exec(
|
||||
'CREATE TABLE IF NOT EXISTS taxi_requests (
|
||||
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||||
passenger_name VARCHAR(120) NOT NULL,
|
||||
pickup_point VARCHAR(160) NOT NULL,
|
||||
destination_area VARCHAR(80) NOT NULL,
|
||||
pickup_time DATETIME NOT NULL,
|
||||
source_channel VARCHAR(40) NOT NULL,
|
||||
party_size TINYINT UNSIGNED NOT NULL DEFAULT 1,
|
||||
notes VARCHAR(255) DEFAULT NULL,
|
||||
status VARCHAR(40) NOT NULL DEFAULT "requested",
|
||||
recommendation_status VARCHAR(40) NOT NULL DEFAULT "shown",
|
||||
recommended_offer_slugs VARCHAR(255) DEFAULT NULL,
|
||||
recommendation_clicked_slug VARCHAR(80) DEFAULT NULL,
|
||||
booked_offer_slug VARCHAR(80) DEFAULT NULL,
|
||||
booked_offer_title VARCHAR(160) DEFAULT NULL,
|
||||
booking_status VARCHAR(40) DEFAULT NULL,
|
||||
booking_started_at DATETIME DEFAULT NULL,
|
||||
booking_completed_at DATETIME DEFAULT NULL,
|
||||
created_at DATETIME NOT NULL,
|
||||
updated_at DATETIME NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci'
|
||||
);
|
||||
|
||||
$initialized = true;
|
||||
}
|
||||
|
||||
function create_taxi_request(array $input): int
|
||||
{
|
||||
ensure_schema();
|
||||
|
||||
$recommendedOffers = recommend_offers($input['destination_area'], $input['pickup_time']);
|
||||
$recommendedSlugs = implode(',', array_column($recommendedOffers, 'slug'));
|
||||
$now = date('Y-m-d H:i:s');
|
||||
|
||||
$statement = db()->prepare(
|
||||
'INSERT INTO taxi_requests (
|
||||
passenger_name,
|
||||
pickup_point,
|
||||
destination_area,
|
||||
pickup_time,
|
||||
source_channel,
|
||||
party_size,
|
||||
notes,
|
||||
status,
|
||||
recommendation_status,
|
||||
recommended_offer_slugs,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
:passenger_name,
|
||||
:pickup_point,
|
||||
:destination_area,
|
||||
:pickup_time,
|
||||
:source_channel,
|
||||
:party_size,
|
||||
:notes,
|
||||
:status,
|
||||
:recommendation_status,
|
||||
:recommended_offer_slugs,
|
||||
:created_at,
|
||||
:updated_at
|
||||
)'
|
||||
);
|
||||
|
||||
$statement->bindValue(':passenger_name', $input['passenger_name']);
|
||||
$statement->bindValue(':pickup_point', $input['pickup_point']);
|
||||
$statement->bindValue(':destination_area', $input['destination_area']);
|
||||
$statement->bindValue(':pickup_time', $input['pickup_time']);
|
||||
$statement->bindValue(':source_channel', $input['source_channel']);
|
||||
$statement->bindValue(':party_size', (int) $input['party_size'], PDO::PARAM_INT);
|
||||
$statement->bindValue(':notes', $input['notes'] !== '' ? $input['notes'] : null);
|
||||
$statement->bindValue(':status', 'confirmed');
|
||||
$statement->bindValue(':recommendation_status', 'shown');
|
||||
$statement->bindValue(':recommended_offer_slugs', $recommendedSlugs !== '' ? $recommendedSlugs : null);
|
||||
$statement->bindValue(':created_at', $now);
|
||||
$statement->bindValue(':updated_at', $now);
|
||||
$statement->execute();
|
||||
|
||||
return (int) db()->lastInsertId();
|
||||
}
|
||||
|
||||
function fetch_request(int $id): ?array
|
||||
{
|
||||
ensure_schema();
|
||||
|
||||
$statement = db()->prepare('SELECT * FROM taxi_requests WHERE id = :id LIMIT 1');
|
||||
$statement->bindValue(':id', $id, PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
$record = $statement->fetch();
|
||||
|
||||
return $record ?: null;
|
||||
}
|
||||
|
||||
function fetch_requests(int $limit = 12): array
|
||||
{
|
||||
ensure_schema();
|
||||
|
||||
$statement = db()->prepare('SELECT * FROM taxi_requests ORDER BY created_at DESC LIMIT :limit');
|
||||
$statement->bindValue(':limit', $limit, PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
return $statement->fetchAll();
|
||||
}
|
||||
|
||||
function fetch_dashboard_stats(): array
|
||||
{
|
||||
ensure_schema();
|
||||
|
||||
$totalRequests = (int) db()->query('SELECT COUNT(*) FROM taxi_requests')->fetchColumn();
|
||||
$clicked = (int) db()->query('SELECT COUNT(*) FROM taxi_requests WHERE recommendation_clicked_slug IS NOT NULL')->fetchColumn();
|
||||
$booked = (int) db()->query('SELECT COUNT(*) FROM taxi_requests WHERE booked_offer_slug IS NOT NULL')->fetchColumn();
|
||||
$avgDelay = db()->query('SELECT AVG(TIMESTAMPDIFF(MINUTE, created_at, booking_completed_at)) FROM taxi_requests WHERE booking_completed_at IS NOT NULL')->fetchColumn();
|
||||
|
||||
return [
|
||||
'total_requests' => $totalRequests,
|
||||
'offers_clicked' => $clicked,
|
||||
'bookings' => $booked,
|
||||
'ctr' => $totalRequests > 0 ? round(($clicked / $totalRequests) * 100, 1) : 0,
|
||||
'conversion' => $totalRequests > 0 ? round(($booked / $totalRequests) * 100, 1) : 0,
|
||||
'avg_delay' => $avgDelay !== null ? (int) round((float) $avgDelay) : null,
|
||||
];
|
||||
}
|
||||
|
||||
function hydrate_recommended_offers(array $request): array
|
||||
{
|
||||
$recommended = recommend_offers((string) $request['destination_area'], (string) $request['pickup_time']);
|
||||
$recommendedBySlug = [];
|
||||
|
||||
foreach ($recommended as $offer) {
|
||||
$recommendedBySlug[$offer['slug']] = $offer;
|
||||
}
|
||||
|
||||
$slugs = array_filter(array_map('trim', explode(',', (string) ($request['recommended_offer_slugs'] ?? ''))));
|
||||
$offers = [];
|
||||
|
||||
foreach ($slugs as $slug) {
|
||||
if (isset($recommendedBySlug[$slug])) {
|
||||
$offers[] = $recommendedBySlug[$slug];
|
||||
}
|
||||
}
|
||||
|
||||
return $offers !== [] ? $offers : $recommended;
|
||||
}
|
||||
|
||||
function offer_by_slug(string $slug): ?array
|
||||
{
|
||||
$catalog = offer_catalog();
|
||||
return $catalog[$slug] ?? null;
|
||||
}
|
||||
|
||||
function book_offer(int $requestId, string $offerSlug): bool
|
||||
{
|
||||
ensure_schema();
|
||||
|
||||
$offer = offer_by_slug($offerSlug);
|
||||
if ($offer === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$statement = db()->prepare(
|
||||
'UPDATE taxi_requests
|
||||
SET recommendation_clicked_slug = :clicked_slug,
|
||||
booked_offer_slug = :booked_offer_slug,
|
||||
booked_offer_title = :booked_offer_title,
|
||||
booking_status = :booking_status,
|
||||
booking_started_at = COALESCE(booking_started_at, :booking_started_at),
|
||||
booking_completed_at = :booking_completed_at,
|
||||
status = :status,
|
||||
updated_at = :updated_at
|
||||
WHERE id = :id'
|
||||
);
|
||||
|
||||
$statement->bindValue(':clicked_slug', $offerSlug);
|
||||
$statement->bindValue(':booked_offer_slug', $offerSlug);
|
||||
$statement->bindValue(':booked_offer_title', $offer['title']);
|
||||
$statement->bindValue(':booking_status', 'confirmed');
|
||||
$statement->bindValue(':booking_started_at', $now);
|
||||
$statement->bindValue(':booking_completed_at', $now);
|
||||
$statement->bindValue(':status', 'offer_booked');
|
||||
$statement->bindValue(':updated_at', $now);
|
||||
$statement->bindValue(':id', $requestId, PDO::PARAM_INT);
|
||||
|
||||
return $statement->execute();
|
||||
}
|
||||
|
||||
function status_badge_class(string $status): string
|
||||
{
|
||||
return match ($status) {
|
||||
'offer_booked' => 'text-bg-success',
|
||||
'confirmed' => 'text-bg-dark',
|
||||
default => 'text-bg-secondary',
|
||||
};
|
||||
}
|
||||
|
||||
function render_head(string $title, string $description, string $robots = 'index,follow'): void
|
||||
{
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title><?= h($title) ?></title>
|
||||
<meta name="description" content="<?= h($description) ?>">
|
||||
<meta name="robots" content="<?= h($robots) ?>">
|
||||
<meta name="theme-color" content="#111827">
|
||||
<?php if ($projectDescription): ?>
|
||||
<meta property="og:description" content="<?= h($projectDescription) ?>">
|
||||
<meta property="twitter:description" content="<?= h($projectDescription) ?>">
|
||||
<?php else: ?>
|
||||
<meta property="og:description" content="<?= h($description) ?>">
|
||||
<meta property="twitter:description" content="<?= h($description) ?>">
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<meta property="og:image" content="<?= h($projectImageUrl) ?>">
|
||||
<meta property="twitter:image" content="<?= h($projectImageUrl) ?>">
|
||||
<?php endif; ?>
|
||||
<meta property="og:title" content="<?= h($title) ?>">
|
||||
<meta property="twitter:title" content="<?= h($title) ?>">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
|
||||
<link href="<?= h(asset_url('assets/css/custom.css')) ?>" rel="stylesheet">
|
||||
</head>
|
||||
<?php
|
||||
}
|
||||
|
||||
function render_header(string $active = 'home'): void
|
||||
{
|
||||
$stats = fetch_dashboard_stats();
|
||||
?>
|
||||
<body>
|
||||
<div class="app-shell">
|
||||
<header class="border-bottom bg-white sticky-top">
|
||||
<nav class="navbar navbar-expand-lg navbar-light py-3">
|
||||
<div class="container">
|
||||
<a class="navbar-brand fw-semibold d-flex align-items-center gap-2" href="/">
|
||||
<span class="brand-mark"><i class="bi bi-taxi-front"></i></span>
|
||||
<span><?= h(app_name()) ?></span>
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mainNav" aria-controls="mainNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="mainNav">
|
||||
<ul class="navbar-nav ms-auto align-items-lg-center gap-lg-2">
|
||||
<li class="nav-item"><a class="nav-link <?= $active === 'home' ? 'active' : '' ?>" href="/">Taxi flow</a></li>
|
||||
<li class="nav-item"><a class="nav-link <?= $active === 'operations' ? 'active' : '' ?>" href="/requests.php">Operations board</a></li>
|
||||
<li class="nav-item"><a class="nav-link <?= $active === 'health' ? 'active' : '' ?>" href="/healthz.php">Health</a></li>
|
||||
<li class="nav-item ms-lg-2">
|
||||
<span class="mini-stat">
|
||||
<strong><?= (int) $stats['total_requests'] ?></strong>
|
||||
<span>taxi requests</span>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
<?php
|
||||
}
|
||||
|
||||
function render_footer(?string $toastMessage = null): void
|
||||
{
|
||||
?>
|
||||
</main>
|
||||
<footer class="border-top bg-white">
|
||||
<div class="container py-4 d-flex flex-column flex-md-row justify-content-between gap-3 small text-secondary">
|
||||
<div>
|
||||
<div class="fw-semibold text-dark mb-1"><?= h(app_name()) ?> · Taxi → Booking MVP</div>
|
||||
<div>Thin slice for taxi confirmation, contextual offers, and booking attribution.</div>
|
||||
</div>
|
||||
<div class="d-flex gap-3 align-items-start">
|
||||
<a href="/" class="footer-link">New taxi request</a>
|
||||
<a href="/requests.php" class="footer-link">Review requests</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
<div class="toast-container position-fixed bottom-0 end-0 p-3">
|
||||
<div id="appToast" class="toast align-items-center text-bg-dark border-0" role="status" aria-live="polite" aria-atomic="true" data-toast-message="<?= h($toastMessage ?? '') ?>">
|
||||
<div class="d-flex">
|
||||
<div class="toast-body"></div>
|
||||
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
||||
<script src="<?= h(asset_url('assets/js/main.js')) ?>"></script>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
140
app/Filament/Resources/BookingResource.php
Normal file
140
app/Filament/Resources/BookingResource.php
Normal file
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\BookingResource\Pages;
|
||||
use App\Filament\Resources\BookingResource\RelationManagers;
|
||||
use App\Models\Booking;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class BookingResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Booking::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('uuid')
|
||||
->label('UUID')
|
||||
->required()
|
||||
->maxLength(36),
|
||||
Forms\Components\Select::make('ride_id')
|
||||
->relationship('ride', 'id')
|
||||
->default(null),
|
||||
Forms\Components\Select::make('offer_id')
|
||||
->relationship('offer', 'title')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('ride_recommendation_id')
|
||||
->numeric()
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('customer_name')
|
||||
->maxLength(255)
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('customer_email')
|
||||
->email()
|
||||
->maxLength(255)
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('customer_phone')
|
||||
->tel()
|
||||
->maxLength(255)
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('party_size')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(1),
|
||||
Forms\Components\DateTimePicker::make('booking_for'),
|
||||
Forms\Components\TextInput::make('status')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('amount')
|
||||
->numeric()
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('commission_amount')
|
||||
->numeric()
|
||||
->default(null),
|
||||
Forms\Components\Textarea::make('notes')
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('uuid')
|
||||
->label('UUID')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('ride.id')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('offer.title')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('ride_recommendation_id')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('customer_name')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('customer_email')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('customer_phone')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('party_size')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('booking_for')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('status'),
|
||||
Tables\Columns\TextColumn::make('amount')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('commission_amount')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListBookings::route('/'),
|
||||
'create' => Pages\CreateBooking::route('/create'),
|
||||
'edit' => Pages\EditBooking::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BookingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\BookingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateBooking extends CreateRecord
|
||||
{
|
||||
protected static string $resource = BookingResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/BookingResource/Pages/EditBooking.php
Normal file
19
app/Filament/Resources/BookingResource/Pages/EditBooking.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BookingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\BookingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditBooking extends EditRecord
|
||||
{
|
||||
protected static string $resource = BookingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\BookingResource\Pages;
|
||||
|
||||
use App\Filament\Resources\BookingResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListBookings extends ListRecords
|
||||
{
|
||||
protected static string $resource = BookingResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
100
app/Filament/Resources/EventResource.php
Normal file
100
app/Filament/Resources/EventResource.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\EventResource\Pages;
|
||||
use App\Filament\Resources\EventResource\RelationManagers;
|
||||
use App\Models\Event;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class EventResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Event::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('event_type')
|
||||
->required(),
|
||||
Forms\Components\Select::make('ride_id')
|
||||
->relationship('ride', 'id')
|
||||
->default(null),
|
||||
Forms\Components\Select::make('offer_id')
|
||||
->relationship('offer', 'title')
|
||||
->default(null),
|
||||
Forms\Components\Select::make('booking_id')
|
||||
->relationship('booking', 'id')
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('ride_recommendation_id')
|
||||
->numeric()
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('session_id')
|
||||
->maxLength(255)
|
||||
->default(null),
|
||||
Forms\Components\Textarea::make('meta')
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('event_type'),
|
||||
Tables\Columns\TextColumn::make('ride.id')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('offer.title')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('booking.id')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('ride_recommendation_id')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('session_id')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListEvents::route('/'),
|
||||
'create' => Pages\CreateEvent::route('/create'),
|
||||
'edit' => Pages\EditEvent::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
12
app/Filament/Resources/EventResource/Pages/CreateEvent.php
Normal file
12
app/Filament/Resources/EventResource/Pages/CreateEvent.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EventResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EventResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateEvent extends CreateRecord
|
||||
{
|
||||
protected static string $resource = EventResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/EventResource/Pages/EditEvent.php
Normal file
19
app/Filament/Resources/EventResource/Pages/EditEvent.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EventResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EventResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditEvent extends EditRecord
|
||||
{
|
||||
protected static string $resource = EventResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/EventResource/Pages/ListEvents.php
Normal file
19
app/Filament/Resources/EventResource/Pages/ListEvents.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\EventResource\Pages;
|
||||
|
||||
use App\Filament\Resources\EventResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListEvents extends ListRecords
|
||||
{
|
||||
protected static string $resource = EventResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
147
app/Filament/Resources/OfferResource.php
Normal file
147
app/Filament/Resources/OfferResource.php
Normal file
@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\OfferResource\Pages;
|
||||
use App\Filament\Resources\OfferResource\RelationManagers;
|
||||
use App\Models\Offer;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class OfferResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Offer::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('uuid')
|
||||
->label('UUID')
|
||||
->required()
|
||||
->maxLength(36),
|
||||
Forms\Components\TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('slug')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('category')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('excerpt')
|
||||
->maxLength(255)
|
||||
->default(null),
|
||||
Forms\Components\Textarea::make('description')
|
||||
->columnSpanFull(),
|
||||
Forms\Components\TextInput::make('location_label')
|
||||
->maxLength(255)
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('lat')
|
||||
->numeric()
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('lng')
|
||||
->numeric()
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('price_from')
|
||||
->numeric()
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('duration_minutes')
|
||||
->numeric()
|
||||
->default(null),
|
||||
Forms\Components\FileUpload::make('image_url')
|
||||
->image(),
|
||||
Forms\Components\TextInput::make('status')
|
||||
->required(),
|
||||
Forms\Components\Toggle::make('is_featured')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('priority_score')
|
||||
->required()
|
||||
->numeric()
|
||||
->default(0),
|
||||
Forms\Components\Toggle::make('available_now')
|
||||
->required(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('uuid')
|
||||
->label('UUID')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('title')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('slug')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('category'),
|
||||
Tables\Columns\TextColumn::make('excerpt')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('location_label')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('lat')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('lng')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('price_from')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('duration_minutes')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\ImageColumn::make('image_url'),
|
||||
Tables\Columns\TextColumn::make('status'),
|
||||
Tables\Columns\IconColumn::make('is_featured')
|
||||
->boolean(),
|
||||
Tables\Columns\TextColumn::make('priority_score')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\IconColumn::make('available_now')
|
||||
->boolean(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListOffers::route('/'),
|
||||
'create' => Pages\CreateOffer::route('/create'),
|
||||
'edit' => Pages\EditOffer::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
12
app/Filament/Resources/OfferResource/Pages/CreateOffer.php
Normal file
12
app/Filament/Resources/OfferResource/Pages/CreateOffer.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\OfferResource\Pages;
|
||||
|
||||
use App\Filament\Resources\OfferResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateOffer extends CreateRecord
|
||||
{
|
||||
protected static string $resource = OfferResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/OfferResource/Pages/EditOffer.php
Normal file
19
app/Filament/Resources/OfferResource/Pages/EditOffer.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\OfferResource\Pages;
|
||||
|
||||
use App\Filament\Resources\OfferResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditOffer extends EditRecord
|
||||
{
|
||||
protected static string $resource = OfferResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/OfferResource/Pages/ListOffers.php
Normal file
19
app/Filament/Resources/OfferResource/Pages/ListOffers.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\OfferResource\Pages;
|
||||
|
||||
use App\Filament\Resources\OfferResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListOffers extends ListRecords
|
||||
{
|
||||
protected static string $resource = OfferResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
137
app/Filament/Resources/RideResource.php
Normal file
137
app/Filament/Resources/RideResource.php
Normal file
@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\RideResource\Pages;
|
||||
use App\Filament\Resources\RideResource\RelationManagers;
|
||||
use App\Models\Ride;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class RideResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Ride::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('uuid')
|
||||
->label('UUID')
|
||||
->required()
|
||||
->maxLength(36),
|
||||
Forms\Components\TextInput::make('pickup_label')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('pickup_lat')
|
||||
->numeric()
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('pickup_lng')
|
||||
->numeric()
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('destination_label')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\TextInput::make('destination_lat')
|
||||
->numeric()
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('destination_lng')
|
||||
->numeric()
|
||||
->default(null),
|
||||
Forms\Components\DateTimePicker::make('scheduled_for'),
|
||||
Forms\Components\TextInput::make('status')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('eta_minutes')
|
||||
->numeric()
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('source_channel')
|
||||
->required(),
|
||||
Forms\Components\TextInput::make('context_zone')
|
||||
->maxLength(255)
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('locale')
|
||||
->maxLength(10)
|
||||
->default(null),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('uuid')
|
||||
->label('UUID')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('pickup_label')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('pickup_lat')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('pickup_lng')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('destination_label')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('destination_lat')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('destination_lng')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('scheduled_for')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('status'),
|
||||
Tables\Columns\TextColumn::make('eta_minutes')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('source_channel'),
|
||||
Tables\Columns\TextColumn::make('context_zone')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('locale')
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListRides::route('/'),
|
||||
'create' => Pages\CreateRide::route('/create'),
|
||||
'edit' => Pages\EditRide::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
12
app/Filament/Resources/RideResource/Pages/CreateRide.php
Normal file
12
app/Filament/Resources/RideResource/Pages/CreateRide.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RideResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RideResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateRide extends CreateRecord
|
||||
{
|
||||
protected static string $resource = RideResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/RideResource/Pages/EditRide.php
Normal file
19
app/Filament/Resources/RideResource/Pages/EditRide.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RideResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RideResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditRide extends EditRecord
|
||||
{
|
||||
protected static string $resource = RideResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/RideResource/Pages/ListRides.php
Normal file
19
app/Filament/Resources/RideResource/Pages/ListRides.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RideResource\Pages;
|
||||
|
||||
use App\Filament\Resources\RideResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListRides extends ListRecords
|
||||
{
|
||||
protected static string $resource = RideResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
70
app/Http/Controllers/BookingController.php
Normal file
70
app/Http/Controllers/BookingController.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Offer;
|
||||
use App\Models\Ride;
|
||||
use App\Models\RideRecommendation;
|
||||
use App\Services\EventTracker;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class BookingController extends Controller
|
||||
{
|
||||
public function __construct(protected EventTracker $eventTracker)
|
||||
{
|
||||
}
|
||||
|
||||
public function store(Request $request, Offer $offer): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'ride_id' => ['nullable', 'integer', 'exists:rides,id'],
|
||||
'ride_recommendation_id' => ['nullable', 'integer', 'exists:ride_recommendations,id'],
|
||||
'customer_name' => ['required', 'string', 'max:255'],
|
||||
'customer_email' => ['nullable', 'email', 'max:255'],
|
||||
'customer_phone' => ['nullable', 'string', 'max:50'],
|
||||
'party_size' => ['required', 'integer', 'min:1', 'max:12'],
|
||||
'booking_for' => ['nullable', 'date'],
|
||||
'notes' => ['nullable', 'string', 'max:1000'],
|
||||
]);
|
||||
|
||||
$ride = !empty($validated['ride_id']) ? Ride::find($validated['ride_id']) : null;
|
||||
$recommendation = !empty($validated['ride_recommendation_id']) ? RideRecommendation::find($validated['ride_recommendation_id']) : null;
|
||||
|
||||
$booking = Booking::create([
|
||||
'ride_id' => $ride?->id,
|
||||
'offer_id' => $offer->id,
|
||||
'ride_recommendation_id' => $recommendation?->id,
|
||||
'customer_name' => $validated['customer_name'],
|
||||
'customer_email' => $validated['customer_email'] ?? null,
|
||||
'customer_phone' => $validated['customer_phone'] ?? null,
|
||||
'party_size' => $validated['party_size'],
|
||||
'booking_for' => $validated['booking_for'] ?? null,
|
||||
'status' => 'confirmed',
|
||||
'amount' => $offer->price_from,
|
||||
'commission_amount' => $offer->price_from ? round(((float) $offer->price_from) * 0.15, 2) : null,
|
||||
'notes' => $validated['notes'] ?? null,
|
||||
]);
|
||||
|
||||
$this->eventTracker->log('booking_started', $ride, $offer, $booking, $recommendation, [
|
||||
'party_size' => $booking->party_size,
|
||||
]);
|
||||
|
||||
$this->eventTracker->log('booking_completed', $ride, $offer, $booking, $recommendation, [
|
||||
'amount' => $booking->amount,
|
||||
]);
|
||||
|
||||
return redirect()->route('bookings.success', $booking);
|
||||
}
|
||||
|
||||
public function success(Booking $booking): View
|
||||
{
|
||||
$booking->load(['offer', 'ride', 'recommendation']);
|
||||
|
||||
return view('bookings.success', [
|
||||
'booking' => $booking,
|
||||
]);
|
||||
}
|
||||
}
|
||||
8
app/Http/Controllers/Controller.php
Normal file
8
app/Http/Controllers/Controller.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
22
app/Http/Controllers/HomeController.php
Normal file
22
app/Http/Controllers/HomeController.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\Offer;
|
||||
use App\Models\Ride;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
return view('home', [
|
||||
'featuredOffers' => Offer::query()->where('status', 'published')->orderByDesc('is_featured')->orderByDesc('priority_score')->take(3)->get(),
|
||||
'metrics' => [
|
||||
'rides' => Ride::count(),
|
||||
'views' => Event::where('event_type', 'recommendation_viewed')->count(),
|
||||
'bookings' => Event::where('event_type', 'booking_completed')->count(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
48
app/Http/Controllers/OfferController.php
Normal file
48
app/Http/Controllers/OfferController.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Offer;
|
||||
use App\Models\Ride;
|
||||
use App\Models\RideRecommendation;
|
||||
use App\Services\EventTracker;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class OfferController extends Controller
|
||||
{
|
||||
public function __construct(protected EventTracker $eventTracker)
|
||||
{
|
||||
}
|
||||
|
||||
public function show(Request $request, Offer $offer): View
|
||||
{
|
||||
$ride = $request->integer('ride') ? Ride::find($request->integer('ride')) : null;
|
||||
$recommendation = $request->integer('recommendation') ? RideRecommendation::with('offer', 'ride')->find($request->integer('recommendation')) : null;
|
||||
|
||||
if ($recommendation && $recommendation->offer_id === $offer->id) {
|
||||
$this->eventTracker->logOncePerSession(
|
||||
'recommendation_clicked',
|
||||
'rec-clicked-'.$recommendation->id,
|
||||
$ride,
|
||||
$offer,
|
||||
null,
|
||||
$recommendation,
|
||||
['position' => $recommendation->position]
|
||||
);
|
||||
|
||||
if (!$recommendation->was_clicked) {
|
||||
$recommendation->forceFill([
|
||||
'was_clicked' => true,
|
||||
'clicked_at' => now(),
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
|
||||
return view('offers.show', [
|
||||
'offer' => $offer,
|
||||
'ride' => $ride,
|
||||
'recommendation' => $recommendation,
|
||||
]);
|
||||
}
|
||||
}
|
||||
120
app/Http/Controllers/RideController.php
Normal file
120
app/Http/Controllers/RideController.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Ride;
|
||||
use App\Models\RideRecommendation;
|
||||
use App\Services\EventTracker;
|
||||
use App\Services\RecommendationEngine;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class RideController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected RecommendationEngine $recommendationEngine,
|
||||
protected EventTracker $eventTracker,
|
||||
) {
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'pickup_label' => ['required', 'string', 'max:255'],
|
||||
'destination_label' => ['required', 'string', 'max:255'],
|
||||
'scheduled_for' => ['nullable', 'date'],
|
||||
'source_channel' => ['required', 'in:app,hotel,reception,web'],
|
||||
'locale' => ['nullable', 'string', 'max:10'],
|
||||
]);
|
||||
|
||||
$ride = Ride::create([
|
||||
'pickup_label' => $validated['pickup_label'],
|
||||
'destination_label' => $validated['destination_label'],
|
||||
'scheduled_for' => $validated['scheduled_for'] ?? null,
|
||||
'status' => 'confirmed',
|
||||
'eta_minutes' => $this->estimateEta($validated['pickup_label'], $validated['destination_label']),
|
||||
'source_channel' => $validated['source_channel'],
|
||||
'context_zone' => $this->resolveZone($validated['destination_label']),
|
||||
'locale' => $validated['locale'] ?? app()->getLocale(),
|
||||
]);
|
||||
|
||||
$this->eventTracker->log('request_created', $ride, meta: [
|
||||
'source_channel' => $ride->source_channel,
|
||||
'context_zone' => $ride->context_zone,
|
||||
]);
|
||||
|
||||
$this->syncRecommendations($ride);
|
||||
|
||||
return redirect()->route('rides.confirmed', $ride);
|
||||
}
|
||||
|
||||
public function confirmed(Ride $ride): View
|
||||
{
|
||||
$ride->load(['recommendations.offer']);
|
||||
|
||||
if ($ride->recommendations->isEmpty()) {
|
||||
$this->syncRecommendations($ride);
|
||||
$ride->load(['recommendations.offer']);
|
||||
}
|
||||
|
||||
foreach ($ride->recommendations as $recommendation) {
|
||||
$this->eventTracker->logOncePerSession(
|
||||
'recommendation_viewed',
|
||||
'rec-viewed-'.$recommendation->id,
|
||||
$ride,
|
||||
$recommendation->offer,
|
||||
null,
|
||||
$recommendation,
|
||||
['position' => $recommendation->position]
|
||||
);
|
||||
|
||||
if (!$recommendation->was_viewed) {
|
||||
$recommendation->forceFill(['was_viewed' => true])->save();
|
||||
}
|
||||
}
|
||||
|
||||
return view('rides.confirmed', [
|
||||
'ride' => $ride,
|
||||
'recommendations' => $ride->recommendations,
|
||||
]);
|
||||
}
|
||||
|
||||
protected function syncRecommendations(Ride $ride): void
|
||||
{
|
||||
$offers = $this->recommendationEngine->recommendFor($ride, 3);
|
||||
|
||||
$ride->recommendations()->delete();
|
||||
|
||||
foreach ($offers as $index => $offer) {
|
||||
RideRecommendation::create([
|
||||
'ride_id' => $ride->id,
|
||||
'offer_id' => $offer->id,
|
||||
'position' => $index + 1,
|
||||
'score' => $offer->demo_score,
|
||||
'reason' => $offer->demo_reason,
|
||||
'was_viewed' => false,
|
||||
'was_clicked' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function resolveZone(string $destinationLabel): string
|
||||
{
|
||||
$normalized = mb_strtolower($destinationLabel);
|
||||
|
||||
return match (true) {
|
||||
str_contains($normalized, 'beach') => 'beach',
|
||||
str_contains($normalized, 'old town') => 'old town',
|
||||
str_contains($normalized, 'marina') => 'marina',
|
||||
str_contains($normalized, 'center'), str_contains($normalized, 'centre') => 'city center',
|
||||
default => trim($destinationLabel),
|
||||
};
|
||||
}
|
||||
|
||||
protected function estimateEta(string $pickup, string $destination): int
|
||||
{
|
||||
$seed = strlen($pickup) + strlen($destination);
|
||||
return max(4, min(16, ($seed % 13) + 4));
|
||||
}
|
||||
}
|
||||
59
app/Models/Booking.php
Normal file
59
app/Models/Booking.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Booking extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'ride_id',
|
||||
'offer_id',
|
||||
'ride_recommendation_id',
|
||||
'customer_name',
|
||||
'customer_email',
|
||||
'customer_phone',
|
||||
'party_size',
|
||||
'booking_for',
|
||||
'status',
|
||||
'amount',
|
||||
'commission_amount',
|
||||
'notes',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'booking_for' => 'datetime',
|
||||
'amount' => 'decimal:2',
|
||||
'commission_amount' => 'decimal:2',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (Booking $booking) {
|
||||
if (blank($booking->uuid)) {
|
||||
$booking->uuid = (string) Str::uuid();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function ride(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Ride::class);
|
||||
}
|
||||
|
||||
public function offer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Offer::class);
|
||||
}
|
||||
|
||||
public function recommendation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(RideRecommendation::class, 'ride_recommendation_id');
|
||||
}
|
||||
}
|
||||
50
app/Models/Event.php
Normal file
50
app/Models/Event.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Event extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public const UPDATED_AT = null;
|
||||
|
||||
protected $fillable = [
|
||||
'event_type',
|
||||
'ride_id',
|
||||
'offer_id',
|
||||
'booking_id',
|
||||
'ride_recommendation_id',
|
||||
'session_id',
|
||||
'meta',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'meta' => 'array',
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function ride(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Ride::class);
|
||||
}
|
||||
|
||||
public function offer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Offer::class);
|
||||
}
|
||||
|
||||
public function booking(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
|
||||
public function recommendation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(RideRecommendation::class, 'ride_recommendation_id');
|
||||
}
|
||||
}
|
||||
68
app/Models/Offer.php
Normal file
68
app/Models/Offer.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Offer extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'title',
|
||||
'slug',
|
||||
'category',
|
||||
'excerpt',
|
||||
'description',
|
||||
'location_label',
|
||||
'lat',
|
||||
'lng',
|
||||
'price_from',
|
||||
'duration_minutes',
|
||||
'image_url',
|
||||
'status',
|
||||
'is_featured',
|
||||
'priority_score',
|
||||
'available_now',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'lat' => 'decimal:7',
|
||||
'lng' => 'decimal:7',
|
||||
'price_from' => 'decimal:2',
|
||||
'is_featured' => 'boolean',
|
||||
'available_now' => 'boolean',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (Offer $offer) {
|
||||
if (blank($offer->uuid)) {
|
||||
$offer->uuid = (string) Str::uuid();
|
||||
}
|
||||
|
||||
if (blank($offer->slug)) {
|
||||
$offer->slug = Str::slug($offer->title);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function recommendations(): HasMany
|
||||
{
|
||||
return $this->hasMany(RideRecommendation::class);
|
||||
}
|
||||
|
||||
public function bookings(): HasMany
|
||||
{
|
||||
return $this->hasMany(Booking::class);
|
||||
}
|
||||
|
||||
public function events(): HasMany
|
||||
{
|
||||
return $this->hasMany(Event::class);
|
||||
}
|
||||
}
|
||||
61
app/Models/Ride.php
Normal file
61
app/Models/Ride.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Ride extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'pickup_label',
|
||||
'pickup_lat',
|
||||
'pickup_lng',
|
||||
'destination_label',
|
||||
'destination_lat',
|
||||
'destination_lng',
|
||||
'scheduled_for',
|
||||
'status',
|
||||
'eta_minutes',
|
||||
'source_channel',
|
||||
'context_zone',
|
||||
'locale',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'pickup_lat' => 'decimal:7',
|
||||
'pickup_lng' => 'decimal:7',
|
||||
'destination_lat' => 'decimal:7',
|
||||
'destination_lng' => 'decimal:7',
|
||||
'scheduled_for' => 'datetime',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (Ride $ride) {
|
||||
if (blank($ride->uuid)) {
|
||||
$ride->uuid = (string) Str::uuid();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function recommendations(): HasMany
|
||||
{
|
||||
return $this->hasMany(RideRecommendation::class)->orderBy('position');
|
||||
}
|
||||
|
||||
public function bookings(): HasMany
|
||||
{
|
||||
return $this->hasMany(Booking::class);
|
||||
}
|
||||
|
||||
public function events(): HasMany
|
||||
{
|
||||
return $this->hasMany(Event::class);
|
||||
}
|
||||
}
|
||||
40
app/Models/RideRecommendation.php
Normal file
40
app/Models/RideRecommendation.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class RideRecommendation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'ride_id',
|
||||
'offer_id',
|
||||
'position',
|
||||
'score',
|
||||
'reason',
|
||||
'was_viewed',
|
||||
'was_clicked',
|
||||
'clicked_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'score' => 'decimal:2',
|
||||
'was_viewed' => 'boolean',
|
||||
'was_clicked' => 'boolean',
|
||||
'clicked_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function ride(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Ride::class);
|
||||
}
|
||||
|
||||
public function offer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Offer::class);
|
||||
}
|
||||
}
|
||||
57
app/Models/User.php
Normal file
57
app/Models/User.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Filament\Models\Contracts\FilamentUser;
|
||||
use Filament\Panel;
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Database\Factories\UserFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
class User extends Authenticatable implements FilamentUser
|
||||
{
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function canAccessPanel(Panel $panel): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
24
app/Providers/AppServiceProvider.php
Normal file
24
app/Providers/AppServiceProvider.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register any application services.
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
58
app/Providers/Filament/AdminPanelProvider.php
Normal file
58
app/Providers/Filament/AdminPanelProvider.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\Http\Middleware\AuthenticateSession;
|
||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||
use Filament\Pages;
|
||||
use Filament\Panel;
|
||||
use Filament\PanelProvider;
|
||||
use Filament\Support\Colors\Color;
|
||||
use Filament\Widgets;
|
||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
||||
use Illuminate\Routing\Middleware\SubstituteBindings;
|
||||
use Illuminate\Session\Middleware\StartSession;
|
||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||
|
||||
class AdminPanelProvider extends PanelProvider
|
||||
{
|
||||
public function panel(Panel $panel): Panel
|
||||
{
|
||||
return $panel
|
||||
->default()
|
||||
->id('admin')
|
||||
->path('admin')
|
||||
->login()
|
||||
->colors([
|
||||
'primary' => Color::Amber,
|
||||
])
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
|
||||
->pages([
|
||||
Pages\Dashboard::class,
|
||||
])
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
|
||||
->widgets([
|
||||
Widgets\AccountWidget::class,
|
||||
Widgets\FilamentInfoWidget::class,
|
||||
])
|
||||
->middleware([
|
||||
EncryptCookies::class,
|
||||
AddQueuedCookiesToResponse::class,
|
||||
StartSession::class,
|
||||
AuthenticateSession::class,
|
||||
ShareErrorsFromSession::class,
|
||||
VerifyCsrfToken::class,
|
||||
SubstituteBindings::class,
|
||||
DisableBladeIconComponents::class,
|
||||
DispatchServingFilamentEvent::class,
|
||||
])
|
||||
->authMiddleware([
|
||||
Authenticate::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
40
app/Services/EventTracker.php
Normal file
40
app/Services/EventTracker.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Event;
|
||||
use App\Models\Offer;
|
||||
use App\Models\Ride;
|
||||
use App\Models\RideRecommendation;
|
||||
|
||||
class EventTracker
|
||||
{
|
||||
public function log(string $eventType, ?Ride $ride = null, ?Offer $offer = null, ?Booking $booking = null, ?RideRecommendation $recommendation = null, array $meta = []): Event
|
||||
{
|
||||
return Event::create([
|
||||
'event_type' => $eventType,
|
||||
'ride_id' => $ride?->id,
|
||||
'offer_id' => $offer?->id,
|
||||
'booking_id' => $booking?->id,
|
||||
'ride_recommendation_id' => $recommendation?->id,
|
||||
'session_id' => session()->getId(),
|
||||
'meta' => $meta ?: null,
|
||||
'created_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function logOncePerSession(string $eventType, string $dedupeKey, ?Ride $ride = null, ?Offer $offer = null, ?Booking $booking = null, ?RideRecommendation $recommendation = null, array $meta = []): ?Event
|
||||
{
|
||||
$logged = session()->get('event_dedupe', []);
|
||||
|
||||
if (in_array($dedupeKey, $logged, true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$logged[] = $dedupeKey;
|
||||
session()->put('event_dedupe', $logged);
|
||||
|
||||
return $this->log($eventType, $ride, $offer, $booking, $recommendation, $meta);
|
||||
}
|
||||
}
|
||||
72
app/Services/RecommendationEngine.php
Normal file
72
app/Services/RecommendationEngine.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Offer;
|
||||
use App\Models\Ride;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class RecommendationEngine
|
||||
{
|
||||
public function recommendFor(Ride $ride, int $limit = 3): Collection
|
||||
{
|
||||
$zone = Str::lower((string) $ride->context_zone);
|
||||
$destination = Str::lower((string) $ride->destination_label);
|
||||
$hour = optional($ride->scheduled_for)->hour ?? now()->hour;
|
||||
|
||||
return Offer::query()
|
||||
->where('status', 'published')
|
||||
->get()
|
||||
->map(function (Offer $offer) use ($zone, $destination, $hour) {
|
||||
$score = (int) $offer->priority_score;
|
||||
$reasons = [];
|
||||
$haystack = Str::lower(trim(($offer->location_label ?? '').' '.$offer->title.' '.$offer->excerpt.' '.$offer->description));
|
||||
|
||||
if ($offer->available_now) {
|
||||
$score += 18;
|
||||
$reasons[] = 'Available right now';
|
||||
}
|
||||
|
||||
if ($offer->is_featured) {
|
||||
$score += 14;
|
||||
$reasons[] = 'Featured partner';
|
||||
}
|
||||
|
||||
foreach (array_filter([$zone, $destination]) as $needle) {
|
||||
if ($needle !== '' && Str::contains($haystack, $needle)) {
|
||||
$score += 22;
|
||||
$reasons[] = 'Matches destination context';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($hour >= 18 && $offer->category === 'restaurant') {
|
||||
$score += 12;
|
||||
$reasons[] = 'Good fit for the evening';
|
||||
}
|
||||
|
||||
if ($hour >= 10 && $hour <= 18 && in_array($offer->category, ['experience', 'activity'], true)) {
|
||||
$score += 12;
|
||||
$reasons[] = 'Works well while waiting or after arrival';
|
||||
}
|
||||
|
||||
if (($offer->duration_minutes ?? 0) > 0 && $offer->duration_minutes <= 120) {
|
||||
$score += 8;
|
||||
$reasons[] = 'Easy to fit into today';
|
||||
}
|
||||
|
||||
if (($offer->price_from ?? 0) > 0 && $offer->price_from <= 50) {
|
||||
$score += 6;
|
||||
$reasons[] = 'Easy price point';
|
||||
}
|
||||
|
||||
$offer->demo_score = $score;
|
||||
$offer->demo_reason = collect($reasons)->unique()->take(2)->implode(' · ') ?: 'Strong local fit';
|
||||
return $offer;
|
||||
})
|
||||
->sortByDesc(fn (Offer $offer) => [$offer->demo_score, $offer->is_featured, $offer->priority_score])
|
||||
->take($limit)
|
||||
->values();
|
||||
}
|
||||
}
|
||||
18
artisan
Executable file
18
artisan
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
// Register the Composer autoloader...
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
// Bootstrap Laravel and handle the command...
|
||||
/** @var Application $app */
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
$status = $app->handleCommand(new ArgvInput);
|
||||
|
||||
exit($status);
|
||||
@ -1,425 +0,0 @@
|
||||
:root {
|
||||
--bg: #f5f5f4;
|
||||
--surface: #ffffff;
|
||||
--surface-muted: #fafaf9;
|
||||
--border: #e7e5e4;
|
||||
--border-strong: #d6d3d1;
|
||||
--text: #111827;
|
||||
--text-soft: #6b7280;
|
||||
--accent: #111827;
|
||||
--accent-soft: #f3f4f6;
|
||||
--success-soft: #ecfdf3;
|
||||
--shadow: 0 12px 32px rgba(17, 24, 39, 0.06);
|
||||
--radius-sm: 10px;
|
||||
--radius-md: 14px;
|
||||
--radius-lg: 18px;
|
||||
--space-1: 0.25rem;
|
||||
--space-2: 0.5rem;
|
||||
--space-3: 0.75rem;
|
||||
--space-4: 1rem;
|
||||
--space-5: 1.5rem;
|
||||
--space-6: 2rem;
|
||||
--space-7: 3rem;
|
||||
}
|
||||
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
main {
|
||||
min-height: calc(100vh - 145px);
|
||||
}
|
||||
|
||||
.navbar {
|
||||
background: rgba(255, 255, 255, 0.92);
|
||||
backdrop-filter: blur(12px);
|
||||
}
|
||||
|
||||
.navbar-brand,
|
||||
.nav-link,
|
||||
.footer-link {
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
font-size: 0.95rem;
|
||||
font-weight: 500;
|
||||
border-radius: 999px;
|
||||
padding: 0.55rem 0.9rem !important;
|
||||
}
|
||||
|
||||
.nav-link.active,
|
||||
.nav-link:hover {
|
||||
background: var(--accent-soft);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.brand-mark {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
border-radius: 0.8rem;
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.mini-stat {
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--surface-muted);
|
||||
padding: 0.45rem 0.8rem;
|
||||
border-radius: 999px;
|
||||
line-height: 1.1;
|
||||
min-width: 115px;
|
||||
}
|
||||
|
||||
.mini-stat strong {
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
.mini-stat span {
|
||||
color: var(--text-soft);
|
||||
font-size: 0.72rem;
|
||||
}
|
||||
|
||||
.section-block {
|
||||
padding: 4rem 0;
|
||||
}
|
||||
|
||||
.section-hero {
|
||||
padding-top: 3rem;
|
||||
}
|
||||
|
||||
.hero-panel,
|
||||
.card-panel,
|
||||
.offer-card,
|
||||
.metric-card,
|
||||
.step-card {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.hero-panel {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.card-panel {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.display-title {
|
||||
font-size: clamp(2rem, 5vw, 3.6rem);
|
||||
line-height: 1.02;
|
||||
letter-spacing: -0.04em;
|
||||
margin-bottom: 1rem;
|
||||
max-width: 12ch;
|
||||
}
|
||||
|
||||
.lead-copy {
|
||||
color: var(--text-soft);
|
||||
max-width: 58ch;
|
||||
font-size: 1rem;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
font-size: 0.78rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
color: var(--text-soft);
|
||||
margin-bottom: 0.9rem;
|
||||
}
|
||||
|
||||
.chip,
|
||||
.reason-pill,
|
||||
.score-pill,
|
||||
.status-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
padding: 0.45rem 0.75rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.82rem;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--surface-muted);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.status-pill {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.reason-pill {
|
||||
margin-bottom: 0.45rem;
|
||||
}
|
||||
|
||||
.metric-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 0.9rem;
|
||||
}
|
||||
|
||||
.metric-card {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.metric-card strong {
|
||||
display: block;
|
||||
font-size: clamp(1.4rem, 3vw, 1.9rem);
|
||||
margin-top: 0.35rem;
|
||||
}
|
||||
|
||||
.metric-card small,
|
||||
.metric-label,
|
||||
.offer-copy,
|
||||
.offer-meta,
|
||||
.summary-list dt,
|
||||
.section-heading p,
|
||||
.step-card p,
|
||||
.empty-state p {
|
||||
color: var(--text-soft);
|
||||
}
|
||||
|
||||
.metric-label {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
|
||||
.card-head,
|
||||
.section-heading {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: clamp(1.6rem, 4vw, 2.25rem);
|
||||
line-height: 1.1;
|
||||
letter-spacing: -0.03em;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
font-size: 0.86rem;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.form-control,
|
||||
.form-select {
|
||||
border-radius: var(--radius-sm);
|
||||
border-color: var(--border-strong);
|
||||
min-height: 2.95rem;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.form-control:focus,
|
||||
.form-select:focus,
|
||||
.btn:focus {
|
||||
border-color: #374151;
|
||||
box-shadow: 0 0 0 0.2rem rgba(17, 24, 39, 0.12) !important;
|
||||
}
|
||||
|
||||
.btn {
|
||||
border-radius: var(--radius-sm);
|
||||
font-weight: 600;
|
||||
padding: 0.8rem 1rem;
|
||||
}
|
||||
|
||||
.btn-lg {
|
||||
padding: 0.95rem 1rem;
|
||||
}
|
||||
|
||||
.step-card,
|
||||
.offer-card {
|
||||
padding: 1.25rem;
|
||||
}
|
||||
|
||||
.step-index {
|
||||
display: inline-flex;
|
||||
width: 2.2rem;
|
||||
height: 2.2rem;
|
||||
border-radius: 0.85rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--accent-soft);
|
||||
font-weight: 700;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.step-card h3 {
|
||||
font-size: 1.05rem;
|
||||
margin-bottom: 0.7rem;
|
||||
}
|
||||
|
||||
.table-slim th,
|
||||
.table-slim td {
|
||||
padding: 1rem 1.1rem;
|
||||
border-color: var(--border);
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.table-slim thead th {
|
||||
background: var(--surface-muted);
|
||||
font-size: 0.78rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
color: var(--text-soft);
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 4rem 1.5rem;
|
||||
}
|
||||
|
||||
.empty-icon {
|
||||
width: 4rem;
|
||||
height: 4rem;
|
||||
margin: 0 auto 1rem;
|
||||
border-radius: 1.25rem;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--surface-muted);
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
.summary-list {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.summary-list div {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 120px) minmax(0, 1fr);
|
||||
gap: 1rem;
|
||||
padding-bottom: 1rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.summary-list div:last-child {
|
||||
border-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.summary-list dt {
|
||||
margin: 0;
|
||||
font-size: 0.82rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
|
||||
.summary-list dd {
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.divider {
|
||||
border-top: 1px solid var(--border);
|
||||
margin: 1.25rem 0;
|
||||
}
|
||||
|
||||
.sticky-summary {
|
||||
position: sticky;
|
||||
top: 6rem;
|
||||
}
|
||||
|
||||
.offer-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.7rem;
|
||||
}
|
||||
|
||||
.offer-card-active {
|
||||
border-color: #16a34a;
|
||||
background: var(--success-soft);
|
||||
}
|
||||
|
||||
.offer-meta li {
|
||||
display: flex;
|
||||
gap: 0.55rem;
|
||||
align-items: center;
|
||||
margin-bottom: 0.45rem;
|
||||
}
|
||||
|
||||
.reason-stack {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.45rem;
|
||||
}
|
||||
|
||||
.compact-offer {
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
.timeline-item {
|
||||
padding-left: 1rem;
|
||||
border-left: 2px solid var(--accent);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.timeline-item-muted {
|
||||
border-left-color: var(--border-strong);
|
||||
}
|
||||
|
||||
.footer-link {
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.footer-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.toast {
|
||||
border-radius: var(--radius-sm);
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
@media (max-width: 991.98px) {
|
||||
.sticky-summary {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.section-block {
|
||||
padding: 3rem 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767.98px) {
|
||||
.metric-grid,
|
||||
.summary-list div {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.section-heading,
|
||||
.card-head {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.table-slim th,
|
||||
.table-slim td {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const pickupInput = document.getElementById('pickup_time');
|
||||
if (pickupInput && !pickupInput.value) {
|
||||
const now = new Date();
|
||||
now.setMinutes(now.getMinutes() + 20);
|
||||
now.setSeconds(0, 0);
|
||||
pickupInput.value = now.toISOString().slice(0, 16);
|
||||
}
|
||||
|
||||
const toastElement = document.getElementById('appToast');
|
||||
if (toastElement && typeof bootstrap !== 'undefined') {
|
||||
const message = toastElement.dataset.toastMessage || '';
|
||||
if (message.trim() !== '') {
|
||||
const body = toastElement.querySelector('.toast-body');
|
||||
if (body) {
|
||||
body.textContent = message;
|
||||
}
|
||||
const toast = new bootstrap.Toast(toastElement, { delay: 3200 });
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
|
||||
document.querySelectorAll('.book-offer-btn').forEach((button) => {
|
||||
button.addEventListener('click', () => {
|
||||
button.disabled = true;
|
||||
button.textContent = 'Confirming booking…';
|
||||
const form = button.closest('form');
|
||||
if (form) {
|
||||
form.submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
BIN
assets/pasted-20260406-060945-de3cf20e.jpg
Normal file
BIN
assets/pasted-20260406-060945-de3cf20e.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 138 KiB |
BIN
assets/vm-shot-2026-04-06T06-04-24-180Z.jpg
Normal file
BIN
assets/vm-shot-2026-04-06T06-04-24-180Z.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 138 KiB |
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/app.php';
|
||||
|
||||
ensure_schema();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
header('Location: /');
|
||||
exit;
|
||||
}
|
||||
|
||||
$requestId = filter_input(INPUT_POST, 'request_id', FILTER_VALIDATE_INT);
|
||||
$offerSlug = trim((string) ($_POST['offer_slug'] ?? ''));
|
||||
|
||||
if (!$requestId || $offerSlug === '' || !offer_by_slug($offerSlug)) {
|
||||
header('Location: /requests.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
book_offer($requestId, $offerSlug);
|
||||
header('Location: /request_success.php?id=' . $requestId . '&booked=1');
|
||||
exit;
|
||||
18
bootstrap/app.php
Normal file
18
bootstrap/app.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Configuration\Exceptions;
|
||||
use Illuminate\Foundation\Configuration\Middleware;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
//
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions): void {
|
||||
//
|
||||
})->create();
|
||||
2
bootstrap/cache/.gitignore
vendored
Normal file
2
bootstrap/cache/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
6
bootstrap/providers.php
Normal file
6
bootstrap/providers.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\Filament\AdminPanelProvider::class,
|
||||
];
|
||||
89
composer.json
Normal file
89
composer.json
Normal file
@ -0,0 +1,89 @@
|
||||
{
|
||||
"$schema": "https://getcomposer.org/schema.json",
|
||||
"name": "laravel/laravel",
|
||||
"type": "project",
|
||||
"description": "The skeleton application for the Laravel framework.",
|
||||
"keywords": ["laravel", "framework"],
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"filament/filament": "^3.3",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"livewire/livewire": "^3.5"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
"laravel/pail": "^1.2.2",
|
||||
"laravel/pint": "^1.24",
|
||||
"laravel/sail": "^1.41",
|
||||
"mockery/mockery": "^1.6",
|
||||
"nunomaduro/collision": "^8.6",
|
||||
"phpunit/phpunit": "^11.5.50"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"setup": [
|
||||
"composer install",
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
|
||||
"@php artisan key:generate",
|
||||
"@php artisan migrate --force",
|
||||
"npm install",
|
||||
"npm run build"
|
||||
],
|
||||
"dev": [
|
||||
"Composer\\Config::disableProcessTimeout",
|
||||
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others"
|
||||
],
|
||||
"test": [
|
||||
"@php artisan config:clear --ansi",
|
||||
"@php artisan test"
|
||||
],
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi",
|
||||
"@php artisan filament:upgrade"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||
],
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
],
|
||||
"post-create-project-cmd": [
|
||||
"@php artisan key:generate --ansi",
|
||||
"@php -r \"file_exists('database/database.sqlite') || touch('database/database.sqlite');\"",
|
||||
"@php artisan migrate --graceful --ansi"
|
||||
],
|
||||
"pre-package-uninstall": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::prePackageUninstall"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"dont-discover": []
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"pestphp/pest-plugin": true,
|
||||
"php-http/discovery": true
|
||||
}
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true
|
||||
}
|
||||
10075
composer.lock
generated
Normal file
10075
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
126
config/app.php
Normal file
126
config/app.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the name of your application, which will be used when the
|
||||
| framework needs to place the application's name in a notification or
|
||||
| other UI elements where an application name needs to be displayed.
|
||||
|
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'Laravel'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Environment
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the "environment" your application is currently
|
||||
| running in. This may determine how you prefer to configure various
|
||||
| services the application utilizes. Set this in your ".env" file.
|
||||
|
|
||||
*/
|
||||
|
||||
'env' => env('APP_ENV', 'production'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Debug Mode
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When your application is in debug mode, detailed error messages with
|
||||
| stack traces will be shown on every error that occurs within your
|
||||
| application. If disabled, a simple generic error page is shown.
|
||||
|
|
||||
*/
|
||||
|
||||
'debug' => (bool) env('APP_DEBUG', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This URL is used by the console to properly generate URLs when using
|
||||
| the Artisan command line tool. You should set this to the root of
|
||||
| the application so that it's available within Artisan commands.
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. The timezone
|
||||
| is set to "UTC" by default as it is suitable for most use cases.
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'UTC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by Laravel's translation / localization methods. This option can be
|
||||
| set to any locale for which you plan to have translation strings.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => env('APP_LOCALE', 'en'),
|
||||
|
||||
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
|
||||
|
||||
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is utilized by Laravel's encryption services and should be set
|
||||
| to a random, 32 character string to ensure that all encrypted values
|
||||
| are secure. You should do this prior to deploying the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
'key' => env('APP_KEY') ?: 'base64:6A3w22uOZ9g3q4kS4hA4O1ohs04E4+PGcfNP9m2OE8A=',
|
||||
|
||||
'previous_keys' => [
|
||||
...array_filter(
|
||||
explode(',', (string) env('APP_PREVIOUS_KEYS', ''))
|
||||
),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Maintenance Mode Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options determine the driver used to determine and
|
||||
| manage Laravel's "maintenance mode" status. The "cache" driver will
|
||||
| allow maintenance mode to be controlled across multiple machines.
|
||||
|
|
||||
| Supported drivers: "file", "cache"
|
||||
|
|
||||
*/
|
||||
|
||||
'maintenance' => [
|
||||
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
|
||||
'store' => env('APP_MAINTENANCE_STORE', 'database'),
|
||||
],
|
||||
|
||||
];
|
||||
117
config/auth.php
Normal file
117
config/auth.php
Normal file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Defaults
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default authentication "guard" and password
|
||||
| reset "broker" for your application. You may change these values
|
||||
| as required, but they're a perfect start for most applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'defaults' => [
|
||||
'guard' => env('AUTH_GUARD', 'web'),
|
||||
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Next, you may define every authentication guard for your application.
|
||||
| Of course, a great default configuration has been defined for you
|
||||
| which utilizes session storage plus the Eloquent user provider.
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| Supported: "session"
|
||||
|
|
||||
*/
|
||||
|
||||
'guards' => [
|
||||
'web' => [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| User Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| All authentication guards have a user provider, which defines how the
|
||||
| users are actually retrieved out of your database or other storage
|
||||
| system used by the application. Typically, Eloquent is utilized.
|
||||
|
|
||||
| If you have multiple user tables or models you may configure multiple
|
||||
| providers to represent the model / table. These providers may then
|
||||
| be assigned to any extra authentication guards you have defined.
|
||||
|
|
||||
| Supported: "database", "eloquent"
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
'users' => [
|
||||
'driver' => 'eloquent',
|
||||
'model' => env('AUTH_MODEL', User::class),
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Resetting Passwords
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These configuration options specify the behavior of Laravel's password
|
||||
| reset functionality, including the table utilized for token storage
|
||||
| and the user provider that is invoked to actually retrieve users.
|
||||
|
|
||||
| The expiry time is the number of minutes that each reset token will be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
| The throttle setting is the number of seconds a user must wait before
|
||||
| generating more password reset tokens. This prevents the user from
|
||||
| quickly generating a very large amount of password reset tokens.
|
||||
|
|
||||
*/
|
||||
|
||||
'passwords' => [
|
||||
'users' => [
|
||||
'provider' => 'users',
|
||||
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
||||
'expire' => 60,
|
||||
'throttle' => 60,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Confirmation Timeout
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define the number of seconds before a password confirmation
|
||||
| window expires and users are asked to re-enter their password via the
|
||||
| confirmation screen. By default, the timeout lasts for three hours.
|
||||
|
|
||||
*/
|
||||
|
||||
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
||||
|
||||
];
|
||||
117
config/cache.php
Normal file
117
config/cache.php
Normal file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default cache store that will be used by the
|
||||
| framework. This connection is utilized if another isn't explicitly
|
||||
| specified when running a cache operation inside the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('CACHE_STORE', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Stores
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the cache "stores" for your application as
|
||||
| well as their drivers. You may even define multiple stores for the
|
||||
| same cache driver to group types of items stored in your caches.
|
||||
|
|
||||
| Supported drivers: "array", "database", "file", "memcached",
|
||||
| "redis", "dynamodb", "octane",
|
||||
| "failover", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'stores' => [
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_CACHE_CONNECTION'),
|
||||
'table' => env('DB_CACHE_TABLE', 'cache'),
|
||||
'lock_connection' => env('DB_CACHE_LOCK_CONNECTION'),
|
||||
'lock_table' => env('DB_CACHE_LOCK_TABLE'),
|
||||
],
|
||||
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
'path' => storage_path('framework/cache/data'),
|
||||
'lock_path' => storage_path('framework/cache/data'),
|
||||
],
|
||||
|
||||
'memcached' => [
|
||||
'driver' => 'memcached',
|
||||
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
|
||||
'sasl' => [
|
||||
env('MEMCACHED_USERNAME'),
|
||||
env('MEMCACHED_PASSWORD'),
|
||||
],
|
||||
'options' => [
|
||||
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||
],
|
||||
'servers' => [
|
||||
[
|
||||
'host' => env('MEMCACHED_HOST', '127.0.0.1'),
|
||||
'port' => env('MEMCACHED_PORT', 11211),
|
||||
'weight' => 100,
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_CACHE_CONNECTION', 'cache'),
|
||||
'lock_connection' => env('REDIS_CACHE_LOCK_CONNECTION', 'default'),
|
||||
],
|
||||
|
||||
'dynamodb' => [
|
||||
'driver' => 'dynamodb',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||
],
|
||||
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'driver' => 'failover',
|
||||
'stores' => [
|
||||
'database',
|
||||
'array',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the APC, database, memcached, Redis, and DynamoDB cache
|
||||
| stores, there might be other applications using the same cache. For
|
||||
| that reason, you may prefix every cache key to avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-cache-'),
|
||||
|
||||
];
|
||||
139
config/database.php
Normal file
139
config/database.php
Normal file
@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Query\Grammars\MySqlGrammar as Mysql;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
$dbConfigPaths = [base_path('db/config.php'), dirname(base_path()).'/db/config.php'];
|
||||
foreach ($dbConfigPaths as $dbConfigPath) {
|
||||
if (file_exists($dbConfigPath)) {
|
||||
require_once $dbConfigPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
'default' => 'mysql',
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'url' => env('DB_URL'),
|
||||
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||
'prefix' => '',
|
||||
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
|
||||
'busy_timeout' => null,
|
||||
'journal_mode' => null,
|
||||
'synchronous' => null,
|
||||
'transaction_mode' => 'DEFERRED',
|
||||
],
|
||||
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => defined('DB_HOST') ? DB_HOST : env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => defined('DB_NAME') ? DB_NAME : env('DB_DATABASE', 'laravel'),
|
||||
'username' => defined('DB_USER') ? DB_USER : env('DB_USERNAME', 'root'),
|
||||
'password' => defined('DB_PASS') ? DB_PASS : env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'mariadb' => [
|
||||
'driver' => 'mariadb',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
'pgsql' => [
|
||||
'driver' => 'pgsql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '5432'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'search_path' => 'public',
|
||||
'sslmode' => 'prefer',
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', 'localhost'),
|
||||
'port' => env('DB_PORT', '1433'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
'migrations' => [
|
||||
'table' => 'migrations',
|
||||
'update_date_on_publish' => true,
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
|
||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
|
||||
'persistent' => env('REDIS_PERSISTENT', false),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
'url' => env('REDIS_URL'),
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'username' => env('REDIS_USERNAME'),
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
80
config/filesystems.php
Normal file
80
config/filesystems.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Filesystem Disk
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default filesystem disk that should be used
|
||||
| by the framework. The "local" disk, as well as a variety of cloud
|
||||
| based disks are available to your application for file storage.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('FILESYSTEM_DISK', 'local'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Filesystem Disks
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below you may configure as many filesystem disks as necessary, and you
|
||||
| may even configure multiple disks for the same driver. Examples for
|
||||
| most supported storage drivers are configured here for reference.
|
||||
|
|
||||
| Supported drivers: "local", "ftp", "sftp", "s3"
|
||||
|
|
||||
*/
|
||||
|
||||
'disks' => [
|
||||
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/private'),
|
||||
'serve' => true,
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => rtrim(env('APP_URL', 'http://localhost'), '/').'/storage',
|
||||
'visibility' => 'public',
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
's3' => [
|
||||
'driver' => 's3',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION'),
|
||||
'bucket' => env('AWS_BUCKET'),
|
||||
'url' => env('AWS_URL'),
|
||||
'endpoint' => env('AWS_ENDPOINT'),
|
||||
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
|
||||
'throw' => false,
|
||||
'report' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Symbolic Links
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the symbolic links that will be created when the
|
||||
| `storage:link` Artisan command is executed. The array keys should be
|
||||
| the locations of the links and the values should be their targets.
|
||||
|
|
||||
*/
|
||||
|
||||
'links' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
],
|
||||
|
||||
];
|
||||
132
config/logging.php
Normal file
132
config/logging.php
Normal file
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
use Monolog\Handler\NullHandler;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Handler\SyslogUdpHandler;
|
||||
use Monolog\Processor\PsrLogMessageProcessor;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option defines the default log channel that is utilized to write
|
||||
| messages to your logs. The value provided here should match one of
|
||||
| the channels present in the list of "channels" configured below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('LOG_CHANNEL', 'stack'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Deprecations Log Channel
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the log channel that should be used to log warnings
|
||||
| regarding deprecated PHP and library features. This allows you to get
|
||||
| your application ready for upcoming major versions of dependencies.
|
||||
|
|
||||
*/
|
||||
|
||||
'deprecations' => [
|
||||
'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),
|
||||
'trace' => env('LOG_DEPRECATIONS_TRACE', false),
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Log Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log channels for your application. Laravel
|
||||
| utilizes the Monolog PHP logging library, which includes a variety
|
||||
| of powerful log handlers and formatters that you're free to use.
|
||||
|
|
||||
| Available drivers: "single", "daily", "slack", "syslog",
|
||||
| "errorlog", "monolog", "custom", "stack"
|
||||
|
|
||||
*/
|
||||
|
||||
'channels' => [
|
||||
|
||||
'stack' => [
|
||||
'driver' => 'stack',
|
||||
'channels' => explode(',', (string) env('LOG_STACK', 'single')),
|
||||
'ignore_exceptions' => false,
|
||||
],
|
||||
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => env('LOG_DAILY_DAYS', 14),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => env('LOG_SLACK_USERNAME', env('APP_NAME', 'Laravel')),
|
||||
'emoji' => env('LOG_SLACK_EMOJI', ':boom:'),
|
||||
'level' => env('LOG_LEVEL', 'critical'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
'connectionString' => 'tls://'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'handler' => StreamHandler::class,
|
||||
'handler_with' => [
|
||||
'stream' => 'php://stderr',
|
||||
],
|
||||
'formatter' => env('LOG_STDERR_FORMATTER'),
|
||||
'processors' => [PsrLogMessageProcessor::class],
|
||||
],
|
||||
|
||||
'syslog' => [
|
||||
'driver' => 'syslog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'facility' => env('LOG_SYSLOG_FACILITY', LOG_USER),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'errorlog' => [
|
||||
'driver' => 'errorlog',
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'monolog',
|
||||
'handler' => NullHandler::class,
|
||||
],
|
||||
|
||||
'emergency' => [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
118
config/mail.php
Normal file
118
config/mail.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Mailer
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default mailer that is used to send all email
|
||||
| messages unless another mailer is explicitly specified when sending
|
||||
| the message. All additional mailers can be configured within the
|
||||
| "mailers" array. Examples of each type of mailer are provided.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('MAIL_MAILER', 'log'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Mailer Configurations
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure all of the mailers used by your application plus
|
||||
| their respective settings. Several examples have been configured for
|
||||
| you and you are free to add your own as your application requires.
|
||||
|
|
||||
| Laravel supports a variety of mail "transport" drivers that can be used
|
||||
| when delivering an email. You may specify which one you're using for
|
||||
| your mailers below. You may also add additional mailers if needed.
|
||||
|
|
||||
| Supported: "smtp", "sendmail", "mailgun", "ses", "ses-v2",
|
||||
| "postmark", "resend", "log", "array",
|
||||
| "failover", "roundrobin"
|
||||
|
|
||||
*/
|
||||
|
||||
'mailers' => [
|
||||
|
||||
'smtp' => [
|
||||
'transport' => 'smtp',
|
||||
'scheme' => env('MAIL_SCHEME'),
|
||||
'url' => env('MAIL_URL'),
|
||||
'host' => env('MAIL_HOST', '127.0.0.1'),
|
||||
'port' => env('MAIL_PORT', 2525),
|
||||
'username' => env('MAIL_USERNAME'),
|
||||
'password' => env('MAIL_PASSWORD'),
|
||||
'timeout' => null,
|
||||
'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'transport' => 'ses',
|
||||
],
|
||||
|
||||
'postmark' => [
|
||||
'transport' => 'postmark',
|
||||
// 'message_stream_id' => env('POSTMARK_MESSAGE_STREAM_ID'),
|
||||
// 'client' => [
|
||||
// 'timeout' => 5,
|
||||
// ],
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'transport' => 'resend',
|
||||
],
|
||||
|
||||
'sendmail' => [
|
||||
'transport' => 'sendmail',
|
||||
'path' => env('MAIL_SENDMAIL_PATH', '/usr/sbin/sendmail -bs -i'),
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'transport' => 'log',
|
||||
'channel' => env('MAIL_LOG_CHANNEL'),
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'transport' => 'array',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'transport' => 'failover',
|
||||
'mailers' => [
|
||||
'smtp',
|
||||
'log',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
'roundrobin' => [
|
||||
'transport' => 'roundrobin',
|
||||
'mailers' => [
|
||||
'ses',
|
||||
'postmark',
|
||||
],
|
||||
'retry_after' => 60,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global "From" Address
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| You may wish for all emails sent by your application to be sent from
|
||||
| the same address. Here you may specify a name and address that is
|
||||
| used globally for all emails that are sent by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'from' => [
|
||||
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
||||
'name' => env('MAIL_FROM_NAME', env('APP_NAME', 'Laravel')),
|
||||
],
|
||||
|
||||
];
|
||||
129
config/queue.php
Normal file
129
config/queue.php
Normal file
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Queue Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Laravel's queue supports a variety of backends via a single, unified
|
||||
| API, giving you convenient access to each backend using identical
|
||||
| syntax for each. The default queue connection is defined below.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('QUEUE_CONNECTION', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the connection options for every queue backend
|
||||
| used by your application. An example configuration is provided for
|
||||
| each backend supported by Laravel. You're also free to add more.
|
||||
|
|
||||
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis",
|
||||
| "deferred", "background", "failover", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sync' => [
|
||||
'driver' => 'sync',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'connection' => env('DB_QUEUE_CONNECTION'),
|
||||
'table' => env('DB_QUEUE_TABLE', 'jobs'),
|
||||
'queue' => env('DB_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'beanstalkd' => [
|
||||
'driver' => 'beanstalkd',
|
||||
'host' => env('BEANSTALKD_QUEUE_HOST', 'localhost'),
|
||||
'queue' => env('BEANSTALKD_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('BEANSTALKD_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => 0,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'sqs' => [
|
||||
'driver' => 'sqs',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||
'queue' => env('SQS_QUEUE', 'default'),
|
||||
'suffix' => env('SQS_SUFFIX'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => env('REDIS_QUEUE_CONNECTION', 'default'),
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => (int) env('REDIS_QUEUE_RETRY_AFTER', 90),
|
||||
'block_for' => null,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'deferred' => [
|
||||
'driver' => 'deferred',
|
||||
],
|
||||
|
||||
'background' => [
|
||||
'driver' => 'background',
|
||||
],
|
||||
|
||||
'failover' => [
|
||||
'driver' => 'failover',
|
||||
'connections' => [
|
||||
'database',
|
||||
'deferred',
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Job Batching
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following options configure the database and table that store job
|
||||
| batching information. These options can be updated to any database
|
||||
| connection and table which has been defined by your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'batching' => [
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'job_batches',
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Failed Queue Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These options configure the behavior of failed queue job logging so you
|
||||
| can control how and where failed jobs are stored. Laravel ships with
|
||||
| support for storing failed jobs in a simple file or in a database.
|
||||
|
|
||||
| Supported drivers: "database-uuids", "dynamodb", "file", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
|
||||
'database' => env('DB_CONNECTION', 'sqlite'),
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
||||
];
|
||||
38
config/services.php
Normal file
38
config/services.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Third Party Services
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is for storing the credentials for third party services such
|
||||
| as Mailgun, Postmark, AWS and more. This file provides the de facto
|
||||
| location for this type of information, allowing packages to have
|
||||
| a conventional file to locate the various service credentials.
|
||||
|
|
||||
*/
|
||||
|
||||
'postmark' => [
|
||||
'key' => env('POSTMARK_API_KEY'),
|
||||
],
|
||||
|
||||
'resend' => [
|
||||
'key' => env('RESEND_API_KEY'),
|
||||
],
|
||||
|
||||
'ses' => [
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'notifications' => [
|
||||
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||
'channel' => env('SLACK_BOT_USER_DEFAULT_CHANNEL'),
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
217
config/session.php
Normal file
217
config/session.php
Normal file
@ -0,0 +1,217 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Session Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines the default session driver that is utilized for
|
||||
| incoming requests. Laravel supports a variety of storage options to
|
||||
| persist session data. Database storage is a great default choice.
|
||||
|
|
||||
| Supported: "file", "cookie", "database", "memcached",
|
||||
| "redis", "dynamodb", "array"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => env('SESSION_DRIVER', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Lifetime
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the number of minutes that you wish the session
|
||||
| to be allowed to remain idle before it expires. If you want them
|
||||
| to expire immediately when the browser is closed then you may
|
||||
| indicate that via the expire_on_close configuration option.
|
||||
|
|
||||
*/
|
||||
|
||||
'lifetime' => (int) env('SESSION_LIFETIME', 120),
|
||||
|
||||
'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Encryption
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option allows you to easily specify that all of your session data
|
||||
| should be encrypted before it's stored. All encryption is performed
|
||||
| automatically by Laravel and you may use the session like normal.
|
||||
|
|
||||
*/
|
||||
|
||||
'encrypt' => env('SESSION_ENCRYPT', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session File Location
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing the "file" session driver, the session files are placed
|
||||
| on disk. The default storage location is defined here; however, you
|
||||
| are free to provide another location where they should be stored.
|
||||
|
|
||||
*/
|
||||
|
||||
'files' => storage_path('framework/sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Connection
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" or "redis" session drivers, you may specify a
|
||||
| connection that should be used to manage these sessions. This should
|
||||
| correspond to a connection in your database configuration options.
|
||||
|
|
||||
*/
|
||||
|
||||
'connection' => env('SESSION_CONNECTION'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Database Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "database" session driver, you may specify the table to
|
||||
| be used to store sessions. Of course, a sensible default is defined
|
||||
| for you; however, you're welcome to change this to another table.
|
||||
|
|
||||
*/
|
||||
|
||||
'table' => env('SESSION_TABLE', 'sessions'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using one of the framework's cache driven session backends, you may
|
||||
| define the cache store which should be used to store the session data
|
||||
| between requests. This must match one of your defined cache stores.
|
||||
|
|
||||
| Affects: "dynamodb", "memcached", "redis"
|
||||
|
|
||||
*/
|
||||
|
||||
'store' => env('SESSION_STORE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Sweeping Lottery
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Some session drivers must manually sweep their storage location to get
|
||||
| rid of old sessions from storage. Here are the chances that it will
|
||||
| happen on a given request. By default, the odds are 2 out of 100.
|
||||
|
|
||||
*/
|
||||
|
||||
'lottery' => [2, 100],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may change the name of the session cookie that is created by
|
||||
| the framework. Typically, you should not need to change this value
|
||||
| since doing so does not grant a meaningful security improvement.
|
||||
|
|
||||
*/
|
||||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug((string) env('APP_NAME', 'laravel')).'-session'
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Path
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The session cookie path determines the path for which the cookie will
|
||||
| be regarded as available. Typically, this will be the root path of
|
||||
| your application, but you're free to change this when necessary.
|
||||
|
|
||||
*/
|
||||
|
||||
'path' => env('SESSION_PATH', '/'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Session Cookie Domain
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the domain and subdomains the session cookie is
|
||||
| available to. By default, the cookie will be available to the root
|
||||
| domain without subdomains. Typically, this shouldn't be changed.
|
||||
|
|
||||
*/
|
||||
|
||||
'domain' => env('SESSION_DOMAIN'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTPS Only Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| By setting this option to true, session cookies will only be sent back
|
||||
| to the server if the browser has a HTTPS connection. This will keep
|
||||
| the cookie from being sent to you when it can't be done securely.
|
||||
|
|
||||
*/
|
||||
|
||||
'secure' => env('SESSION_SECURE_COOKIE'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| HTTP Access Only
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will prevent JavaScript from accessing the
|
||||
| value of the cookie and the cookie will only be accessible through
|
||||
| the HTTP protocol. It's unlikely you should disable this option.
|
||||
|
|
||||
*/
|
||||
|
||||
'http_only' => env('SESSION_HTTP_ONLY', true),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Same-Site Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option determines how your cookies behave when cross-site requests
|
||||
| take place, and can be used to mitigate CSRF attacks. By default, we
|
||||
| will set this value to "lax" to permit secure cross-site requests.
|
||||
|
|
||||
| See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value
|
||||
|
|
||||
| Supported: "lax", "strict", "none", null
|
||||
|
|
||||
*/
|
||||
|
||||
'same_site' => env('SESSION_SAME_SITE', 'lax'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Partitioned Cookies
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Setting this value to true will tie the cookie to the top-level site for
|
||||
| a cross-site context. Partitioned cookies are accepted by the browser
|
||||
| when flagged "secure" and the Same-Site attribute is set to "none".
|
||||
|
|
||||
*/
|
||||
|
||||
'partitioned' => env('SESSION_PARTITIONED_COOKIE', false),
|
||||
|
||||
];
|
||||
1
database/.gitignore
vendored
Normal file
1
database/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
45
database/factories/UserFactory.php
Normal file
45
database/factories/UserFactory.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
49
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
49
database/migrations/0001_01_01_000000_create_users_table.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
35
database/migrations/0001_01_01_000001_create_cache_table.php
Normal file
35
database/migrations/0001_01_01_000001_create_cache_table.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->integer('expiration')->index();
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->integer('expiration')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
57
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
57
database/migrations/0001_01_01_000002_create_jobs_table.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
34
database/migrations/2026_04_06_055036_create_rides_table.php
Normal file
34
database/migrations/2026_04_06_055036_create_rides_table.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('rides', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->string('pickup_label');
|
||||
$table->decimal('pickup_lat', 10, 7)->nullable();
|
||||
$table->decimal('pickup_lng', 10, 7)->nullable();
|
||||
$table->string('destination_label');
|
||||
$table->decimal('destination_lat', 10, 7)->nullable();
|
||||
$table->decimal('destination_lng', 10, 7)->nullable();
|
||||
$table->dateTime('scheduled_for')->nullable();
|
||||
$table->enum('status', ['pending', 'confirmed', 'completed', 'cancelled'])->default('pending');
|
||||
$table->unsignedTinyInteger('eta_minutes')->nullable();
|
||||
$table->enum('source_channel', ['app', 'hotel', 'reception', 'web'])->default('web');
|
||||
$table->string('context_zone')->nullable();
|
||||
$table->string('locale', 10)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('rides');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('offers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->string('title');
|
||||
$table->string('slug')->unique();
|
||||
$table->enum('category', ['restaurant', 'experience', 'activity', 'product', 'service']);
|
||||
$table->string('excerpt')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->string('location_label')->nullable();
|
||||
$table->decimal('lat', 10, 7)->nullable();
|
||||
$table->decimal('lng', 10, 7)->nullable();
|
||||
$table->decimal('price_from', 10, 2)->nullable();
|
||||
$table->unsignedInteger('duration_minutes')->nullable();
|
||||
$table->string('image_url')->nullable();
|
||||
$table->enum('status', ['draft', 'published', 'paused'])->default('draft');
|
||||
$table->boolean('is_featured')->default(false);
|
||||
$table->integer('priority_score')->default(0);
|
||||
$table->boolean('available_now')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('offers');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('ride_recommendations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('ride_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('offer_id')->constrained()->cascadeOnDelete();
|
||||
$table->unsignedTinyInteger('position');
|
||||
$table->decimal('score', 8, 2)->nullable();
|
||||
$table->string('reason')->nullable();
|
||||
$table->boolean('was_viewed')->default(false);
|
||||
$table->boolean('was_clicked')->default(false);
|
||||
$table->timestamp('clicked_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['ride_id', 'offer_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ride_recommendations');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('bookings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->foreignId('ride_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignId('offer_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('ride_recommendation_id')->nullable()->constrained('ride_recommendations')->nullOnDelete();
|
||||
$table->string('customer_name')->nullable();
|
||||
$table->string('customer_email')->nullable();
|
||||
$table->string('customer_phone')->nullable();
|
||||
$table->unsignedInteger('party_size')->default(1);
|
||||
$table->dateTime('booking_for')->nullable();
|
||||
$table->enum('status', ['started', 'confirmed', 'cancelled'])->default('started');
|
||||
$table->decimal('amount', 10, 2)->nullable();
|
||||
$table->decimal('commission_amount', 10, 2)->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('bookings');
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('events', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->enum('event_type', ['request_created', 'recommendation_viewed', 'recommendation_clicked', 'booking_started', 'booking_completed']);
|
||||
$table->foreignId('ride_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignId('offer_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignId('booking_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignId('ride_recommendation_id')->nullable()->constrained('ride_recommendations')->nullOnDelete();
|
||||
$table->string('session_id')->nullable();
|
||||
$table->json('meta')->nullable();
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('events');
|
||||
}
|
||||
};
|
||||
15
database/seeders/DatabaseSeeder.php
Normal file
15
database/seeders/DatabaseSeeder.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$this->call([
|
||||
DemoDataSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
103
database/seeders/DemoDataSeeder.php
Normal file
103
database/seeders/DemoDataSeeder.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Offer;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DemoDataSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$offers = [
|
||||
[
|
||||
'title' => 'Sunset Marina Table',
|
||||
'slug' => 'sunset-marina-table',
|
||||
'category' => 'restaurant',
|
||||
'excerpt' => 'A polished waterfront dinner spot for couples or small groups.',
|
||||
'description' => 'Priority seating, fast confirmation, and a memorable marina view that works well right after a taxi drop-off.',
|
||||
'location_label' => 'Marina',
|
||||
'price_from' => 42,
|
||||
'duration_minutes' => 90,
|
||||
'status' => 'published',
|
||||
'is_featured' => true,
|
||||
'priority_score' => 92,
|
||||
'available_now' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'Old Town Tapas Walk',
|
||||
'slug' => 'old-town-tapas-walk',
|
||||
'category' => 'experience',
|
||||
'excerpt' => 'A short guided route through the most photogenic local food spots.',
|
||||
'description' => 'Ideal for first-time visitors who want a curated plan without committing half a day.',
|
||||
'location_label' => 'Old Town',
|
||||
'price_from' => 34,
|
||||
'duration_minutes' => 75,
|
||||
'status' => 'published',
|
||||
'is_featured' => true,
|
||||
'priority_score' => 88,
|
||||
'available_now' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'Beach Club Day Pass',
|
||||
'slug' => 'beach-club-day-pass',
|
||||
'category' => 'activity',
|
||||
'excerpt' => 'Fast-entry pass with towel, lounger, and drink credit included.',
|
||||
'description' => 'An easy same-day upgrade for guests heading toward the waterfront zone.',
|
||||
'location_label' => 'Beach',
|
||||
'price_from' => 29,
|
||||
'duration_minutes' => 120,
|
||||
'status' => 'published',
|
||||
'is_featured' => true,
|
||||
'priority_score' => 85,
|
||||
'available_now' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'City Center Brunch Slot',
|
||||
'slug' => 'city-center-brunch-slot',
|
||||
'category' => 'restaurant',
|
||||
'excerpt' => 'Reliable reservation at a high-demand brunch concept.',
|
||||
'description' => 'Convenient for arrivals into the city core with a predictable handoff to the host team.',
|
||||
'location_label' => 'City Center',
|
||||
'price_from' => 26,
|
||||
'duration_minutes' => 60,
|
||||
'status' => 'published',
|
||||
'is_featured' => false,
|
||||
'priority_score' => 74,
|
||||
'available_now' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'Private Sailing Intro',
|
||||
'slug' => 'private-sailing-intro',
|
||||
'category' => 'experience',
|
||||
'excerpt' => 'Short premium sailing experience from the marina.',
|
||||
'description' => 'A premium upsell for guests already moving toward the port area.',
|
||||
'location_label' => 'Marina',
|
||||
'price_from' => 79,
|
||||
'duration_minutes' => 105,
|
||||
'status' => 'published',
|
||||
'is_featured' => false,
|
||||
'priority_score' => 80,
|
||||
'available_now' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'Hotel Spa Recovery',
|
||||
'slug' => 'hotel-spa-recovery',
|
||||
'category' => 'service',
|
||||
'excerpt' => 'Fast-access recovery ritual for same-day arrivals.',
|
||||
'description' => 'Especially useful after airport or station pickups with short waiting windows.',
|
||||
'location_label' => 'Hotel District',
|
||||
'price_from' => 55,
|
||||
'duration_minutes' => 60,
|
||||
'status' => 'published',
|
||||
'is_featured' => false,
|
||||
'priority_score' => 71,
|
||||
'available_now' => true,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($offers as $offer) {
|
||||
Offer::updateOrCreate(['slug' => $offer['slug']], $offer);
|
||||
}
|
||||
}
|
||||
}
|
||||
17
healthz.php
17
healthz.php
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/app.php';
|
||||
|
||||
try {
|
||||
ensure_schema();
|
||||
db()->query('SELECT 1');
|
||||
http_response_code(200);
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo "ok\n";
|
||||
} catch (Throwable $exception) {
|
||||
http_response_code(500);
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo "error\n";
|
||||
}
|
||||
265
index.php
265
index.php
@ -1,265 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
require_once __DIR__ . '/app.php';
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
ensure_schema();
|
||||
/** @var \Illuminate\Foundation\Application $app */
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
$errors = [];
|
||||
$input = [
|
||||
'passenger_name' => '',
|
||||
'pickup_point' => '',
|
||||
'destination_area' => 'marina',
|
||||
'pickup_time' => (new DateTimeImmutable('+20 minutes'))->format('Y-m-d\TH:i'),
|
||||
'source_channel' => 'hotel',
|
||||
'party_size' => '2',
|
||||
'notes' => '',
|
||||
];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$input['passenger_name'] = trim((string) ($_POST['passenger_name'] ?? ''));
|
||||
$input['pickup_point'] = trim((string) ($_POST['pickup_point'] ?? ''));
|
||||
$input['destination_area'] = trim((string) ($_POST['destination_area'] ?? ''));
|
||||
$input['pickup_time'] = trim((string) ($_POST['pickup_time'] ?? ''));
|
||||
$input['source_channel'] = trim((string) ($_POST['source_channel'] ?? ''));
|
||||
$input['party_size'] = trim((string) ($_POST['party_size'] ?? '1'));
|
||||
$input['notes'] = trim((string) ($_POST['notes'] ?? ''));
|
||||
|
||||
if ($input['passenger_name'] === '') {
|
||||
$errors['passenger_name'] = 'Add a passenger or booking reference.';
|
||||
}
|
||||
if ($input['pickup_point'] === '') {
|
||||
$errors['pickup_point'] = 'Pickup point is required.';
|
||||
}
|
||||
if (!array_key_exists($input['destination_area'], destination_options())) {
|
||||
$errors['destination_area'] = 'Choose a valid destination area.';
|
||||
}
|
||||
|
||||
$dateTime = DateTimeImmutable::createFromFormat('Y-m-d\TH:i', $input['pickup_time']);
|
||||
if (!$dateTime) {
|
||||
$errors['pickup_time'] = 'Choose a valid pickup time.';
|
||||
} else {
|
||||
$input['pickup_time'] = $dateTime->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
if (!array_key_exists($input['source_channel'], source_channel_options())) {
|
||||
$errors['source_channel'] = 'Choose a valid source channel.';
|
||||
}
|
||||
|
||||
$partySize = filter_var($input['party_size'], FILTER_VALIDATE_INT, ['options' => ['min_range' => 1, 'max_range' => 8]]);
|
||||
if ($partySize === false) {
|
||||
$errors['party_size'] = 'Party size must be between 1 and 8.';
|
||||
}
|
||||
$input['party_size'] = (string) ($partySize ?: 1);
|
||||
|
||||
if ($errors === []) {
|
||||
$requestId = create_taxi_request([
|
||||
'passenger_name' => $input['passenger_name'],
|
||||
'pickup_point' => $input['pickup_point'],
|
||||
'destination_area' => $input['destination_area'],
|
||||
'pickup_time' => $input['pickup_time'],
|
||||
'source_channel' => $input['source_channel'],
|
||||
'party_size' => (int) $input['party_size'],
|
||||
'notes' => $input['notes'],
|
||||
]);
|
||||
|
||||
header('Location: /request_success.php?id=' . $requestId . '&created=1');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$stats = fetch_dashboard_stats();
|
||||
$recentRequests = fetch_requests(6);
|
||||
$heroDescription = 'Confirm a taxi request and immediately surface the top 2–3 contextual offers with simple booking attribution.';
|
||||
|
||||
render_head(app_name() . ' | Taxi request workflow', $heroDescription);
|
||||
render_header('home');
|
||||
?>
|
||||
<section class="section-block section-hero">
|
||||
<div class="container">
|
||||
<div class="row g-4 align-items-start">
|
||||
<div class="col-lg-7">
|
||||
<div class="hero-panel">
|
||||
<div class="eyebrow">Initial MVP slice · tourist flow</div>
|
||||
<h1 class="display-title">Taxi confirmation with immediate upsell recommendations.</h1>
|
||||
<p class="lead-copy"><?= h($heroDescription) ?></p>
|
||||
<div class="d-flex flex-wrap gap-2 mt-4">
|
||||
<span class="chip"><i class="bi bi-check2-circle"></i> Taxi request</span>
|
||||
<span class="chip"><i class="bi bi-stars"></i> Top-3 recommendations</span>
|
||||
<span class="chip"><i class="bi bi-journal-check"></i> Booking attribution</span>
|
||||
</div>
|
||||
<div class="metric-grid mt-4">
|
||||
<article class="metric-card">
|
||||
<span class="metric-label">Requests</span>
|
||||
<strong><?= (int) $stats['total_requests'] ?></strong>
|
||||
<small>captured end-to-end</small>
|
||||
</article>
|
||||
<article class="metric-card">
|
||||
<span class="metric-label">CTR</span>
|
||||
<strong><?= h(number_format((float) $stats['ctr'], 1)) ?>%</strong>
|
||||
<small>offer click-through</small>
|
||||
</article>
|
||||
<article class="metric-card">
|
||||
<span class="metric-label">Bookings</span>
|
||||
<strong><?= (int) $stats['bookings'] ?></strong>
|
||||
<small>from taxi flow</small>
|
||||
</article>
|
||||
<article class="metric-card">
|
||||
<span class="metric-label">Avg. delay</span>
|
||||
<strong><?= $stats['avg_delay'] !== null ? (int) $stats['avg_delay'] . 'm' : '—' ?></strong>
|
||||
<small>request to booking</small>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-5">
|
||||
<div class="card-panel shadow-sm">
|
||||
<div class="card-head">
|
||||
<div>
|
||||
<h2 class="h5 mb-1">Create taxi request</h2>
|
||||
<p class="text-secondary mb-0">Save the ride context and instantly generate contextual offers.</p>
|
||||
</div>
|
||||
<span class="status-pill">Live MVP</span>
|
||||
</div>
|
||||
<?php if ($errors !== []): ?>
|
||||
<div class="alert alert-danger mt-3 mb-0" role="alert">Please review the highlighted fields and try again.</div>
|
||||
<?php endif; ?>
|
||||
<form method="post" class="row g-3 mt-1" novalidate>
|
||||
<div class="col-12">
|
||||
<label for="passenger_name" class="form-label">Passenger / booking reference</label>
|
||||
<input type="text" class="form-control <?= isset($errors['passenger_name']) ? 'is-invalid' : '' ?>" id="passenger_name" name="passenger_name" value="<?= h($input['passenger_name']) ?>" placeholder="e.g. Room 204 · Sofia M.">
|
||||
<?php if (isset($errors['passenger_name'])): ?><div class="invalid-feedback"><?= h($errors['passenger_name']) ?></div><?php endif; ?>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label for="pickup_point" class="form-label">Pickup point</label>
|
||||
<input type="text" class="form-control <?= isset($errors['pickup_point']) ? 'is-invalid' : '' ?>" id="pickup_point" name="pickup_point" value="<?= h($input['pickup_point']) ?>" placeholder="Hotel lobby, gate, cruise terminal...">
|
||||
<?php if (isset($errors['pickup_point'])): ?><div class="invalid-feedback"><?= h($errors['pickup_point']) ?></div><?php endif; ?>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="destination_area" class="form-label">Destination area</label>
|
||||
<select class="form-select <?= isset($errors['destination_area']) ? 'is-invalid' : '' ?>" id="destination_area" name="destination_area">
|
||||
<?php foreach (destination_options() as $value => $label): ?>
|
||||
<option value="<?= h($value) ?>" <?= $input['destination_area'] === $value ? 'selected' : '' ?>><?= h($label) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php if (isset($errors['destination_area'])): ?><div class="invalid-feedback"><?= h($errors['destination_area']) ?></div><?php endif; ?>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="pickup_time" class="form-label">Pickup time</label>
|
||||
<input type="datetime-local" class="form-control <?= isset($errors['pickup_time']) ? 'is-invalid' : '' ?>" id="pickup_time" name="pickup_time" value="<?= h(str_replace(' ', 'T', substr($input['pickup_time'], 0, 16))) ?>">
|
||||
<?php if (isset($errors['pickup_time'])): ?><div class="invalid-feedback"><?= h($errors['pickup_time']) ?></div><?php endif; ?>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="source_channel" class="form-label">Source channel</label>
|
||||
<select class="form-select <?= isset($errors['source_channel']) ? 'is-invalid' : '' ?>" id="source_channel" name="source_channel">
|
||||
<?php foreach (source_channel_options() as $value => $label): ?>
|
||||
<option value="<?= h($value) ?>" <?= $input['source_channel'] === $value ? 'selected' : '' ?>><?= h($label) ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php if (isset($errors['source_channel'])): ?><div class="invalid-feedback"><?= h($errors['source_channel']) ?></div><?php endif; ?>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="party_size" class="form-label">Party size</label>
|
||||
<input type="number" min="1" max="8" class="form-control <?= isset($errors['party_size']) ? 'is-invalid' : '' ?>" id="party_size" name="party_size" value="<?= h($input['party_size']) ?>">
|
||||
<?php if (isset($errors['party_size'])): ?><div class="invalid-feedback"><?= h($errors['party_size']) ?></div><?php endif; ?>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label for="notes" class="form-label">Context notes <span class="text-secondary">(optional)</span></label>
|
||||
<textarea class="form-control" id="notes" name="notes" rows="3" placeholder="Family, mobility needs, preferred cuisine, celebration, arrival context..."><?= h($input['notes']) ?></textarea>
|
||||
</div>
|
||||
<div class="col-12 d-grid">
|
||||
<button type="submit" class="btn btn-dark btn-lg">Confirm taxi and generate offers</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section-block border-top bg-white">
|
||||
<div class="container">
|
||||
<div class="section-heading">
|
||||
<div>
|
||||
<div class="eyebrow">Workflow</div>
|
||||
<h2 class="section-title">The first thin slice follows the real tourist journey.</h2>
|
||||
</div>
|
||||
<a href="/requests.php" class="btn btn-outline-dark">Open operations board</a>
|
||||
</div>
|
||||
<div class="row g-3 mt-1">
|
||||
<div class="col-md-4">
|
||||
<article class="step-card h-100">
|
||||
<span class="step-index">01</span>
|
||||
<h3>Capture the taxi request</h3>
|
||||
<p>Store pickup, destination, time, party size, and channel using a focused intake form.</p>
|
||||
</article>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<article class="step-card h-100">
|
||||
<span class="step-index">02</span>
|
||||
<h3>Generate contextual offers</h3>
|
||||
<p>Score nearby restaurants and experiences by geography, timing, quality, and strategic value.</p>
|
||||
</article>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<article class="step-card h-100">
|
||||
<span class="step-index">03</span>
|
||||
<h3>Book and attribute</h3>
|
||||
<p>Confirm the best offer in one click and keep a simple log for CTR and taxi-to-booking conversion.</p>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section-block border-top">
|
||||
<div class="container">
|
||||
<div class="section-heading">
|
||||
<div>
|
||||
<div class="eyebrow">Recent activity</div>
|
||||
<h2 class="section-title">Live requests and current booking outcomes.</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-panel p-0 overflow-hidden">
|
||||
<?php if ($recentRequests === []): ?>
|
||||
<div class="empty-state text-center">
|
||||
<div class="empty-icon"><i class="bi bi-car-front"></i></div>
|
||||
<h3>No requests yet</h3>
|
||||
<p>Submit the first taxi flow above to populate the operations board and recommendation funnel.</p>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-slim align-middle mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Passenger</th>
|
||||
<th>Destination</th>
|
||||
<th>Channel</th>
|
||||
<th>Status</th>
|
||||
<th>Created</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($recentRequests as $request): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="fw-semibold"><?= h($request['passenger_name']) ?></div>
|
||||
<div class="text-secondary small"><?= h($request['pickup_point']) ?></div>
|
||||
</td>
|
||||
<td><?= h(destination_label((string) $request['destination_area'])) ?></td>
|
||||
<td><?= h(source_channel_label((string) $request['source_channel'])) ?></td>
|
||||
<td><span class="badge rounded-pill <?= h(status_badge_class((string) $request['status'])) ?>"><?= h(str_replace('_', ' ', (string) $request['status'])) ?></span></td>
|
||||
<td><?= h(date('d M H:i', strtotime((string) $request['created_at']))) ?></td>
|
||||
<td class="text-end"><a href="/request_detail.php?id=<?= (int) $request['id'] ?>" class="btn btn-sm btn-outline-dark">Detail</a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<?php render_footer(); ?>
|
||||
$app->handleRequest(Illuminate\Http\Request::capture());
|
||||
|
||||
7
laravel_tmp/.htaccess
Normal file
7
laravel_tmp/.htaccess
Normal file
@ -0,0 +1,7 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
</IfModule>
|
||||
@ -2,9 +2,69 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Offer;
|
||||
use App\Models\Ride;
|
||||
use App\Models\RideRecommendation;
|
||||
use App\Services\EventTracker;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class BookingController extends Controller
|
||||
{
|
||||
//
|
||||
public function __construct(protected EventTracker $eventTracker)
|
||||
{
|
||||
}
|
||||
|
||||
public function store(Request $request, Offer $offer): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'ride_id' => ['nullable', 'integer', 'exists:rides,id'],
|
||||
'ride_recommendation_id' => ['nullable', 'integer', 'exists:ride_recommendations,id'],
|
||||
'customer_name' => ['required', 'string', 'max:255'],
|
||||
'customer_email' => ['nullable', 'email', 'max:255'],
|
||||
'customer_phone' => ['nullable', 'string', 'max:50'],
|
||||
'party_size' => ['required', 'integer', 'min:1', 'max:12'],
|
||||
'booking_for' => ['nullable', 'date'],
|
||||
'notes' => ['nullable', 'string', 'max:1000'],
|
||||
]);
|
||||
|
||||
$ride = !empty($validated['ride_id']) ? Ride::find($validated['ride_id']) : null;
|
||||
$recommendation = !empty($validated['ride_recommendation_id']) ? RideRecommendation::find($validated['ride_recommendation_id']) : null;
|
||||
|
||||
$booking = Booking::create([
|
||||
'ride_id' => $ride?->id,
|
||||
'offer_id' => $offer->id,
|
||||
'ride_recommendation_id' => $recommendation?->id,
|
||||
'customer_name' => $validated['customer_name'],
|
||||
'customer_email' => $validated['customer_email'] ?? null,
|
||||
'customer_phone' => $validated['customer_phone'] ?? null,
|
||||
'party_size' => $validated['party_size'],
|
||||
'booking_for' => $validated['booking_for'] ?? null,
|
||||
'status' => 'confirmed',
|
||||
'amount' => $offer->price_from,
|
||||
'commission_amount' => $offer->price_from ? round(((float) $offer->price_from) * 0.15, 2) : null,
|
||||
'notes' => $validated['notes'] ?? null,
|
||||
]);
|
||||
|
||||
$this->eventTracker->log('booking_started', $ride, $offer, $booking, $recommendation, [
|
||||
'party_size' => $booking->party_size,
|
||||
]);
|
||||
|
||||
$this->eventTracker->log('booking_completed', $ride, $offer, $booking, $recommendation, [
|
||||
'amount' => $booking->amount,
|
||||
]);
|
||||
|
||||
return redirect()->route('bookings.success', $booking);
|
||||
}
|
||||
|
||||
public function success(Booking $booking): View
|
||||
{
|
||||
$booking->load(['offer', 'ride', 'recommendation']);
|
||||
|
||||
return view('bookings.success', [
|
||||
'booking' => $booking,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,9 +2,21 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Event;
|
||||
use App\Models\Offer;
|
||||
use App\Models\Ride;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
//
|
||||
public function __invoke()
|
||||
{
|
||||
return view('home', [
|
||||
'featuredOffers' => Offer::query()->where('status', 'published')->orderByDesc('is_featured')->orderByDesc('priority_score')->take(3)->get(),
|
||||
'metrics' => [
|
||||
'rides' => Ride::count(),
|
||||
'views' => Event::where('event_type', 'recommendation_viewed')->count(),
|
||||
'bookings' => Event::where('event_type', 'booking_completed')->count(),
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,9 +2,47 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Offer;
|
||||
use App\Models\Ride;
|
||||
use App\Models\RideRecommendation;
|
||||
use App\Services\EventTracker;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class OfferController extends Controller
|
||||
{
|
||||
//
|
||||
public function __construct(protected EventTracker $eventTracker)
|
||||
{
|
||||
}
|
||||
|
||||
public function show(Request $request, Offer $offer): View
|
||||
{
|
||||
$ride = $request->integer('ride') ? Ride::find($request->integer('ride')) : null;
|
||||
$recommendation = $request->integer('recommendation') ? RideRecommendation::with('offer', 'ride')->find($request->integer('recommendation')) : null;
|
||||
|
||||
if ($recommendation && $recommendation->offer_id === $offer->id) {
|
||||
$this->eventTracker->logOncePerSession(
|
||||
'recommendation_clicked',
|
||||
'rec-clicked-'.$recommendation->id,
|
||||
$ride,
|
||||
$offer,
|
||||
null,
|
||||
$recommendation,
|
||||
['position' => $recommendation->position]
|
||||
);
|
||||
|
||||
if (!$recommendation->was_clicked) {
|
||||
$recommendation->forceFill([
|
||||
'was_clicked' => true,
|
||||
'clicked_at' => now(),
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
|
||||
return view('offers.show', [
|
||||
'offer' => $offer,
|
||||
'ride' => $ride,
|
||||
'recommendation' => $recommendation,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,9 +2,119 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Ride;
|
||||
use App\Models\RideRecommendation;
|
||||
use App\Services\EventTracker;
|
||||
use App\Services\RecommendationEngine;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class RideController extends Controller
|
||||
{
|
||||
//
|
||||
public function __construct(
|
||||
protected RecommendationEngine $recommendationEngine,
|
||||
protected EventTracker $eventTracker,
|
||||
) {
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'pickup_label' => ['required', 'string', 'max:255'],
|
||||
'destination_label' => ['required', 'string', 'max:255'],
|
||||
'scheduled_for' => ['nullable', 'date'],
|
||||
'source_channel' => ['required', 'in:app,hotel,reception,web'],
|
||||
'locale' => ['nullable', 'string', 'max:10'],
|
||||
]);
|
||||
|
||||
$ride = Ride::create([
|
||||
'pickup_label' => $validated['pickup_label'],
|
||||
'destination_label' => $validated['destination_label'],
|
||||
'scheduled_for' => $validated['scheduled_for'] ?? null,
|
||||
'status' => 'confirmed',
|
||||
'eta_minutes' => $this->estimateEta($validated['pickup_label'], $validated['destination_label']),
|
||||
'source_channel' => $validated['source_channel'],
|
||||
'context_zone' => $this->resolveZone($validated['destination_label']),
|
||||
'locale' => $validated['locale'] ?? app()->getLocale(),
|
||||
]);
|
||||
|
||||
$this->eventTracker->log('request_created', $ride, meta: [
|
||||
'source_channel' => $ride->source_channel,
|
||||
'context_zone' => $ride->context_zone,
|
||||
]);
|
||||
|
||||
$this->syncRecommendations($ride);
|
||||
|
||||
return redirect()->route('rides.confirmed', $ride);
|
||||
}
|
||||
|
||||
public function confirmed(Ride $ride): View
|
||||
{
|
||||
$ride->load(['recommendations.offer']);
|
||||
|
||||
if ($ride->recommendations->isEmpty()) {
|
||||
$this->syncRecommendations($ride);
|
||||
$ride->load(['recommendations.offer']);
|
||||
}
|
||||
|
||||
foreach ($ride->recommendations as $recommendation) {
|
||||
$this->eventTracker->logOncePerSession(
|
||||
'recommendation_viewed',
|
||||
'rec-viewed-'.$recommendation->id,
|
||||
$ride,
|
||||
$recommendation->offer,
|
||||
null,
|
||||
$recommendation,
|
||||
['position' => $recommendation->position]
|
||||
);
|
||||
|
||||
if (!$recommendation->was_viewed) {
|
||||
$recommendation->forceFill(['was_viewed' => true])->save();
|
||||
}
|
||||
}
|
||||
|
||||
return view('rides.confirmed', [
|
||||
'ride' => $ride,
|
||||
'recommendations' => $ride->recommendations,
|
||||
]);
|
||||
}
|
||||
|
||||
protected function syncRecommendations(Ride $ride): void
|
||||
{
|
||||
$offers = $this->recommendationEngine->recommendFor($ride, 3);
|
||||
|
||||
$ride->recommendations()->delete();
|
||||
|
||||
foreach ($offers as $index => $offer) {
|
||||
RideRecommendation::create([
|
||||
'ride_id' => $ride->id,
|
||||
'offer_id' => $offer->id,
|
||||
'position' => $index + 1,
|
||||
'score' => $offer->demo_score,
|
||||
'reason' => $offer->demo_reason,
|
||||
'was_viewed' => false,
|
||||
'was_clicked' => false,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
protected function resolveZone(string $destinationLabel): string
|
||||
{
|
||||
$normalized = mb_strtolower($destinationLabel);
|
||||
|
||||
return match (true) {
|
||||
str_contains($normalized, 'beach') => 'beach',
|
||||
str_contains($normalized, 'old town') => 'old town',
|
||||
str_contains($normalized, 'marina') => 'marina',
|
||||
str_contains($normalized, 'center'), str_contains($normalized, 'centre') => 'city center',
|
||||
default => trim($destinationLabel),
|
||||
};
|
||||
}
|
||||
|
||||
protected function estimateEta(string $pickup, string $destination): int
|
||||
{
|
||||
$seed = strlen($pickup) + strlen($destination);
|
||||
return max(4, min(16, ($seed % 13) + 4));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,9 +2,58 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Booking extends Model
|
||||
{
|
||||
//
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'ride_id',
|
||||
'offer_id',
|
||||
'ride_recommendation_id',
|
||||
'customer_name',
|
||||
'customer_email',
|
||||
'customer_phone',
|
||||
'party_size',
|
||||
'booking_for',
|
||||
'status',
|
||||
'amount',
|
||||
'commission_amount',
|
||||
'notes',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'booking_for' => 'datetime',
|
||||
'amount' => 'decimal:2',
|
||||
'commission_amount' => 'decimal:2',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (Booking $booking) {
|
||||
if (blank($booking->uuid)) {
|
||||
$booking->uuid = (string) Str::uuid();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function ride(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Ride::class);
|
||||
}
|
||||
|
||||
public function offer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Offer::class);
|
||||
}
|
||||
|
||||
public function recommendation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(RideRecommendation::class, 'ride_recommendation_id');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,9 +2,49 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Event extends Model
|
||||
{
|
||||
//
|
||||
use HasFactory;
|
||||
|
||||
public const UPDATED_AT = null;
|
||||
|
||||
protected $fillable = [
|
||||
'event_type',
|
||||
'ride_id',
|
||||
'offer_id',
|
||||
'booking_id',
|
||||
'ride_recommendation_id',
|
||||
'session_id',
|
||||
'meta',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'meta' => 'array',
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function ride(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Ride::class);
|
||||
}
|
||||
|
||||
public function offer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Offer::class);
|
||||
}
|
||||
|
||||
public function booking(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Booking::class);
|
||||
}
|
||||
|
||||
public function recommendation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(RideRecommendation::class, 'ride_recommendation_id');
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,9 +2,67 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Offer extends Model
|
||||
{
|
||||
//
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'title',
|
||||
'slug',
|
||||
'category',
|
||||
'excerpt',
|
||||
'description',
|
||||
'location_label',
|
||||
'lat',
|
||||
'lng',
|
||||
'price_from',
|
||||
'duration_minutes',
|
||||
'image_url',
|
||||
'status',
|
||||
'is_featured',
|
||||
'priority_score',
|
||||
'available_now',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'lat' => 'decimal:7',
|
||||
'lng' => 'decimal:7',
|
||||
'price_from' => 'decimal:2',
|
||||
'is_featured' => 'boolean',
|
||||
'available_now' => 'boolean',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (Offer $offer) {
|
||||
if (blank($offer->uuid)) {
|
||||
$offer->uuid = (string) Str::uuid();
|
||||
}
|
||||
|
||||
if (blank($offer->slug)) {
|
||||
$offer->slug = Str::slug($offer->title);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function recommendations(): HasMany
|
||||
{
|
||||
return $this->hasMany(RideRecommendation::class);
|
||||
}
|
||||
|
||||
public function bookings(): HasMany
|
||||
{
|
||||
return $this->hasMany(Booking::class);
|
||||
}
|
||||
|
||||
public function events(): HasMany
|
||||
{
|
||||
return $this->hasMany(Event::class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,9 +2,60 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Ride extends Model
|
||||
{
|
||||
//
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'uuid',
|
||||
'pickup_label',
|
||||
'pickup_lat',
|
||||
'pickup_lng',
|
||||
'destination_label',
|
||||
'destination_lat',
|
||||
'destination_lng',
|
||||
'scheduled_for',
|
||||
'status',
|
||||
'eta_minutes',
|
||||
'source_channel',
|
||||
'context_zone',
|
||||
'locale',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'pickup_lat' => 'decimal:7',
|
||||
'pickup_lng' => 'decimal:7',
|
||||
'destination_lat' => 'decimal:7',
|
||||
'destination_lng' => 'decimal:7',
|
||||
'scheduled_for' => 'datetime',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (Ride $ride) {
|
||||
if (blank($ride->uuid)) {
|
||||
$ride->uuid = (string) Str::uuid();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function recommendations(): HasMany
|
||||
{
|
||||
return $this->hasMany(RideRecommendation::class)->orderBy('position');
|
||||
}
|
||||
|
||||
public function bookings(): HasMany
|
||||
{
|
||||
return $this->hasMany(Booking::class);
|
||||
}
|
||||
|
||||
public function events(): HasMany
|
||||
{
|
||||
return $this->hasMany(Event::class);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,9 +2,39 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class RideRecommendation extends Model
|
||||
{
|
||||
//
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'ride_id',
|
||||
'offer_id',
|
||||
'position',
|
||||
'score',
|
||||
'reason',
|
||||
'was_viewed',
|
||||
'was_clicked',
|
||||
'clicked_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'score' => 'decimal:2',
|
||||
'was_viewed' => 'boolean',
|
||||
'was_clicked' => 'boolean',
|
||||
'clicked_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function ride(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Ride::class);
|
||||
}
|
||||
|
||||
public function offer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Offer::class);
|
||||
}
|
||||
}
|
||||
|
||||
40
laravel_tmp/app/Services/EventTracker.php
Normal file
40
laravel_tmp/app/Services/EventTracker.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Event;
|
||||
use App\Models\Offer;
|
||||
use App\Models\Ride;
|
||||
use App\Models\RideRecommendation;
|
||||
|
||||
class EventTracker
|
||||
{
|
||||
public function log(string $eventType, ?Ride $ride = null, ?Offer $offer = null, ?Booking $booking = null, ?RideRecommendation $recommendation = null, array $meta = []): Event
|
||||
{
|
||||
return Event::create([
|
||||
'event_type' => $eventType,
|
||||
'ride_id' => $ride?->id,
|
||||
'offer_id' => $offer?->id,
|
||||
'booking_id' => $booking?->id,
|
||||
'ride_recommendation_id' => $recommendation?->id,
|
||||
'session_id' => session()->getId(),
|
||||
'meta' => $meta ?: null,
|
||||
'created_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function logOncePerSession(string $eventType, string $dedupeKey, ?Ride $ride = null, ?Offer $offer = null, ?Booking $booking = null, ?RideRecommendation $recommendation = null, array $meta = []): ?Event
|
||||
{
|
||||
$logged = session()->get('event_dedupe', []);
|
||||
|
||||
if (in_array($dedupeKey, $logged, true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$logged[] = $dedupeKey;
|
||||
session()->put('event_dedupe', $logged);
|
||||
|
||||
return $this->log($eventType, $ride, $offer, $booking, $recommendation, $meta);
|
||||
}
|
||||
}
|
||||
72
laravel_tmp/app/Services/RecommendationEngine.php
Normal file
72
laravel_tmp/app/Services/RecommendationEngine.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Offer;
|
||||
use App\Models\Ride;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class RecommendationEngine
|
||||
{
|
||||
public function recommendFor(Ride $ride, int $limit = 3): Collection
|
||||
{
|
||||
$zone = Str::lower((string) $ride->context_zone);
|
||||
$destination = Str::lower((string) $ride->destination_label);
|
||||
$hour = optional($ride->scheduled_for)->hour ?? now()->hour;
|
||||
|
||||
return Offer::query()
|
||||
->where('status', 'published')
|
||||
->get()
|
||||
->map(function (Offer $offer) use ($zone, $destination, $hour) {
|
||||
$score = (int) $offer->priority_score;
|
||||
$reasons = [];
|
||||
$haystack = Str::lower(trim(($offer->location_label ?? '').' '.$offer->title.' '.$offer->excerpt.' '.$offer->description));
|
||||
|
||||
if ($offer->available_now) {
|
||||
$score += 18;
|
||||
$reasons[] = 'Available right now';
|
||||
}
|
||||
|
||||
if ($offer->is_featured) {
|
||||
$score += 14;
|
||||
$reasons[] = 'Featured partner';
|
||||
}
|
||||
|
||||
foreach (array_filter([$zone, $destination]) as $needle) {
|
||||
if ($needle !== '' && Str::contains($haystack, $needle)) {
|
||||
$score += 22;
|
||||
$reasons[] = 'Matches destination context';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($hour >= 18 && $offer->category === 'restaurant') {
|
||||
$score += 12;
|
||||
$reasons[] = 'Good fit for the evening';
|
||||
}
|
||||
|
||||
if ($hour >= 10 && $hour <= 18 && in_array($offer->category, ['experience', 'activity'], true)) {
|
||||
$score += 12;
|
||||
$reasons[] = 'Works well while waiting or after arrival';
|
||||
}
|
||||
|
||||
if (($offer->duration_minutes ?? 0) > 0 && $offer->duration_minutes <= 120) {
|
||||
$score += 8;
|
||||
$reasons[] = 'Easy to fit into today';
|
||||
}
|
||||
|
||||
if (($offer->price_from ?? 0) > 0 && $offer->price_from <= 50) {
|
||||
$score += 6;
|
||||
$reasons[] = 'Easy price point';
|
||||
}
|
||||
|
||||
$offer->demo_score = $score;
|
||||
$offer->demo_reason = collect($reasons)->unique()->take(2)->implode(' · ') ?: 'Strong local fit';
|
||||
return $offer;
|
||||
})
|
||||
->sortByDesc(fn (Offer $offer) => [$offer->demo_score, $offer->is_featured, $offer->priority_score])
|
||||
->take($limit)
|
||||
->values();
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,7 @@ return [
|
||||
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
'key' => env('APP_KEY'),
|
||||
'key' => env('APP_KEY', 'base64:6A3w22uOZ9g3q4kS4hA4O1ohs04E4+PGcfNP9m2OE8A='),
|
||||
|
||||
'previous_keys' => [
|
||||
...array_filter(
|
||||
|
||||
@ -1,34 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Query\Grammars\MySqlGrammar as Mysql;
|
||||
use Illuminate\Support\Str;
|
||||
use Pdo\Mysql;
|
||||
|
||||
$dbConfigPaths = [base_path('db/config.php'), dirname(base_path()).'/db/config.php'];
|
||||
foreach ($dbConfigPaths as $dbConfigPath) {
|
||||
if (file_exists($dbConfigPath)) {
|
||||
require_once $dbConfigPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Database Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify which of the database connections below you wish
|
||||
| to use as your default connection for database operations. This is
|
||||
| the connection which will be utilized unless another connection
|
||||
| is explicitly specified when you execute a query / statement.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('DB_CONNECTION', 'sqlite'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Database Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Below are all of the database connections defined for your application.
|
||||
| An example configuration is provided for each database system which
|
||||
| is supported by Laravel. You're free to add / remove connections.
|
||||
|
|
||||
*/
|
||||
'default' => env('DB_CONNECTION', 'mysql'),
|
||||
|
||||
'connections' => [
|
||||
|
||||
@ -47,11 +32,11 @@ return [
|
||||
'mysql' => [
|
||||
'driver' => 'mysql',
|
||||
'url' => env('DB_URL'),
|
||||
'host' => env('DB_HOST', '127.0.0.1'),
|
||||
'host' => defined('DB_HOST') ? DB_HOST : env('DB_HOST', '127.0.0.1'),
|
||||
'port' => env('DB_PORT', '3306'),
|
||||
'database' => env('DB_DATABASE', 'laravel'),
|
||||
'username' => env('DB_USERNAME', 'root'),
|
||||
'password' => env('DB_PASSWORD', ''),
|
||||
'database' => defined('DB_NAME') ? DB_NAME : env('DB_DATABASE', 'laravel'),
|
||||
'username' => defined('DB_USER') ? DB_USER : env('DB_USERNAME', 'root'),
|
||||
'password' => defined('DB_PASS') ? DB_PASS : env('DB_PASSWORD', ''),
|
||||
'unix_socket' => env('DB_SOCKET', ''),
|
||||
'charset' => env('DB_CHARSET', 'utf8mb4'),
|
||||
'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
|
||||
@ -80,7 +65,7 @@ return [
|
||||
'strict' => true,
|
||||
'engine' => null,
|
||||
'options' => extension_loaded('pdo_mysql') ? array_filter([
|
||||
(PHP_VERSION_ID >= 80500 ? Mysql::ATTR_SSL_CA : PDO::MYSQL_ATTR_SSL_CA) => env('MYSQL_ATTR_SSL_CA'),
|
||||
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
|
||||
]) : [],
|
||||
],
|
||||
|
||||
@ -96,7 +81,7 @@ return [
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
'search_path' => 'public',
|
||||
'sslmode' => env('DB_SSLMODE', 'prefer'),
|
||||
'sslmode' => 'prefer',
|
||||
],
|
||||
|
||||
'sqlsrv' => [
|
||||
@ -110,39 +95,17 @@ return [
|
||||
'charset' => env('DB_CHARSET', 'utf8'),
|
||||
'prefix' => '',
|
||||
'prefix_indexes' => true,
|
||||
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
'encrypt' => env('DB_ENCRYPT', 'yes'),
|
||||
'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Migration Repository Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This table keeps track of all the migrations that have already run for
|
||||
| your application. Using this information, we can determine which of
|
||||
| the migrations on disk haven't actually been run on the database.
|
||||
|
|
||||
*/
|
||||
|
||||
'migrations' => [
|
||||
'table' => 'migrations',
|
||||
'update_date_on_publish' => true,
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Redis Databases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Redis is an open source, fast, and advanced key-value store that also
|
||||
| provides a richer body of commands than a typical key-value system
|
||||
| such as Memcached. You may define your connection settings here.
|
||||
|
|
||||
*/
|
||||
|
||||
'redis' => [
|
||||
|
||||
'client' => env('REDIS_CLIENT', 'phpredis'),
|
||||
@ -160,10 +123,6 @@ return [
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DB', '0'),
|
||||
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||
],
|
||||
|
||||
'cache' => [
|
||||
@ -173,10 +132,6 @@ return [
|
||||
'password' => env('REDIS_PASSWORD'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_CACHE_DB', '1'),
|
||||
'max_retries' => env('REDIS_MAX_RETRIES', 3),
|
||||
'backoff_algorithm' => env('REDIS_BACKOFF_ALGORITHM', 'decorrelated_jitter'),
|
||||
'backoff_base' => env('REDIS_BACKOFF_BASE', 100),
|
||||
'backoff_cap' => env('REDIS_BACKOFF_CAP', 1000),
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
@ -6,20 +6,30 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('offers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->string('title');
|
||||
$table->string('slug')->unique();
|
||||
$table->enum('category', ['restaurant', 'experience', 'activity', 'product', 'service']);
|
||||
$table->string('excerpt')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->string('location_label')->nullable();
|
||||
$table->decimal('lat', 10, 7)->nullable();
|
||||
$table->decimal('lng', 10, 7)->nullable();
|
||||
$table->decimal('price_from', 10, 2)->nullable();
|
||||
$table->unsignedInteger('duration_minutes')->nullable();
|
||||
$table->string('image_url')->nullable();
|
||||
$table->enum('status', ['draft', 'published', 'paused'])->default('draft');
|
||||
$table->boolean('is_featured')->default(false);
|
||||
$table->integer('priority_score')->default(0);
|
||||
$table->boolean('available_now')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('offers');
|
||||
|
||||
@ -6,20 +6,24 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('ride_recommendations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('ride_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('offer_id')->constrained()->cascadeOnDelete();
|
||||
$table->unsignedTinyInteger('position');
|
||||
$table->decimal('score', 8, 2)->nullable();
|
||||
$table->string('reason')->nullable();
|
||||
$table->boolean('was_viewed')->default(false);
|
||||
$table->boolean('was_clicked')->default(false);
|
||||
$table->timestamp('clicked_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['ride_id', 'offer_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ride_recommendations');
|
||||
|
||||
@ -6,20 +6,27 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('bookings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->foreignId('ride_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignId('offer_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('ride_recommendation_id')->nullable()->constrained('ride_recommendations')->nullOnDelete();
|
||||
$table->string('customer_name')->nullable();
|
||||
$table->string('customer_email')->nullable();
|
||||
$table->string('customer_phone')->nullable();
|
||||
$table->unsignedInteger('party_size')->default(1);
|
||||
$table->dateTime('booking_for')->nullable();
|
||||
$table->enum('status', ['started', 'confirmed', 'cancelled'])->default('started');
|
||||
$table->decimal('amount', 10, 2)->nullable();
|
||||
$table->decimal('commission_amount', 10, 2)->nullable();
|
||||
$table->text('notes')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('bookings');
|
||||
|
||||
@ -6,20 +6,21 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('events', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->enum('event_type', ['request_created', 'recommendation_viewed', 'recommendation_clicked', 'booking_started', 'booking_completed']);
|
||||
$table->foreignId('ride_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignId('offer_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignId('booking_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignId('ride_recommendation_id')->nullable()->constrained('ride_recommendations')->nullOnDelete();
|
||||
$table->string('session_id')->nullable();
|
||||
$table->json('meta')->nullable();
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('events');
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('rides', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->uuid('uuid')->unique();
|
||||
$table->string('pickup_label');
|
||||
$table->decimal('pickup_lat', 10, 7)->nullable();
|
||||
$table->decimal('pickup_lng', 10, 7)->nullable();
|
||||
$table->string('destination_label');
|
||||
$table->decimal('destination_lat', 10, 7)->nullable();
|
||||
$table->decimal('destination_lng', 10, 7)->nullable();
|
||||
$table->dateTime('scheduled_for')->nullable();
|
||||
$table->enum('status', ['pending', 'confirmed', 'completed', 'cancelled'])->default('pending');
|
||||
$table->unsignedTinyInteger('eta_minutes')->nullable();
|
||||
$table->enum('source_channel', ['app', 'hotel', 'reception', 'web'])->default('web');
|
||||
$table->string('context_zone')->nullable();
|
||||
$table->string('locale', 10)->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('rides');
|
||||
}
|
||||
};
|
||||
@ -2,24 +2,14 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
use WithoutModelEvents;
|
||||
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
$this->call([
|
||||
DemoDataSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,16 +2,102 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use App\Models\Offer;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DemoDataSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
$offers = [
|
||||
[
|
||||
'title' => 'Sunset Marina Table',
|
||||
'slug' => 'sunset-marina-table',
|
||||
'category' => 'restaurant',
|
||||
'excerpt' => 'A polished waterfront dinner spot for couples or small groups.',
|
||||
'description' => 'Priority seating, fast confirmation, and a memorable marina view that works well right after a taxi drop-off.',
|
||||
'location_label' => 'Marina',
|
||||
'price_from' => 42,
|
||||
'duration_minutes' => 90,
|
||||
'status' => 'published',
|
||||
'is_featured' => true,
|
||||
'priority_score' => 92,
|
||||
'available_now' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'Old Town Tapas Walk',
|
||||
'slug' => 'old-town-tapas-walk',
|
||||
'category' => 'experience',
|
||||
'excerpt' => 'A short guided route through the most photogenic local food spots.',
|
||||
'description' => 'Ideal for first-time visitors who want a curated plan without committing half a day.',
|
||||
'location_label' => 'Old Town',
|
||||
'price_from' => 34,
|
||||
'duration_minutes' => 75,
|
||||
'status' => 'published',
|
||||
'is_featured' => true,
|
||||
'priority_score' => 88,
|
||||
'available_now' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'Beach Club Day Pass',
|
||||
'slug' => 'beach-club-day-pass',
|
||||
'category' => 'activity',
|
||||
'excerpt' => 'Fast-entry pass with towel, lounger, and drink credit included.',
|
||||
'description' => 'An easy same-day upgrade for guests heading toward the waterfront zone.',
|
||||
'location_label' => 'Beach',
|
||||
'price_from' => 29,
|
||||
'duration_minutes' => 120,
|
||||
'status' => 'published',
|
||||
'is_featured' => true,
|
||||
'priority_score' => 85,
|
||||
'available_now' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'City Center Brunch Slot',
|
||||
'slug' => 'city-center-brunch-slot',
|
||||
'category' => 'restaurant',
|
||||
'excerpt' => 'Reliable reservation at a high-demand brunch concept.',
|
||||
'description' => 'Convenient for arrivals into the city core with a predictable handoff to the host team.',
|
||||
'location_label' => 'City Center',
|
||||
'price_from' => 26,
|
||||
'duration_minutes' => 60,
|
||||
'status' => 'published',
|
||||
'is_featured' => false,
|
||||
'priority_score' => 74,
|
||||
'available_now' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'Private Sailing Intro',
|
||||
'slug' => 'private-sailing-intro',
|
||||
'category' => 'experience',
|
||||
'excerpt' => 'Short premium sailing experience from the marina.',
|
||||
'description' => 'A premium upsell for guests already moving toward the port area.',
|
||||
'location_label' => 'Marina',
|
||||
'price_from' => 79,
|
||||
'duration_minutes' => 105,
|
||||
'status' => 'published',
|
||||
'is_featured' => false,
|
||||
'priority_score' => 80,
|
||||
'available_now' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'Hotel Spa Recovery',
|
||||
'slug' => 'hotel-spa-recovery',
|
||||
'category' => 'service',
|
||||
'excerpt' => 'Fast-access recovery ritual for same-day arrivals.',
|
||||
'description' => 'Especially useful after airport or station pickups with short waiting windows.',
|
||||
'location_label' => 'Hotel District',
|
||||
'price_from' => 55,
|
||||
'duration_minutes' => 60,
|
||||
'status' => 'published',
|
||||
'is_featured' => false,
|
||||
'priority_score' => 71,
|
||||
'available_now' => true,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($offers as $offer) {
|
||||
Offer::updateOrCreate(['slug' => $offer['slug']], $offer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
laravel_tmp/index.php
Normal file
10
laravel_tmp/index.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
require __DIR__.'/vendor/autoload.php';
|
||||
|
||||
/** @var \Illuminate\Foundation\Application $app */
|
||||
$app = require_once __DIR__.'/bootstrap/app.php';
|
||||
|
||||
$app->handleRequest(Illuminate\Http\Request::capture());
|
||||
34
laravel_tmp/resources/views/bookings/success.blade.php
Normal file
34
laravel_tmp/resources/views/bookings/success.blade.php
Normal file
@ -0,0 +1,34 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('title', 'Booking confirmed | ArrivalFlow')
|
||||
@section('meta_description', 'Booking success screen for the taxi-to-offer demo flow.')
|
||||
|
||||
@section('content')
|
||||
<section class="split">
|
||||
<article class="card success">
|
||||
<span class="eyebrow">6 · Booking confirmed</span>
|
||||
<h1 style="font-size:clamp(2.1rem,4vw,3.5rem);">Reservation confirmed.</h1>
|
||||
<p>{{ $booking->customer_name }} is booked for <strong>{{ $booking->offer->title }}</strong>. This step closes the demo funnel with a real <code>booking_completed</code> event.</p>
|
||||
<div class="list" style="margin-top:18px;">
|
||||
<div class="list-item">Booking UUID: {{ $booking->uuid }}</div>
|
||||
<div class="list-item">Status: {{ ucfirst($booking->status) }}</div>
|
||||
<div class="list-item">Amount: {{ $booking->amount ? '€'.number_format((float) $booking->amount, 2) : 'TBD' }}</div>
|
||||
<div class="list-item">Commission: {{ $booking->commission_amount ? '€'.number_format((float) $booking->commission_amount, 2) : 'TBD' }}</div>
|
||||
</div>
|
||||
</article>
|
||||
<aside class="card">
|
||||
<span class="eyebrow">Attribution summary</span>
|
||||
<div class="list">
|
||||
<div class="list-item">Ride linked: {{ $booking->ride?->uuid ?? 'Direct booking' }}</div>
|
||||
<div class="list-item">Recommendation linked: {{ $booking->recommendation?->id ? '#'.$booking->recommendation->position : 'No' }}</div>
|
||||
<div class="list-item">Customer email: {{ $booking->customer_email ?: 'Not provided' }}</div>
|
||||
</div>
|
||||
<div style="margin-top:18px; display:flex; gap:12px; flex-wrap:wrap;">
|
||||
<a class="btn" href="{{ route('home') }}">Start another ride</a>
|
||||
@if($booking->ride)
|
||||
<a class="btn btn-secondary" href="{{ route('rides.confirmed', $booking->ride) }}">Back to ride</a>
|
||||
@endif
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
@endsection
|
||||
1
laravel_tmp/resources/views/healthz.blade.php
Normal file
1
laravel_tmp/resources/views/healthz.blade.php
Normal file
@ -0,0 +1 @@
|
||||
ok
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user