Skip to content

Commit 3b50607

Browse files
committed
WIP
1 parent 151cd50 commit 3b50607

File tree

3 files changed

+41
-35
lines changed

3 files changed

+41
-35
lines changed

.env.example

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
APP_NAME=Laravel
1+
APP_NAME=Assocation
22
APP_ENV=local
33
APP_KEY=
44
APP_DEBUG=true
55
APP_URL=http://localhost
66

7-
APP_LOCALE=en
7+
APP_LOCALE=fr
88
APP_FALLBACK_LOCALE=en
9-
APP_FAKER_LOCALE=en_US
9+
APP_FAKER_LOCALE=fr_FR
1010

1111
APP_MAINTENANCE_DRIVER=file
1212
# APP_MAINTENANCE_STORE=database
@@ -20,24 +20,24 @@ LOG_STACK=single
2020
LOG_DEPRECATIONS_CHANNEL=null
2121
LOG_LEVEL=debug
2222

23-
DB_CONNECTION=sqlite
24-
# DB_HOST=127.0.0.1
25-
# DB_PORT=3306
26-
# DB_DATABASE=laravel
27-
# DB_USERNAME=root
28-
# DB_PASSWORD=
23+
DB_CONNECTION=mysql
24+
DB_HOST=127.0.0.1
25+
DB_PORT=3306
26+
DB_DATABASE=assocation
27+
DB_USERNAME=root
28+
DB_PASSWORD=
2929

3030
SESSION_DRIVER=database
31-
SESSION_LIFETIME=120
31+
SESSION_LIFETIME=1440
3232
SESSION_ENCRYPT=false
3333
SESSION_PATH=/
3434
SESSION_DOMAIN=null
3535

3636
BROADCAST_CONNECTION=log
37-
FILESYSTEM_DISK=local
38-
QUEUE_CONNECTION=database
37+
FILESYSTEM_DISK=s3
38+
QUEUE_CONNECTION=redis
3939

40-
CACHE_STORE=database
40+
CACHE_STORE=redis
4141
# CACHE_PREFIX=
4242

4343
MEMCACHED_HOST=127.0.0.1
@@ -56,10 +56,12 @@ MAIL_PASSWORD=null
5656
MAIL_FROM_ADDRESS="hello@example.com"
5757
MAIL_FROM_NAME="${APP_NAME}"
5858

59-
AWS_ACCESS_KEY_ID=
60-
AWS_SECRET_ACCESS_KEY=
61-
AWS_DEFAULT_REGION=us-east-1
62-
AWS_BUCKET=
63-
AWS_USE_PATH_STYLE_ENDPOINT=false
59+
OVH_ACCESS_KEY_ID=
60+
OVH_SECRET_ACCESS_KEY=
61+
OVH_DEFAULT_REGION=bhs
62+
OVH_URL=https://assocation.s3.bhs.io.cloud.ovh.net/
63+
OVH_ENDPOINT=https://s3.bhs.io.cloud.ovh.net/
64+
OVH_BUCKET=assocation
65+
OVH_USE_PATH_STYLE_ENDPOINT=true
6466

6567
VITE_APP_NAME="${APP_NAME}"

app/Http/Controllers/Public/HomeController.php

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,19 @@ public function index(Request $request)
1515
{
1616

1717
if ($request->user()) {
18+
$cacheKey = 'user_preferences_'.$request->user()->id;
19+
$userPreferences = Cache::get($cacheKey);
20+
$locationData = $request->only(['coordinates', 'radius', 'city', 'postcode']);
1821

19-
// Get the cached user preferences
20-
$userPreferences = Cache::get('user_preferences_'.$request->user()->id);
21-
22-
// Compare the user preferences with the request
23-
if ($request->filled('coordinates') && $request->filled('radius') && $request->filled('city') && $request->filled('postcode')) {
24-
if (! $userPreferences || $userPreferences['coordinates'] !== $request->coordinates || $userPreferences['radius'] !== $request->radius || $userPreferences['city'] !== $request->city || $userPreferences['postcode'] !== $request->postcode) {
25-
// Update the user preferences
26-
$request->user()->update([
27-
'preferences' => $request->only(['coordinates', 'radius', 'city', 'postcode']),
28-
]);
29-
// Store the user preferences in the cache
30-
Cache::put('user_preferences_'.$request->user()->id, $request->only(['coordinates', 'radius', 'city', 'postcode']), 60 * 60 * 24 * 30);
31-
$userPreferences = $request->only(['coordinates', 'radius', 'city', 'postcode']);
32-
}
22+
if ($this->hasValidLocationData($request) && $this->shouldUpdatePreferences($userPreferences, $locationData)) {
23+
$request->user()->update(['preferences' => $locationData]);
24+
Cache::put($cacheKey, $locationData, now()->addDays(30));
25+
$userPreferences = $locationData;
26+
} else {
27+
$userPreferences = null;
3328
}
34-
3529
} else {
36-
$userPreferences = $request->only(['coordinates', 'radius', 'city', 'postcode']);
30+
$userPreferences = $this->hasValidLocationData($request) ? $request->only(['coordinates', 'radius', 'city', 'postcode']) : null;
3731
}
3832

3933
$query = Equipment::query()
@@ -110,4 +104,14 @@ public function index(Request $request)
110104
'stats' => $stats,
111105
]);
112106
}
107+
108+
private function hasValidLocationData(Request $request)
109+
{
110+
return $request->filled('coordinates') && $request->filled('radius') && $request->filled('city') && $request->filled('postcode');
111+
}
112+
113+
private function shouldUpdatePreferences($userPreferences, $locationData)
114+
{
115+
return ! $userPreferences || $userPreferences['coordinates'] !== $locationData['coordinates'] || $userPreferences['radius'] !== $locationData['radius'] || $userPreferences['city'] !== $locationData['city'] || $userPreferences['postcode'] !== $locationData['postcode'];
116+
}
113117
}

resources/js/components/Home/HeroSection.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const advantages = [
9292
<div class="mt-6 flex flex-wrap items-center gap-3 justify-center lg:justify-start">
9393
<Link
9494
:href="route('discover')"
95-
class="inline-flex items-center px-5 py-2.5 text-sm font-medium rounded-lg bg-gradient-to-r from-violet-600 to-blue-600 text-white hover:from-violet-700 hover:to-blue-700 transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-violet-500 dark:from-violet-400 dark:to-blue-400 dark:hover:from-violet-300 dark:hover:to-blue-300"
95+
class="inline-flex items-center px-5 py-2.5 text-sm font-medium rounded-lg bg-gradient-to-r from-violet-600 to-blue-600 text-white hover:from-violet-700 hover:to-blue-700 transition-all duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-violet-500 dark:from-violet-500 dark:to-blue-500 dark:hover:from-violet-600 dark:hover:to-blue-600"
9696
>
9797
Découvrir la plateforme
9898
<ArrowRightIcon class="ml-2 h-4 w-4" />

0 commit comments

Comments
 (0)