Skip to content

Commit

Permalink
Adding styles to menus
Browse files Browse the repository at this point in the history
  • Loading branch information
carsso committed Nov 27, 2024
1 parent ead4ef1 commit e8b46e8
Show file tree
Hide file tree
Showing 12 changed files with 935 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function updateMenu(UpdateMenuFormRequest $request)
$menu->date = $date;
$menu->event_name = $validated['event_name'][$idx] ?? '';
$menu->information = $validated['information'][$idx] ? $validated['information'][$idx] : null;
$menu->style = $validated['style'][$idx] ? $validated['style'][$idx] : null;
$menu->starters = $validated['starters'][$idx] ?? [];
$menu->liberos = $validated['liberos'][$idx] ?? [];
$menu->mains = $validated['mains'][$idx] ?? [];
Expand Down
6 changes: 4 additions & 2 deletions app/Http/Controllers/MenuController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function menu($dateString = null)
return view('menu', ['menus' => $weekMenus, 'weekMonday' => Carbon::parse($mondayTime), 'weekSunday' => Carbon::parse($sundayTime), 'prevWeek' => $prevWeek, 'nextWeek' => $nextWeek]);
}

public function dashboard($dateString = null)
public function dashboard(Request $request, $dateString = null)
{
$dateToday = strtotime('today 10 am');
$date = $dateToday;
Expand Down Expand Up @@ -66,7 +66,9 @@ public function dashboard($dateString = null)
$diff = '';
}

return view('dashboard', ['menu' => $menu, 'diff' => $diff, 'day' => $day]);
$style = $request->query('style', $menu->style);
$particlesOptions = in_array($style, array_keys(config('tsparticles.config', []))) ? config('tsparticles.config.'.$style) : null;
return view('dashboard', ['menu' => $menu, 'diff' => $diff, 'day' => $day, 'particlesOptions' => $particlesOptions]);
}

public function webexMenu($dateString)
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Requests/UpdateMenuFormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public function rules()
'event_name.*' => 'nullable',
'information' => 'required|array',
'information.*' => 'nullable',
'style' => 'required|array',
'style.*' => 'nullable',
'starters' => 'required|array',
'starters.*.*' => 'nullable',
'liberos' => 'required|array',
Expand Down
1 change: 1 addition & 0 deletions app/Models/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Menu extends Model
'desserts',
'file_id',
'information',
'style',
];

/**
Expand Down
121 changes: 121 additions & 0 deletions config/tsparticles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?php


$particlesOptionsSnow = [
'name' => 'Neige',
'background' => [
'color' => '#000E9C',
],
'preset' => 'snow',
];
$particlesOptionsLinks = [
'name' => 'Liens',
'background' => [
'color' => '#000E9C',
],
'preset' => 'links',
];
$particlesOptionsTriangles = [
'name' => 'Triangles',
'background' => [
'color' => '#000E9C',
],
'preset' => 'triangles',
'particles' => [
'move' => [
'speed' => 2,
],
'links' => [
'distance' => 175,
'triangles' => [
'opacity' => 0.02,
],
]
],
];
$particlesOptionsBalls = [
'name' => 'Balles',
'background' => [
'color' => '#000E9C',
],
'particles' => [
'destroy' => [
'mode' => 'split',
'split' => [
'count' => 1,
'factor' => [
'value' => [
'min' => 2,
'max' => 4,
],
],
'rate' => [
'value' => 100,
],
'particles' => [
'life' => [
'count' => 1,
'duration' => [
'value' => [
'min' => 2,
'max' => 3,
],
],
],
'move' => [
'speed' => [
'min' => 10,
'max' => 15,
],
],
],
],
],
'number' => [
'value' => 80,
],
'color' => [
'value' => [
'#3998D0',
'#2EB6AF',
'#A9BD33',
'#FEC73B',
'#F89930',
'#F45623',
'#D62E32',
'#EB586E',
'#9952CF',
],
],
'shape' => [
'type' => 'circle',
],
'opacity' => [
'value' => 0.5,
],
'size' => [
'value' => [
'min' => 10,
'max' => 15,
],
],
'collisions' => [
'enable' => true,
'mode' => 'bounce',
],
'move' => [
'enable' => true,
'speed' => 3,
'outModes' => 'bounce',
],
],
];

return [
'config' => [
'snow' => $particlesOptionsSnow,
'links' => $particlesOptionsLinks,
'triangles' => $particlesOptionsTriangles,
'balls' => $particlesOptionsBalls,
],
];
28 changes: 28 additions & 0 deletions database/migrations/2024_11_27_201206_add_style_to_menus.php
Original file line number Diff line number Diff line change
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('menus', function (Blueprint $table) {
$table->string('style')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('menus', function (Blueprint $table) {
$table->dropColumn('style');
});
}
};
Loading

0 comments on commit e8b46e8

Please sign in to comment.