fix free draw

This commit is contained in:
Nyavokevin 2025-09-15 21:12:10 +03:00
parent 153e700b8a
commit 7353aae1f1
89 changed files with 777 additions and 8 deletions

View File

@ -57,11 +57,14 @@ class CardController extends Controller
]);
}
public function cartResult()
public function freeCartResult($id)
{
return Inertia::render('cards/resultat', [
$card = $this->cardRepository->find($id);
]);
return response()->json([
'success' => true,
'cards' => $card,
]);
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use App\Support\CardCsvImporter;
class CardImportController extends Controller
{
public function store(Request $request)
{
$validated = $request->validate([
'csv' => 'required|file|mimetypes:text/plain,text/csv,application/vnd.ms-excel,application/csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'delimiter' => 'nullable|string|in:;,|,',
'dry_run' => 'nullable|boolean',
]);
$delimiter = $request->input('delimiter', ',');
$dryRun = $request->boolean('dry_run', false);
$path = $request->file('csv')->store('imports');
$fullPath = Storage::path($path);
$importer = new CardCsvImporter();
[$inserted, $updated, $skipped] = $importer->import($fullPath, $delimiter, $dryRun);
return response()->json([
'inserted' => $inserted,
'updated' => $updated,
'skipped' => $skipped,
'dry_run' => $dryRun,
'path' => $path,
]);
}
}

View File

@ -0,0 +1,151 @@
<?php
namespace App\Support;
use App\Models\Card;
class CardCsvImporter
{
/**
* Import cards from a CSV or XLSX file (upsert by name/title).
* Returns array [inserted, updated, skipped].
*/
public function import(string $file, string $delimiter = ',', bool $dryRun = false): array
{
if (!is_file($file)) {
throw new \InvalidArgumentException("File not found: {$file}");
}
[$headers, $rows] = $this->readRows($file, $delimiter);
if (empty($headers)) {
return [0, 0, 0];
}
// Normalize headers (lowercase, trimmed, remove BOM)
$headers = array_map(function ($h) {
$h = (string) ($h ?? '');
$h = preg_replace('/^\xEF\xBB\xBF/', '', $h); // strip UTF-8 BOM
return strtolower(trim($h));
}, $headers);
$idx = array_flip($headers);
$nameKey = array_key_exists('name', $idx) ? 'name' : (array_key_exists('title', $idx) ? 'title' : null);
if (!$nameKey) {
throw new \RuntimeException('CSV must contain a "name" or "title" header.');
}
$get = function (array $row, string $key) use ($idx): ?string {
if (!array_key_exists($key, $idx)) return null;
$value = $row[$idx[$key]] ?? null;
return is_string($value) ? trim($value) : (is_null($value) ? null : trim((string) $value));
};
$inserted = 0;
$updated = 0;
$skipped = 0;
foreach ($rows as $row) {
if (!is_array($row)) continue;
if (count(array_filter($row, fn($v) => $v !== null && $v !== '')) === 0) continue;
$name = $get($row, $nameKey);
if (!$name) { $skipped++; continue; }
$payload = [
'description_upright' => (string) ($get($row, 'description_upright') ?? ''),
'description_reversed' => (string) ($get($row, 'description_reversed') ?? ''),
'image_url' => $get($row, 'image_url') ?: null,
'symbolism' => $this->parseSymbolism($get($row, 'symbolism')),
];
if ($dryRun) {
continue;
}
$existing = Card::where('name', $name)->first();
if ($existing) {
$existing->fill($payload)->save();
$updated++;
} else {
Card::create(array_merge(['name' => $name], $payload));
$inserted++;
}
}
return [$inserted, $updated, $skipped];
}
/**
* Read headers and rows from CSV or XLSX.
* @return array{0: array<int,string>, 1: array<int,array<int,string|null>>>}
*/
private function readRows(string $file, string $delimiter): array
{
$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
if (in_array($ext, ['xlsx', 'xls', 'ods'])) {
if (!class_exists('PhpOffice\\PhpSpreadsheet\\IOFactory')) {
throw new \RuntimeException('XLSX import requires phpoffice/phpspreadsheet. Run: composer require phpoffice/phpspreadsheet');
}
/** @var \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet */
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file);
$sheet = $spreadsheet->getActiveSheet();
$data = $sheet->toArray(null, true, true, false); // rows of arrays
if (empty($data)) return [[], []];
$headers = array_map(fn($v) => is_string($v) ? $v : (is_null($v) ? '' : (string) $v), array_shift($data));
$rows = array_map(function ($row) use ($headers) {
// Normalize row length to headers length
$row = array_map(fn($v) => is_string($v) ? $v : (is_null($v) ? null : (string) $v), $row);
if (count($row) < count($headers)) {
$row = array_pad($row, count($headers), null);
} elseif (count($row) > count($headers)) {
$row = array_slice($row, 0, count($headers));
}
return $row;
}, $data);
return [$headers, $rows];
}
// Default: treat as CSV/TSV/plain text
$csv = new \SplFileObject($file, 'r');
$csv->setFlags(\SplFileObject::READ_CSV | \SplFileObject::SKIP_EMPTY | \SplFileObject::DROP_NEW_LINE);
$csv->setCsvControl($delimiter);
if ($csv->eof()) return [[], []];
$headers = $csv->fgetcsv();
if (!$headers || !is_array($headers)) return [[], []];
$headers = array_map(fn($h) => is_string($h) ? $h : (is_null($h) ? '' : (string) $h), $headers);
$rows = [];
foreach ($csv as $row) {
if (!is_array($row)) continue;
$rows[] = $row;
}
return [$headers, $rows];
}
/**
* Parse symbolism string into an array suitable for the Card::casts ['symbolism' => 'array'].
* Accepts JSON arrays or delimited strings (separated by ;, |, , or ,).
*/
public function parseSymbolism(?string $raw): array
{
$raw = trim((string) $raw);
if ($raw === '') return [];
// Try JSON first
if (str_starts_with($raw, '[') || str_starts_with($raw, '{')) {
$decoded = json_decode($raw, true);
if (json_last_error() === JSON_ERROR_NONE) {
if (is_array($decoded)) return array_values($decoded);
return [];
}
}
$parts = preg_split('/[;|•,]+/u', $raw);
$parts = array_map(fn($s) => trim($s), $parts);
$parts = array_filter($parts, fn($s) => $s !== '');
return array_values($parts);
}
}

View File

@ -16,6 +16,7 @@
"laravel/sanctum": "^4.0",
"laravel/tinker": "^2.10.1",
"laravel/wayfinder": "^0.1.9",
"phpoffice/phpspreadsheet": "^5.1",
"stripe/stripe-php": "^17.6"
},
"require-dev": {

372
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "748c4d7177ae376a830b7c336264affd",
"content-hash": "1d6b8072efd73299b27b98a022bb547d",
"packages": [
{
"name": "brick/math",
@ -135,6 +135,85 @@
],
"time": "2024-02-09T16:56:22+00:00"
},
{
"name": "composer/pcre",
"version": "3.3.2",
"source": {
"type": "git",
"url": "https://github.com/composer/pcre.git",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0"
},
"conflict": {
"phpstan/phpstan": "<1.11.10"
},
"require-dev": {
"phpstan/phpstan": "^1.12 || ^2",
"phpstan/phpstan-strict-rules": "^1 || ^2",
"phpunit/phpunit": "^8 || ^9"
},
"type": "library",
"extra": {
"phpstan": {
"includes": [
"extension.neon"
]
},
"branch-alias": {
"dev-main": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\Pcre\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "PCRE wrapping library that offers type-safe preg_* replacements.",
"keywords": [
"PCRE",
"preg",
"regex",
"regular expression"
],
"support": {
"issues": "https://github.com/composer/pcre/issues",
"source": "https://github.com/composer/pcre/tree/3.3.2"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/composer/composer",
"type": "tidelift"
}
],
"time": "2024-11-12T16:29:46+00:00"
},
{
"name": "dflydev/dot-access-data",
"version": "v3.0.3",
@ -2203,6 +2282,191 @@
],
"time": "2024-12-08T08:18:47+00:00"
},
{
"name": "maennchen/zipstream-php",
"version": "3.2.0",
"source": {
"type": "git",
"url": "https://github.com/maennchen/ZipStream-PHP.git",
"reference": "9712d8fa4cdf9240380b01eb4be55ad8dcf71416"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/9712d8fa4cdf9240380b01eb4be55ad8dcf71416",
"reference": "9712d8fa4cdf9240380b01eb4be55ad8dcf71416",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"ext-zlib": "*",
"php-64bit": "^8.3"
},
"require-dev": {
"brianium/paratest": "^7.7",
"ext-zip": "*",
"friendsofphp/php-cs-fixer": "^3.16",
"guzzlehttp/guzzle": "^7.5",
"mikey179/vfsstream": "^1.6",
"php-coveralls/php-coveralls": "^2.5",
"phpunit/phpunit": "^12.0",
"vimeo/psalm": "^6.0"
},
"suggest": {
"guzzlehttp/psr7": "^2.4",
"psr/http-message": "^2.0"
},
"type": "library",
"autoload": {
"psr-4": {
"ZipStream\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paul Duncan",
"email": "pabs@pablotron.org"
},
{
"name": "Jonatan Männchen",
"email": "jonatan@maennchen.ch"
},
{
"name": "Jesse Donat",
"email": "donatj@gmail.com"
},
{
"name": "András Kolesár",
"email": "kolesar@kolesar.hu"
}
],
"description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
"keywords": [
"stream",
"zip"
],
"support": {
"issues": "https://github.com/maennchen/ZipStream-PHP/issues",
"source": "https://github.com/maennchen/ZipStream-PHP/tree/3.2.0"
},
"funding": [
{
"url": "https://github.com/maennchen",
"type": "github"
}
],
"time": "2025-07-17T11:15:13+00:00"
},
{
"name": "markbaker/complex",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPComplex.git",
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
"reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
"phpcompatibility/php-compatibility": "^9.3",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"squizlabs/php_codesniffer": "^3.7"
},
"type": "library",
"autoload": {
"psr-4": {
"Complex\\": "classes/src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Baker",
"email": "mark@lange.demon.co.uk"
}
],
"description": "PHP Class for working with complex numbers",
"homepage": "https://github.com/MarkBaker/PHPComplex",
"keywords": [
"complex",
"mathematics"
],
"support": {
"issues": "https://github.com/MarkBaker/PHPComplex/issues",
"source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2"
},
"time": "2022-12-06T16:21:08+00:00"
},
{
"name": "markbaker/matrix",
"version": "3.0.1",
"source": {
"type": "git",
"url": "https://github.com/MarkBaker/PHPMatrix.git",
"reference": "728434227fe21be27ff6d86621a1b13107a2562c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c",
"reference": "728434227fe21be27ff6d86621a1b13107a2562c",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-master",
"phpcompatibility/php-compatibility": "^9.3",
"phpdocumentor/phpdocumentor": "2.*",
"phploc/phploc": "^4.0",
"phpmd/phpmd": "2.*",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"sebastian/phpcpd": "^4.0",
"squizlabs/php_codesniffer": "^3.7"
},
"type": "library",
"autoload": {
"psr-4": {
"Matrix\\": "classes/src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Mark Baker",
"email": "mark@demon-angel.eu"
}
],
"description": "PHP Class for working with matrices",
"homepage": "https://github.com/MarkBaker/PHPMatrix",
"keywords": [
"mathematics",
"matrix",
"vector"
],
"support": {
"issues": "https://github.com/MarkBaker/PHPMatrix/issues",
"source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1"
},
"time": "2022-12-02T22:17:43+00:00"
},
{
"name": "monolog/monolog",
"version": "3.9.0",
@ -2707,6 +2971,112 @@
],
"time": "2025-05-08T08:14:37+00:00"
},
{
"name": "phpoffice/phpspreadsheet",
"version": "5.1.0",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
"reference": "fd26e45a814e94ae2aad0df757d9d1739c4bf2e0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/fd26e45a814e94ae2aad0df757d9d1739c4bf2e0",
"reference": "fd26e45a814e94ae2aad0df757d9d1739c4bf2e0",
"shasum": ""
},
"require": {
"composer/pcre": "^1||^2||^3",
"ext-ctype": "*",
"ext-dom": "*",
"ext-fileinfo": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"ext-xmlreader": "*",
"ext-xmlwriter": "*",
"ext-zip": "*",
"ext-zlib": "*",
"maennchen/zipstream-php": "^2.1 || ^3.0",
"markbaker/complex": "^3.0",
"markbaker/matrix": "^3.0",
"php": "^8.1",
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "dev-main",
"dompdf/dompdf": "^2.0 || ^3.0",
"friendsofphp/php-cs-fixer": "^3.2",
"mitoteam/jpgraph": "^10.3",
"mpdf/mpdf": "^8.1.1",
"phpcompatibility/php-compatibility": "^9.3",
"phpstan/phpstan": "^1.1 || ^2.0",
"phpstan/phpstan-deprecation-rules": "^1.0 || ^2.0",
"phpstan/phpstan-phpunit": "^1.0 || ^2.0",
"phpunit/phpunit": "^10.5",
"squizlabs/php_codesniffer": "^3.7",
"tecnickcom/tcpdf": "^6.5"
},
"suggest": {
"dompdf/dompdf": "Option for rendering PDF with PDF Writer",
"ext-intl": "PHP Internationalization Functions",
"mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers",
"mpdf/mpdf": "Option for rendering PDF with PDF Writer",
"tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer"
},
"type": "library",
"autoload": {
"psr-4": {
"PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Maarten Balliauw",
"homepage": "https://blog.maartenballiauw.be"
},
{
"name": "Mark Baker",
"homepage": "https://markbakeruk.net"
},
{
"name": "Franck Lefevre",
"homepage": "https://rootslabs.net"
},
{
"name": "Erik Tilt"
},
{
"name": "Adrien Crivelli"
}
],
"description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
"homepage": "https://github.com/PHPOffice/PhpSpreadsheet",
"keywords": [
"OpenXML",
"excel",
"gnumeric",
"ods",
"php",
"spreadsheet",
"xls",
"xlsx"
],
"support": {
"issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
"source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/5.1.0"
},
"time": "2025-09-04T05:34:49+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.9.4",

View File

@ -0,0 +1,29 @@
<?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::table('cards', function (Blueprint $table) {
$table->string('description')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('cards', function (Blueprint $table) {
// Remove the cards column
$table->dropColumn('description');
});
}
};

BIN
public/cards/10.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
public/cards/11.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
public/cards/12.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

BIN
public/cards/13.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

BIN
public/cards/14.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
public/cards/15.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
public/cards/16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
public/cards/17.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
public/cards/18.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
public/cards/19.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
public/cards/20.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
public/cards/21.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

BIN
public/cards/22.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
public/cards/23.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
public/cards/24.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
public/cards/25.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
public/cards/26.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

BIN
public/cards/27.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
public/cards/28.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
public/cards/29.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
public/cards/30.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
public/cards/31.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
public/cards/32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
public/cards/33.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
public/cards/34.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
public/cards/35.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
public/cards/36.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

BIN
public/cards/37.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
public/cards/38.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
public/cards/39.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
public/cards/40.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
public/cards/41.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
public/cards/42.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

BIN
public/cards/43.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
public/cards/44.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
public/cards/45.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

BIN
public/cards/46.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

BIN
public/cards/47.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
public/cards/48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

BIN
public/cards/49.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

BIN
public/cards/5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
public/cards/50.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
public/cards/51.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
public/cards/52.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
public/cards/53.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
public/cards/54.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

BIN
public/cards/55.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
public/cards/56.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
public/cards/57.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

BIN
public/cards/58.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
public/cards/59.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
public/cards/6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
public/cards/60.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
public/cards/61.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
public/cards/62.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
public/cards/63.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

BIN
public/cards/64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
public/cards/65.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
public/cards/66.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
public/cards/67.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

BIN
public/cards/68.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
public/cards/69.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
public/cards/7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
public/cards/70.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
public/cards/71.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
public/cards/72.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
public/cards/73.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

BIN
public/cards/74.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
public/cards/75.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
public/cards/76.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

BIN
public/cards/77.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
public/cards/78.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
public/cards/79.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

BIN
public/cards/8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

BIN
public/cards/80.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

BIN
public/cards/81.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

BIN
public/cards/9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

View File

@ -55,7 +55,11 @@ const goToSelection = () => {
};
const goToResult = () => {
router.visit(`/resultat?client_session_id=${props.clientSessionId}`);
if (props.clientSessionId) {
router.visit(`/resultat?client_session_id=${props.clientSessionId}`);
} else {
router.visit(`/resultat-gratuit?id=${props.drawnCards ? props.drawnCards[0].id : ''}`);
}
};
defineExpose({ setDrawnCards });
@ -93,7 +97,7 @@ defineExpose({ setDrawnCards });
</div>
</div>
<div class="card-face card-known-back">
<img :src="card.image_url!" :alt="card.name" class="card-image" />
<img :src="`/cards/${card.id + 1}.png`" :alt="card.name" class="card-image" />
<div class="card-description-overlay">
<h3>{{ card.name }}</h3>
</div>
@ -109,7 +113,6 @@ defineExpose({ setDrawnCards });
<span class="truncate">Retourner à la sélection des cartes</span>
</button>
<button
v-if="clientSessionId"
@click="goToResult"
class="mt-8 flex h-12 max-w-[480px] min-w-[200px] cursor-pointer items-center justify-center overflow-hidden rounded-full bg-[var(--midnight-blue)] px-8 text-base font-bold tracking-wide text-[var(--pure-white)] transition-all duration-300 hover:bg-[var(--spiritual-earth)] hover:shadow-[var(--spiritual-earth)]/30 hover:shadow-lg disabled:cursor-not-allowed disabled:bg-gray-400 disabled:hover:shadow-none"
>

View File

@ -0,0 +1,150 @@
<script setup lang="ts">
import LandingLayout from '@/layouts/app/LandingLayout.vue';
import { router } from '@inertiajs/vue3';
import axios from 'axios';
import { computed, onMounted, ref } from 'vue';
const goToBooking = () => {
router.visit('/rendez-vous');
};
const card = ref<any>(null);
const error = ref<string | null>(null);
const loading = ref(true);
const params = new URLSearchParams(window.location.search);
const cardId = params.get('id');
const hasCard = computed(() => card.value !== null);
onMounted(async () => {
try {
const response = await axios.get(`/api/get-card/${cardId}`);
card.value = response.data.cards;
} catch (err: any) {
console.error('Card fetch error:', err);
error.value = err.response?.data?.message || 'Failed to get cards from the server. Please contact support.';
} finally {
loading.value = false;
}
});
</script>
<template>
<LandingLayout>
<main class="flex flex-1 justify-center px-4 py-8 sm:px-6 sm:py-12 md:py-16 lg:px-8">
<div class="layout-content-container flex w-full max-w-4xl flex-col">
<!-- Header Section -->
<div class="mb-8 text-center md:mb-12">
<h1 class="text-midnight-blue mb-2 text-3xl font-bold sm:text-4xl md:text-5xl">Votre Lecture</h1>
<p class="text-spiritual-earth mx-auto max-w-2xl text-base sm:text-lg">Voici une analyse détaillée de votre lecture choisie.</p>
</div>
<!-- Loading State -->
<div v-if="loading" class="flex items-center justify-center py-16">
<div class="h-12 w-12 animate-spin rounded-full border-t-2 border-b-2 border-[var(--subtle-gold)]"></div>
</div>
<!-- Error State -->
<div v-else-if="error" class="mb-8 rounded-lg bg-red-50 p-6 text-center">
<div class="mb-2 font-medium text-red-700">Erreur</div>
<p class="text-red-600">{{ error }}</p>
</div>
<!-- Empty State -->
<div v-else-if="!hasCard" class="rounded-lg bg-gray-50 p-8 text-center">
<p class="text-gray-600">Aucune carte n'a été trouvée pour votre session.</p>
</div>
<!-- Single Card Display -->
<div v-else class="mb-8 md:mb-12">
<div class="overflow-hidden rounded-lg border border-gray-100 bg-white shadow-md">
<!-- Card Header -->
<div class="bg-[var(--midnight-blue)] p-6 text-center text-white">
<h2 class="text-2xl font-bold">{{ card.name }}</h2>
<p class="mt-1 text-[var(--subtle-gold)]">
{{ card.orientation === 'reversed' ? 'Position Inversée' : 'Position Droite' }}
</p>
</div>
<!-- Card Content -->
<div class="p-6">
<!-- Card Image -->
<div class="mb-6 flex justify-center">
<img :src="`/cards/${card.id + 1}.png`" :alt="card.name" class="w-full max-w-xs rounded-lg shadow-md" />
</div>
<!-- Description based on orientation -->
<div class="mb-6">
<h3 class="mb-3 text-lg font-semibold text-[var(--midnight-blue)]">
{{ card.orientation === 'reversed' ? 'Signification Inversée' : 'Signification Droite' }}
</h3>
<p class="leading-relaxed text-gray-700">
{{ card.orientation === 'reversed' ? card.description_reversed : card.description_upright }}
</p>
</div>
<!-- Alternative meaning -->
<div class="mb-6">
<h3 class="mb-3 text-lg font-semibold text-[var(--midnight-blue)]">
{{
card.orientation === 'reversed'
? 'Signification Alternative (Droite)'
: 'Signification Alternative (Inversée)'
}}
</h3>
<p class="leading-relaxed text-gray-700">
{{ card.orientation === 'reversed' ? card.description_upright : card.description_reversed }}
</p>
</div>
<!-- Symbolism -->
<div v-if="card.symbolism && card.symbolism.length > 0">
<h3 class="mb-3 text-lg font-semibold text-[var(--midnight-blue)]">Symbolisme</h3>
<ul class="list-disc space-y-2 pl-5 text-gray-700">
<li v-for="(symbol, index) in card.symbolism" :key="index">
{{ symbol }}
</li>
</ul>
</div>
</div>
</div>
</div>
<!-- Consultation CTA -->
<div
v-if="!loading && !error"
class="border-linen rounded-lg border bg-white p-6 text-center shadow-sm transition-all duration-300 hover:shadow-md md:p-8 lg:p-12"
>
<div class="bg-subtle-gold mx-auto mb-6 h-1 w-16 rounded-full"></div>
<p class="text-midnight-blue/80 mx-auto mb-6 max-w-2xl text-base leading-relaxed md:mb-8 md:text-lg">
Pour une guidance plus approfondie, réservez une consultation personnalisée avec Kris Saint Ange.
</p>
<button
@click="goToBooking"
class="hover:bg-opacity-90 focus:ring-opacity-50 mt-4 inline-flex h-12 min-w-[160px] items-center justify-center rounded-full bg-[var(--subtle-gold)] px-6 text-base font-bold tracking-wide text-[var(--midnight-blue)] transition-all duration-300 hover:shadow-lg focus:ring-2 focus:ring-[var(--subtle-gold)] focus:outline-none md:mt-6 md:px-8"
>
Réserver une Consultation
</button>
</div>
</div>
</main>
</LandingLayout>
</template>
<style scoped>
.layout-content-container {
animation: fadeIn 0.6s ease-out;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
</style>

View File

@ -10,7 +10,7 @@ Route::get('/user', function (Request $request) {
Route::get('/validate-payment', [App\Http\Controllers\StripeController::class, 'validatePayment']);
Route::get('/get-cards', [App\Http\Controllers\StripeController::class, 'getCards']);
Route::get('/get-card/{id}', [App\Http\Controllers\CardController::class, 'freeCartResult']);
Route::post('/wise/transfer', [App\Http\Controllers\WisePaymentController::class, 'createTransfer']);
Route::post('/wise/webhook', [App\Http\Controllers\WisePaymentController::class, 'handleWebhook']);

View File

@ -2,7 +2,25 @@
use Illuminate\Foundation\Inspiring;
use Illuminate\Support\Facades\Artisan;
use App\Support\CardCsvImporter;
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');
// Import cards from CSV via CLI without a custom Console Kernel (Laravel 12 console routes)
Artisan::command('cards:import {file : Absolute path to the CSV file} {--delimiter=, : CSV delimiter} {--dry-run : Parse without writing}', function (string $file) {
$delimiter = (string) $this->option('delimiter');
$dryRun = (bool) $this->option('dry-run');
$importer = new CardCsvImporter();
try {
[$inserted, $updated, $skipped] = $importer->import($file, $delimiter, $dryRun);
if ($dryRun) {
$this->info("Dry run complete.");
}
$this->info("Import finished. Inserted: {$inserted}, Updated: {$updated}, Skipped: {$skipped}");
} catch (\Throwable $e) {
$this->error($e->getMessage());
}
})->purpose('Import cards from a CSV file (upsert by name).');

View File

@ -4,6 +4,7 @@ use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
use App\Models\Payment;
use Illuminate\Http\Request;
use App\Http\Controllers\CardImportController;
Route::get('/', function () {
return Inertia::render('Landing');
@ -26,6 +27,9 @@ Route::post('/stripe/webhook', [App\Http\Controllers\WebhookController::class, '
Route::get('/rendez-vous', [App\Http\Controllers\AppointmentController::class, 'index']);
Route::get('/resultat', [App\Http\Controllers\CardController::class, 'cartResult']);
Route::get('/resultat-gratuit', function(Request $request) {
return Inertia::render('cards/FreeCardResult');
})->name('cards.freeResult');
Route::get('paiement', function () {
return Inertia::render('Checkout');
@ -76,5 +80,8 @@ Route::get('/politique-confidalite', function () {
})->name('politique-conf');
// CSV import endpoint for cards
Route::post('/cards/import', [CardImportController::class, 'store'])->middleware(['auth']);
require __DIR__.'/settings.php';
require __DIR__.'/auth.php';