Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d472642cf | ||
|
|
6d57abd008 | ||
|
|
429417d752 | ||
|
|
ca311e99b4 | ||
|
|
ffd5ebcc11 | ||
|
|
066b212d79 | ||
|
|
11ba79824c | ||
|
|
d844b2d94f | ||
|
|
4939586371 | ||
|
|
d1693a6dc6 |
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());
|
||||
}
|
||||
126
app/Filament/Resources/BookingResource.php
Normal file
126
app/Filament/Resources/BookingResource.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\BookingResource\Pages;
|
||||
use App\Models\Booking;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class BookingResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Booking::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-ticket';
|
||||
protected static ?string $navigationLabel = 'Reservas';
|
||||
protected static ?string $navigationGroup = 'Funnel TAXILANZ';
|
||||
protected static ?string $modelLabel = 'Reserva';
|
||||
protected static ?string $pluralModelLabel = 'Reservas';
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return (string) static::getModel()::count();
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): ?string
|
||||
{
|
||||
return 'success';
|
||||
}
|
||||
|
||||
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')->label('Trayecto')->relationship('ride', 'id')->default(null),
|
||||
Forms\Components\Select::make('offer_id')->label('Oferta')->relationship('offer', 'title')->required(),
|
||||
Forms\Components\TextInput::make('ride_recommendation_id')->label('Recomendación')->numeric()->default(null),
|
||||
Forms\Components\TextInput::make('customer_name')->label('Cliente')->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')->label('Personas')->required()->numeric()->default(1),
|
||||
Forms\Components\DateTimePicker::make('booking_for')->label('Fecha / hora'),
|
||||
Forms\Components\TextInput::make('status')->label('Estado')->required(),
|
||||
Forms\Components\TextInput::make('amount')->label('Importe')->numeric()->default(null),
|
||||
Forms\Components\TextInput::make('commission_amount')->label('Comisión')->numeric()->default(null),
|
||||
Forms\Components\Textarea::make('notes')->label('Nota')->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('created_at', 'desc')
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('offer.title')
|
||||
->label('Oferta')
|
||||
->searchable()
|
||||
->weight('semibold'),
|
||||
Tables\Columns\TextColumn::make('customer_name')
|
||||
->label('Cliente')
|
||||
->searchable()
|
||||
->description(fn (Booking $record): string => $record->ride?->pickup_label ? 'Ride: '.$record->ride->pickup_label : 'Reserva directa'),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label('Estado')
|
||||
->badge()
|
||||
->color(fn (?string $state): string => match ($state) {
|
||||
'confirmed', 'completed' => 'success',
|
||||
'pending' => 'warning',
|
||||
'cancelled' => 'danger',
|
||||
default => 'gray',
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('amount')
|
||||
->label('Importe')
|
||||
->money('EUR')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('commission_amount')
|
||||
->label('Comisión')
|
||||
->money('EUR')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('ride_recommendation_id')
|
||||
->label('Top')
|
||||
->formatStateUsing(fn ($state): string => $state ? 'Sí' : 'Directa')
|
||||
->badge()
|
||||
->color(fn ($state): string => $state ? 'primary' : 'gray'),
|
||||
Tables\Columns\TextColumn::make('booking_for')
|
||||
->label('Fecha')
|
||||
->dateTime('d/m/Y H:i')
|
||||
->sortable()
|
||||
->toggleable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Creada')
|
||||
->since()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('uuid')
|
||||
->label('UUID')
|
||||
->copyable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
116
app/Filament/Resources/EventResource.php
Normal file
116
app/Filament/Resources/EventResource.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\EventResource\Pages;
|
||||
use App\Models\Event;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class EventResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Event::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-bolt';
|
||||
protected static ?string $navigationLabel = 'Eventos';
|
||||
protected static ?string $navigationGroup = 'Funnel TAXILANZ';
|
||||
protected static ?string $modelLabel = 'Evento';
|
||||
protected static ?string $pluralModelLabel = 'Eventos';
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return (string) static::getModel()::count();
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): ?string
|
||||
{
|
||||
return 'gray';
|
||||
}
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('event_type')->label('Tipo')->required(),
|
||||
Forms\Components\Select::make('ride_id')->label('Trayecto')->relationship('ride', 'id')->default(null),
|
||||
Forms\Components\Select::make('offer_id')->label('Oferta')->relationship('offer', 'title')->default(null),
|
||||
Forms\Components\Select::make('booking_id')->label('Reserva')->relationship('booking', 'id')->default(null),
|
||||
Forms\Components\TextInput::make('ride_recommendation_id')->label('Recomendación')->numeric()->default(null),
|
||||
Forms\Components\TextInput::make('session_id')->label('Sesión')->maxLength(255)->default(null),
|
||||
Forms\Components\Textarea::make('meta')->label('Meta')->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('created_at', 'desc')
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('event_type')
|
||||
->label('Evento')
|
||||
->badge()
|
||||
->formatStateUsing(fn (?string $state): string => str($state ?: 'unknown')->replace('_', ' ')->title())
|
||||
->color(fn (?string $state): string => match ($state) {
|
||||
'request_created' => 'info',
|
||||
'recommendation_viewed' => 'warning',
|
||||
'recommendation_clicked' => 'primary',
|
||||
'booking_started' => 'gray',
|
||||
'booking_completed' => 'success',
|
||||
default => 'gray',
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('ride_id')
|
||||
->label('Ride')
|
||||
->badge()
|
||||
->color('info'),
|
||||
Tables\Columns\TextColumn::make('offer.title')
|
||||
->label('Oferta')
|
||||
->searchable()
|
||||
->toggleable(),
|
||||
Tables\Columns\TextColumn::make('booking_id')
|
||||
->label('Booking')
|
||||
->badge()
|
||||
->color('success')
|
||||
->toggleable(),
|
||||
Tables\Columns\TextColumn::make('ride_recommendation_id')
|
||||
->label('Top')
|
||||
->badge()
|
||||
->color('primary')
|
||||
->toggleable(),
|
||||
Tables\Columns\TextColumn::make('session_id')
|
||||
->label('Sesión')
|
||||
->limit(18)
|
||||
->searchable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Creado')
|
||||
->dateTime('d/m/Y H:i')
|
||||
->sortable(),
|
||||
])
|
||||
->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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
131
app/Filament/Resources/OfferResource.php
Normal file
131
app/Filament/Resources/OfferResource.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\OfferResource\Pages;
|
||||
use App\Models\Offer;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class OfferResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Offer::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-sparkles';
|
||||
protected static ?string $navigationLabel = 'Ofertas';
|
||||
protected static ?string $navigationGroup = 'Funnel TAXILANZ';
|
||||
protected static ?string $modelLabel = 'Oferta';
|
||||
protected static ?string $pluralModelLabel = 'Ofertas';
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return (string) static::getModel()::count();
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): ?string
|
||||
{
|
||||
return 'warning';
|
||||
}
|
||||
|
||||
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')->label('Título')->required()->maxLength(255),
|
||||
Forms\Components\TextInput::make('slug')->required()->maxLength(255),
|
||||
Forms\Components\TextInput::make('category')->label('Categoría')->required(),
|
||||
Forms\Components\TextInput::make('excerpt')->label('Resumen')->maxLength(255)->default(null),
|
||||
Forms\Components\Textarea::make('description')->label('Descripción')->columnSpanFull(),
|
||||
Forms\Components\TextInput::make('location_label')->label('Ubicación')->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')->label('Precio desde')->numeric()->default(null),
|
||||
Forms\Components\TextInput::make('duration_minutes')->label('Duración')->numeric()->default(null),
|
||||
Forms\Components\FileUpload::make('image_url')->label('Imagen')->image(),
|
||||
Forms\Components\TextInput::make('status')->label('Estado')->required(),
|
||||
Forms\Components\Toggle::make('is_featured')->label('Destacada')->required(),
|
||||
Forms\Components\TextInput::make('priority_score')->label('Prioridad')->required()->numeric()->default(0),
|
||||
Forms\Components\Toggle::make('available_now')->label('Disponible ahora')->required(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('priority_score', 'desc')
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('title')
|
||||
->label('Oferta')
|
||||
->searchable()
|
||||
->weight('semibold')
|
||||
->description(fn (Offer $record): string => $record->excerpt ?: ($record->location_label ?: 'Sin resumen')),
|
||||
Tables\Columns\TextColumn::make('category')
|
||||
->label('Categoría')
|
||||
->badge()
|
||||
->formatStateUsing(fn (?string $state): string => ucfirst($state ?: 'general'))
|
||||
->color('warning'),
|
||||
Tables\Columns\TextColumn::make('location_label')
|
||||
->label('Ubicación')
|
||||
->badge()
|
||||
->toggleable(),
|
||||
Tables\Columns\TextColumn::make('price_from')
|
||||
->label('Desde')
|
||||
->money('EUR')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('duration_minutes')
|
||||
->label('Duración')
|
||||
->suffix(' min')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label('Estado')
|
||||
->badge()
|
||||
->color(fn (?string $state): string => match ($state) {
|
||||
'active' => 'success',
|
||||
'draft' => 'warning',
|
||||
'archived' => 'gray',
|
||||
default => 'primary',
|
||||
}),
|
||||
Tables\Columns\IconColumn::make('available_now')
|
||||
->label('Ahora')
|
||||
->boolean(),
|
||||
Tables\Columns\IconColumn::make('is_featured')
|
||||
->label('Destacada')
|
||||
->boolean(),
|
||||
Tables\Columns\TextColumn::make('priority_score')
|
||||
->label('Prioridad')
|
||||
->badge()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Creada')
|
||||
->since()
|
||||
->sortable(),
|
||||
])
|
||||
->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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
131
app/Filament/Resources/RideResource.php
Normal file
131
app/Filament/Resources/RideResource.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\RideResource\Pages;
|
||||
use App\Models\Ride;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class RideResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Ride::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-map';
|
||||
protected static ?string $navigationLabel = 'Trayectos';
|
||||
protected static ?string $navigationGroup = 'Funnel TAXILANZ';
|
||||
protected static ?string $modelLabel = 'Trayecto';
|
||||
protected static ?string $pluralModelLabel = 'Trayectos';
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return (string) static::getModel()::count();
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): ?string
|
||||
{
|
||||
return 'primary';
|
||||
}
|
||||
|
||||
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')->label('Recogida')->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')->label('Destino')->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')->label('Programado para'),
|
||||
Forms\Components\TextInput::make('status')->label('Estado')->required(),
|
||||
Forms\Components\TextInput::make('eta_minutes')->label('ETA (min)')->numeric()->default(null),
|
||||
Forms\Components\TextInput::make('source_channel')->label('Canal')->required(),
|
||||
Forms\Components\TextInput::make('context_zone')->label('Zona')->maxLength(255)->default(null),
|
||||
Forms\Components\TextInput::make('locale')->maxLength(10)->default(null),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('created_at', 'desc')
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('pickup_label')
|
||||
->label('Trayecto')
|
||||
->searchable()
|
||||
->description(fn (Ride $record): string => '→ '.$record->destination_label)
|
||||
->weight('semibold'),
|
||||
Tables\Columns\TextColumn::make('source_channel')
|
||||
->label('Canal')
|
||||
->badge()
|
||||
->formatStateUsing(fn (?string $state): string => ucfirst($state ?: 'directo'))
|
||||
->color(fn (?string $state): string => match ($state) {
|
||||
'hotel' => 'warning',
|
||||
'app' => 'success',
|
||||
'web' => 'info',
|
||||
'reception' => 'gray',
|
||||
default => 'primary',
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('context_zone')
|
||||
->label('Zona')
|
||||
->badge()
|
||||
->searchable()
|
||||
->toggleable(),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label('Estado')
|
||||
->badge()
|
||||
->color(fn (?string $state): string => match ($state) {
|
||||
'confirmed' => 'success',
|
||||
'pending' => 'warning',
|
||||
'cancelled' => 'danger',
|
||||
default => 'gray',
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('eta_minutes')
|
||||
->label('ETA')
|
||||
->suffix(' min')
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('scheduled_for')
|
||||
->label('Programado')
|
||||
->dateTime('d/m/Y H:i')
|
||||
->sortable()
|
||||
->toggleable(),
|
||||
Tables\Columns\TextColumn::make('uuid')
|
||||
->label('UUID')
|
||||
->searchable()
|
||||
->copyable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Creado')
|
||||
->since()
|
||||
->sortable(),
|
||||
])
|
||||
->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(),
|
||||
];
|
||||
}
|
||||
}
|
||||
43
app/Filament/Widgets/FunnelOverview.php
Normal file
43
app/Filament/Widgets/FunnelOverview.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Event;
|
||||
use App\Models\Ride;
|
||||
use Filament\Widgets\StatsOverviewWidget;
|
||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
|
||||
class FunnelOverview extends StatsOverviewWidget
|
||||
{
|
||||
protected function getStats(): array
|
||||
{
|
||||
$rides = Ride::count();
|
||||
$views = Event::where('event_type', 'recommendation_viewed')->count();
|
||||
$clicks = Event::where('event_type', 'recommendation_clicked')->count();
|
||||
$bookings = Booking::count();
|
||||
$gmv = (float) Booking::sum('amount');
|
||||
$commission = (float) Booking::sum('commission_amount');
|
||||
|
||||
$viewToClick = $views > 0 ? round(($clicks / $views) * 100, 1) : 0;
|
||||
$rideToBooking = $rides > 0 ? round(($bookings / $rides) * 100, 1) : 0;
|
||||
|
||||
return [
|
||||
Stat::make('Taxi requests', number_format($rides))
|
||||
->description('Entradas del funnel')
|
||||
->color('primary'),
|
||||
Stat::make('Recommendation views', number_format($views))
|
||||
->description('Usuarios expuestos a propuestas')
|
||||
->color('info'),
|
||||
Stat::make('Clicks', number_format($clicks))
|
||||
->description('CTR vista → clic: '.$viewToClick.'%')
|
||||
->color('warning'),
|
||||
Stat::make('Bookings', number_format($bookings))
|
||||
->description('Conversión ride → booking: '.$rideToBooking.'% · GMV €'.number_format($gmv, 0))
|
||||
->color('success'),
|
||||
Stat::make('Comisión estimada', '€'.number_format($commission, 0))
|
||||
->description('Valor económico demo ya atribuible')
|
||||
->color('primary'),
|
||||
];
|
||||
}
|
||||
}
|
||||
70
app/Filament/Widgets/FunnelStageChart.php
Normal file
70
app/Filament/Widgets/FunnelStageChart.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Event;
|
||||
use App\Models\Ride;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
|
||||
class FunnelStageChart extends ChartWidget
|
||||
{
|
||||
protected static ?string $heading = 'Funnel';
|
||||
|
||||
protected int | string | array $columnSpan = 'full';
|
||||
|
||||
protected static ?int $sort = 2;
|
||||
|
||||
protected static ?string $maxHeight = '260px';
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$rides = Ride::count();
|
||||
$views = Event::where('event_type', 'recommendation_viewed')->count();
|
||||
$clicks = Event::where('event_type', 'recommendation_clicked')->count();
|
||||
$bookings = Booking::count();
|
||||
|
||||
return [
|
||||
'datasets' => [[
|
||||
'label' => 'Funnel',
|
||||
'data' => [$rides, $views, $clicks, $bookings],
|
||||
'backgroundColor' => ['#0f172a', '#f59e0b', '#0f766e', '#16a34a'],
|
||||
'borderRadius' => 12,
|
||||
'borderSkipped' => false,
|
||||
]],
|
||||
'labels' => ['Taxi', 'Espera útil', 'Detalle', 'Reserva'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'plugins' => [
|
||||
'legend' => [
|
||||
'display' => false,
|
||||
],
|
||||
],
|
||||
'scales' => [
|
||||
'x' => [
|
||||
'grid' => [
|
||||
'display' => false,
|
||||
],
|
||||
],
|
||||
'y' => [
|
||||
'beginAtZero' => true,
|
||||
'grid' => [
|
||||
'color' => 'rgba(148, 163, 184, 0.16)',
|
||||
],
|
||||
'ticks' => [
|
||||
'precision' => 0,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'bar';
|
||||
}
|
||||
}
|
||||
40
app/Filament/Widgets/JourneyStoryboard.php
Normal file
40
app/Filament/Widgets/JourneyStoryboard.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Event;
|
||||
use App\Models\Ride;
|
||||
use Filament\Widgets\Widget;
|
||||
|
||||
class JourneyStoryboard extends Widget
|
||||
{
|
||||
protected static string $view = 'filament.widgets.journey-storyboard';
|
||||
|
||||
protected int | string | array $columnSpan = 'full';
|
||||
|
||||
protected static ?int $sort = 1;
|
||||
|
||||
protected function getViewData(): array
|
||||
{
|
||||
$rides = Ride::count();
|
||||
$views = Event::where('event_type', 'recommendation_viewed')->count();
|
||||
$clicks = Event::where('event_type', 'recommendation_clicked')->count();
|
||||
$bookingsCount = Booking::count();
|
||||
$commission = (float) Booking::sum('commission_amount');
|
||||
$gmv = (float) Booking::sum('amount');
|
||||
$rideToBooking = $rides > 0 ? round(($bookingsCount / $rides) * 100, 1) : 0;
|
||||
$clickThrough = $views > 0 ? round(($clicks / $views) * 100, 1) : 0;
|
||||
|
||||
return [
|
||||
'rides' => $rides,
|
||||
'views' => $views,
|
||||
'clicks' => $clicks,
|
||||
'bookingsCount' => $bookingsCount,
|
||||
'commission' => $commission,
|
||||
'gmv' => $gmv,
|
||||
'rideToBooking' => $rideToBooking,
|
||||
'clickThrough' => $clickThrough,
|
||||
];
|
||||
}
|
||||
}
|
||||
45
app/Filament/Widgets/LatestBookingsTable.php
Normal file
45
app/Filament/Widgets/LatestBookingsTable.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\Booking;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Widgets\TableWidget as BaseWidget;
|
||||
|
||||
class LatestBookingsTable extends BaseWidget
|
||||
{
|
||||
protected static ?string $heading = 'Últimas reservas';
|
||||
|
||||
protected static ?int $sort = 4;
|
||||
|
||||
protected int | string | array $columnSpan = 1;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(Booking::query()->with(['offer', 'ride'])->latest()->limit(5))
|
||||
->paginated(false)
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('offer.title')
|
||||
->label('Oferta')
|
||||
->description(fn (Booking $record): string => $record->customer_name ?: ($record->ride?->pickup_label ?: 'Reserva directa'))
|
||||
->weight('semibold'),
|
||||
Tables\Columns\TextColumn::make('amount')
|
||||
->label('Importe')
|
||||
->money('EUR'),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label('Estado')
|
||||
->badge()
|
||||
->color(fn (?string $state): string => match ($state) {
|
||||
'confirmed', 'completed' => 'success',
|
||||
'pending' => 'warning',
|
||||
'cancelled' => 'danger',
|
||||
default => 'gray',
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Creada')
|
||||
->since(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
46
app/Filament/Widgets/LatestRidesTable.php
Normal file
46
app/Filament/Widgets/LatestRidesTable.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\Ride;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Widgets\TableWidget as BaseWidget;
|
||||
|
||||
class LatestRidesTable extends BaseWidget
|
||||
{
|
||||
protected static ?string $heading = 'Últimos trayectos';
|
||||
|
||||
protected static ?int $sort = 3;
|
||||
|
||||
protected int | string | array $columnSpan = 1;
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->query(Ride::query()->latest()->limit(5))
|
||||
->paginated(false)
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('pickup_label')
|
||||
->label('Trayecto')
|
||||
->description(fn (Ride $record): string => '→ '.$record->destination_label)
|
||||
->weight('semibold'),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->label('Estado')
|
||||
->badge()
|
||||
->formatStateUsing(fn (?string $state): string => ucfirst($state ?: 'pendiente'))
|
||||
->color(fn (?string $state): string => match ($state) {
|
||||
'confirmed', 'completed' => 'success',
|
||||
'pending' => 'warning',
|
||||
'cancelled' => 'danger',
|
||||
default => 'gray',
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('eta_minutes')
|
||||
->label('ETA')
|
||||
->formatStateUsing(fn ($state): string => $state ? $state.' min' : '—'),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Creado')
|
||||
->since(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
35
app/Filament/Widgets/SourceChannelChart.php
Normal file
35
app/Filament/Widgets/SourceChannelChart.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use App\Models\Ride;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
|
||||
class SourceChannelChart extends ChartWidget
|
||||
{
|
||||
protected static ?string $heading = 'Taxi requests por canal';
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$channels = Ride::query()
|
||||
->selectRaw('source_channel, COUNT(*) as aggregate')
|
||||
->groupBy('source_channel')
|
||||
->orderByDesc('aggregate')
|
||||
->pluck('aggregate', 'source_channel');
|
||||
|
||||
return [
|
||||
'datasets' => [[
|
||||
'label' => 'Solicitudes',
|
||||
'data' => $channels->values()->all(),
|
||||
'backgroundColor' => ['#0f766e', '#14b8a6', '#f59e0b', '#0f172a'],
|
||||
'borderWidth' => 0,
|
||||
]],
|
||||
'labels' => $channels->keys()->map(fn (string $channel) => ucfirst($channel))->all(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'bar';
|
||||
}
|
||||
}
|
||||
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
|
||||
{
|
||||
//
|
||||
}
|
||||
34
app/Http/Controllers/HomeController.php
Normal file
34
app/Http/Controllers/HomeController.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Event;
|
||||
use App\Models\Offer;
|
||||
use App\Models\Ride;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
$rides = Ride::count();
|
||||
$views = Event::where('event_type', 'recommendation_viewed')->count();
|
||||
$clicks = Event::where('event_type', 'recommendation_clicked')->count();
|
||||
$bookings = Booking::count();
|
||||
$gmv = (float) Booking::sum('amount');
|
||||
$commission = (float) Booking::sum('commission_amount');
|
||||
|
||||
return view('home', [
|
||||
'featuredOffers' => Offer::query()->where('status', 'published')->orderByDesc('is_featured')->orderByDesc('priority_score')->take(3)->get(),
|
||||
'metrics' => [
|
||||
'rides' => $rides,
|
||||
'views' => $views,
|
||||
'clicks' => $clicks,
|
||||
'bookings' => $bookings,
|
||||
'gmv' => $gmv,
|
||||
'commission' => $commission,
|
||||
'ride_to_booking_rate' => $rides > 0 ? round(($bookings / $rides) * 100, 1) : 0,
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
125
app/Http/Controllers/RideController.php
Normal file
125
app/Http/Controllers/RideController.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?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, 'puerto del carmen') => 'puerto del carmen',
|
||||
str_contains($normalized, 'playa blanca') => 'playa blanca',
|
||||
str_contains($normalized, 'costa teguise') => 'costa teguise',
|
||||
str_contains($normalized, 'arrecife') => 'arrecife',
|
||||
str_contains($normalized, 'marina') => 'marina',
|
||||
str_contains($normalized, 'playa'), str_contains($normalized, 'beach') => 'playa',
|
||||
str_contains($normalized, 'old town'), str_contains($normalized, 'casco antiguo') => 'casco antiguo',
|
||||
str_contains($normalized, 'centro'), str_contains($normalized, 'center'), str_contains($normalized, 'centre') => 'centro',
|
||||
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
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
64
app/Providers/Filament/AdminPanelProvider.php
Normal file
64
app/Providers/Filament/AdminPanelProvider.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use App\Filament\Widgets\FunnelStageChart;
|
||||
use App\Filament\Widgets\JourneyStoryboard;
|
||||
use App\Filament\Widgets\LatestBookingsTable;
|
||||
use App\Filament\Widgets\LatestRidesTable;
|
||||
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 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()
|
||||
->brandName('TAXILANZ Admin')
|
||||
->colors([
|
||||
'primary' => Color::Teal,
|
||||
])
|
||||
->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([
|
||||
JourneyStoryboard::class,
|
||||
FunnelStageChart::class,
|
||||
LatestRidesTable::class,
|
||||
LatestBookingsTable::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);
|
||||
}
|
||||
}
|
||||
73
app/Services/RecommendationEngine.php
Normal file
73
app/Services/RecommendationEngine.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?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[] = 'Disponible ahora';
|
||||
}
|
||||
|
||||
if ($offer->is_featured) {
|
||||
$score += 14;
|
||||
$reasons[] = 'Partner destacado';
|
||||
}
|
||||
|
||||
foreach (array_filter([$zone, $destination]) as $needle) {
|
||||
if ($needle !== '' && Str::contains($haystack, $needle)) {
|
||||
$score += 22;
|
||||
$reasons[] = 'Encaja con el destino';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($hour >= 18 && $offer->category === 'restaurant') {
|
||||
$score += 12;
|
||||
$reasons[] = 'Muy buena opción para esta tarde/noche';
|
||||
}
|
||||
|
||||
if ($hour >= 10 && $hour <= 18 && in_array($offer->category, ['experience', 'activity'], true)) {
|
||||
$score += 12;
|
||||
$reasons[] = 'Funciona bien durante la espera o al llegar';
|
||||
}
|
||||
|
||||
if (($offer->duration_minutes ?? 0) > 0 && $offer->duration_minutes <= 120) {
|
||||
$score += 8;
|
||||
$reasons[] = 'Fácil de encajar hoy';
|
||||
}
|
||||
|
||||
if (($offer->price_from ?? 0) > 0 && $offer->price_from <= 50) {
|
||||
$score += 6;
|
||||
$reasons[] = 'Precio fácil de aceptar';
|
||||
}
|
||||
|
||||
$offer->demo_score = $score;
|
||||
$offer->demo_reason = collect($reasons)->unique()->take(2)->implode(' · ') ?: 'Buen encaje local';
|
||||
|
||||
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,403 +0,0 @@
|
||||
body {
|
||||
background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
|
||||
background-size: 400% 400%;
|
||||
animation: gradient 15s ease infinite;
|
||||
color: #212529;
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.main-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 100vh;
|
||||
width: 100%;
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
@keyframes gradient {
|
||||
0% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
50% {
|
||||
background-position: 100% 50%;
|
||||
}
|
||||
100% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
}
|
||||
|
||||
.chat-container {
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
background: rgba(255, 255, 255, 0.85);
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
border-radius: 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 85vh;
|
||||
box-shadow: 0 20px 40px rgba(0,0,0,0.2);
|
||||
backdrop-filter: blur(15px);
|
||||
-webkit-backdrop-filter: blur(15px);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.chat-header {
|
||||
padding: 1.5rem;
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
font-weight: 700;
|
||||
font-size: 1.1rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.chat-messages {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 1.5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
/* Custom Scrollbar */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
|
||||
.message {
|
||||
max-width: 85%;
|
||||
padding: 0.85rem 1.1rem;
|
||||
border-radius: 16px;
|
||||
line-height: 1.5;
|
||||
font-size: 0.95rem;
|
||||
box-shadow: 0 4px 15px rgba(0,0,0,0.05);
|
||||
animation: fadeIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(20px) scale(0.95); }
|
||||
to { opacity: 1; transform: translateY(0) scale(1); }
|
||||
}
|
||||
|
||||
.message.visitor {
|
||||
align-self: flex-end;
|
||||
background: linear-gradient(135deg, #212529 0%, #343a40 100%);
|
||||
color: #fff;
|
||||
border-bottom-right-radius: 4px;
|
||||
}
|
||||
|
||||
.message.bot {
|
||||
align-self: flex-start;
|
||||
background: #ffffff;
|
||||
color: #212529;
|
||||
border-bottom-left-radius: 4px;
|
||||
}
|
||||
|
||||
.chat-input-area {
|
||||
padding: 1.25rem;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.chat-input-area form {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.chat-input-area input {
|
||||
flex: 1;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-radius: 12px;
|
||||
padding: 0.75rem 1rem;
|
||||
outline: none;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.chat-input-area input:focus {
|
||||
border-color: #23a6d5;
|
||||
box-shadow: 0 0 0 3px rgba(35, 166, 213, 0.2);
|
||||
}
|
||||
|
||||
.chat-input-area button {
|
||||
background: #212529;
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 0.75rem 1.5rem;
|
||||
border-radius: 12px;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.chat-input-area button:hover {
|
||||
background: #000;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
/* Background Animations */
|
||||
.bg-animations {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 0;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.blob {
|
||||
position: absolute;
|
||||
width: 500px;
|
||||
height: 500px;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-radius: 50%;
|
||||
filter: blur(80px);
|
||||
animation: move 20s infinite alternate cubic-bezier(0.45, 0, 0.55, 1);
|
||||
}
|
||||
|
||||
.blob-1 {
|
||||
top: -10%;
|
||||
left: -10%;
|
||||
background: rgba(238, 119, 82, 0.4);
|
||||
}
|
||||
|
||||
.blob-2 {
|
||||
bottom: -10%;
|
||||
right: -10%;
|
||||
background: rgba(35, 166, 213, 0.4);
|
||||
animation-delay: -7s;
|
||||
width: 600px;
|
||||
height: 600px;
|
||||
}
|
||||
|
||||
.blob-3 {
|
||||
top: 40%;
|
||||
left: 30%;
|
||||
background: rgba(231, 60, 126, 0.3);
|
||||
animation-delay: -14s;
|
||||
width: 450px;
|
||||
height: 450px;
|
||||
}
|
||||
|
||||
@keyframes move {
|
||||
0% { transform: translate(0, 0) rotate(0deg) scale(1); }
|
||||
33% { transform: translate(150px, 100px) rotate(120deg) scale(1.1); }
|
||||
66% { transform: translate(-50px, 200px) rotate(240deg) scale(0.9); }
|
||||
100% { transform: translate(0, 0) rotate(360deg) scale(1); }
|
||||
}
|
||||
|
||||
.header-link {
|
||||
font-size: 14px;
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 8px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.header-link:hover {
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* Admin Styles */
|
||||
.admin-container {
|
||||
max-width: 900px;
|
||||
margin: 3rem auto;
|
||||
padding: 2.5rem;
|
||||
background: rgba(255, 255, 255, 0.85);
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
border-radius: 24px;
|
||||
box-shadow: 0 20px 50px rgba(0,0,0,0.15);
|
||||
border: 1px solid rgba(255, 255, 255, 0.4);
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.admin-container h1 {
|
||||
margin-top: 0;
|
||||
color: #212529;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0 8px;
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.table th {
|
||||
background: transparent;
|
||||
border: none;
|
||||
padding: 1rem;
|
||||
color: #6c757d;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
font-size: 0.75rem;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.table td {
|
||||
background: #fff;
|
||||
padding: 1rem;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.table tr td:first-child { border-radius: 12px 0 0 12px; }
|
||||
.table tr td:last-child { border-radius: 0 12px 12px 0; }
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: 600;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
width: 100%;
|
||||
padding: 0.75rem 1rem;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
transition: all 0.3s ease;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.form-control:focus {
|
||||
outline: none;
|
||||
border-color: #23a6d5;
|
||||
box-shadow: 0 0 0 3px rgba(35, 166, 213, 0.1);
|
||||
}
|
||||
|
||||
.header-container {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header-links {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.admin-card {
|
||||
background: rgba(255, 255, 255, 0.6);
|
||||
padding: 2rem;
|
||||
border-radius: 20px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.5);
|
||||
margin-bottom: 2.5rem;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
.admin-card h3 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1.5rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.btn-delete {
|
||||
background: #dc3545;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.btn-add {
|
||||
background: #212529;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.btn-save {
|
||||
background: #0088cc;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 0.8rem 1.5rem;
|
||||
border-radius: 12px;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
width: 100%;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.webhook-url {
|
||||
font-size: 0.85em;
|
||||
color: #555;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.history-table-container {
|
||||
overflow-x: auto;
|
||||
background: rgba(255, 255, 255, 0.4);
|
||||
padding: 1rem;
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
|
||||
.history-table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.history-table-time {
|
||||
width: 15%;
|
||||
white-space: nowrap;
|
||||
font-size: 0.85em;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.history-table-user {
|
||||
width: 35%;
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.history-table-ai {
|
||||
width: 50%;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.no-messages {
|
||||
text-align: center;
|
||||
color: #777;
|
||||
}
|
||||
@ -1,39 +0,0 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const chatForm = document.getElementById('chat-form');
|
||||
const chatInput = document.getElementById('chat-input');
|
||||
const chatMessages = document.getElementById('chat-messages');
|
||||
|
||||
const appendMessage = (text, sender) => {
|
||||
const msgDiv = document.createElement('div');
|
||||
msgDiv.classList.add('message', sender);
|
||||
msgDiv.textContent = text;
|
||||
chatMessages.appendChild(msgDiv);
|
||||
chatMessages.scrollTop = chatMessages.scrollHeight;
|
||||
};
|
||||
|
||||
chatForm.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const message = chatInput.value.trim();
|
||||
if (!message) return;
|
||||
|
||||
appendMessage(message, 'visitor');
|
||||
chatInput.value = '';
|
||||
|
||||
try {
|
||||
const response = await fetch('api/chat.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ message })
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
// Artificial delay for realism
|
||||
setTimeout(() => {
|
||||
appendMessage(data.reply, 'bot');
|
||||
}, 500);
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
appendMessage("Sorry, something went wrong. Please try again.", 'bot');
|
||||
}
|
||||
});
|
||||
});
|
||||
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/pasted-20260406-061403-6c6e50ff.png
Normal file
BIN
assets/pasted-20260406-061403-6c6e50ff.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 MiB |
BIN
assets/pasted-20260406-063915-8fc40ab6.png
Normal file
BIN
assets/pasted-20260406-063915-8fc40ab6.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 MiB |
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 |
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,
|
||||
];
|
||||
BIN
composer-local
Executable file
BIN
composer-local
Executable file
Binary file not shown.
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' => 'Mesa atardecer en Marina Lanzarote',
|
||||
'slug' => 'sunset-marina-table',
|
||||
'category' => 'restaurant',
|
||||
'excerpt' => 'Cena frente al puerto con confirmación rápida para parejas o grupos pequeños.',
|
||||
'description' => 'Una propuesta premium pero fácil de cerrar justo después del traslado, con vista a la marina y entrada sin fricción.',
|
||||
'location_label' => 'Marina',
|
||||
'price_from' => 42,
|
||||
'duration_minutes' => 90,
|
||||
'status' => 'published',
|
||||
'is_featured' => true,
|
||||
'priority_score' => 92,
|
||||
'available_now' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'Ruta de tapas por el casco antiguo',
|
||||
'slug' => 'old-town-tapas-walk',
|
||||
'category' => 'experience',
|
||||
'excerpt' => 'Recorrido corto por paradas fotogénicas y muy fáciles de disfrutar el mismo día.',
|
||||
'description' => 'Pensado para primeros visitantes que quieren una experiencia local curada sin bloquear media jornada.',
|
||||
'location_label' => 'Casco antiguo',
|
||||
'price_from' => 34,
|
||||
'duration_minutes' => 75,
|
||||
'status' => 'published',
|
||||
'is_featured' => true,
|
||||
'priority_score' => 88,
|
||||
'available_now' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'Beach club con acceso rápido',
|
||||
'slug' => 'beach-club-day-pass',
|
||||
'category' => 'activity',
|
||||
'excerpt' => 'Acceso directo con tumbona, toalla y crédito de bebida incluido.',
|
||||
'description' => 'Ideal para turistas que se dirigen a zona de playa y quieren una mejora simple, inmediata y medible.',
|
||||
'location_label' => 'Playa',
|
||||
'price_from' => 29,
|
||||
'duration_minutes' => 120,
|
||||
'status' => 'published',
|
||||
'is_featured' => true,
|
||||
'priority_score' => 85,
|
||||
'available_now' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'Brunch asegurado en Arrecife centro',
|
||||
'slug' => 'city-center-brunch-slot',
|
||||
'category' => 'restaurant',
|
||||
'excerpt' => 'Reserva fiable en un local demandado del centro.',
|
||||
'description' => 'Muy útil para llegadas al núcleo urbano con necesidad de una decisión simple y rápida.',
|
||||
'location_label' => 'Arrecife',
|
||||
'price_from' => 26,
|
||||
'duration_minutes' => 60,
|
||||
'status' => 'published',
|
||||
'is_featured' => false,
|
||||
'priority_score' => 74,
|
||||
'available_now' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'Salida premium desde Puerto del Carmen',
|
||||
'slug' => 'private-sailing-intro',
|
||||
'category' => 'experience',
|
||||
'excerpt' => 'Experiencia breve en barco para elevar una tarde sin complicaciones.',
|
||||
'description' => 'Upsell premium para huéspedes que ya van hacia marina o zona costera y están listos para decidir.',
|
||||
'location_label' => 'Puerto del Carmen',
|
||||
'price_from' => 79,
|
||||
'duration_minutes' => 105,
|
||||
'status' => 'published',
|
||||
'is_featured' => false,
|
||||
'priority_score' => 80,
|
||||
'available_now' => true,
|
||||
],
|
||||
[
|
||||
'title' => 'Ritual spa recovery de llegada',
|
||||
'slug' => 'hotel-spa-recovery',
|
||||
'category' => 'service',
|
||||
'excerpt' => 'Acceso rápido a un ritual de recuperación para el mismo día.',
|
||||
'description' => 'Útil tras recogidas en aeropuerto u hotel cuando hay una ventana corta antes del siguiente plan.',
|
||||
'location_label' => 'Zona hotelera',
|
||||
'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);
|
||||
}
|
||||
}
|
||||
}
|
||||
156
index.php
156
index.php
@ -1,150 +1,10 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
@ini_set('display_errors', '1');
|
||||
@error_reporting(E_ALL);
|
||||
@date_default_timezone_set('UTC');
|
||||
|
||||
$phpVersion = PHP_VERSION;
|
||||
$now = date('Y-m-d H:i:s');
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<?php
|
||||
// Read project preview data from environment
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<?php if ($projectDescription): ?>
|
||||
<!-- Meta description -->
|
||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
||||
<!-- Open Graph meta tags -->
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<!-- Twitter meta tags -->
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<!-- Open Graph image -->
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<!-- Twitter image -->
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
:root {
|
||||
--bg-color-start: #6a11cb;
|
||||
--bg-color-end: #2575fc;
|
||||
--text-color: #ffffff;
|
||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
||||
color: var(--text-color);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
body::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
||||
animation: bg-pan 20s linear infinite;
|
||||
z-index: -1;
|
||||
}
|
||||
@keyframes bg-pan {
|
||||
0% { background-position: 0% 0%; }
|
||||
100% { background-position: 100% 100%; }
|
||||
}
|
||||
main {
|
||||
padding: 2rem;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-bg-color);
|
||||
border: 1px solid var(--card-border-color);
|
||||
border-radius: 16px;
|
||||
padding: 2rem;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.loader {
|
||||
margin: 1.25rem auto 1.25rem;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
||||
border-top-color: #fff;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
@keyframes spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
.hint {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.sr-only {
|
||||
position: absolute;
|
||||
width: 1px; height: 1px;
|
||||
padding: 0; margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
white-space: nowrap; border: 0;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin: 0 0 1rem;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
p {
|
||||
margin: 0.5rem 0;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
code {
|
||||
background: rgba(0,0,0,0.2);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your website…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
</div>
|
||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.</p>
|
||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
||||
</div>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
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());
|
||||
|
||||
18
laravel_tmp/.editorconfig
Normal file
18
laravel_tmp/.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
laravel_tmp/.env.example
Normal file
65
laravel_tmp/.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
laravel_tmp/.gitattributes
vendored
Normal file
11
laravel_tmp/.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
|
||||
24
laravel_tmp/.gitignore
vendored
Normal file
24
laravel_tmp/.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
*.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
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>
|
||||
59
laravel_tmp/README.md
Normal file
59
laravel_tmp/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).
|
||||
70
laravel_tmp/app/Http/Controllers/BookingController.php
Normal file
70
laravel_tmp/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
laravel_tmp/app/Http/Controllers/Controller.php
Normal file
8
laravel_tmp/app/Http/Controllers/Controller.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
22
laravel_tmp/app/Http/Controllers/HomeController.php
Normal file
22
laravel_tmp/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
laravel_tmp/app/Http/Controllers/OfferController.php
Normal file
48
laravel_tmp/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
laravel_tmp/app/Http/Controllers/RideController.php
Normal file
120
laravel_tmp/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
laravel_tmp/app/Models/Booking.php
Normal file
59
laravel_tmp/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
laravel_tmp/app/Models/Event.php
Normal file
50
laravel_tmp/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
laravel_tmp/app/Models/Offer.php
Normal file
68
laravel_tmp/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
laravel_tmp/app/Models/Ride.php
Normal file
61
laravel_tmp/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
laravel_tmp/app/Models/RideRecommendation.php
Normal file
40
laravel_tmp/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);
|
||||
}
|
||||
}
|
||||
49
laravel_tmp/app/Models/User.php
Normal file
49
laravel_tmp/app/Models/User.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// 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
|
||||
{
|
||||
/** @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',
|
||||
];
|
||||
}
|
||||
}
|
||||
24
laravel_tmp/app/Providers/AppServiceProvider.php
Normal file
24
laravel_tmp/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
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
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