Menu customization function
Hi Guys,
I have a long winded question so I apologize to whoever attempts to answer :P
I am building a restaurant menu application where users can add categories, menu items and tags to a database.
I am running into an issue on how I approach the menu customization part. I have templates that I want users to be able to select. When they select a template, they need to be taken to a screen whereby they can then modify the template by adding the menu items, categories and tags from their respective tables and then modify things like font and colors.
This by the way was related to my previous question regarding if Tails is open source.
I want to eventually add a pro feature where users can create their own templates instead of using predefined templates.
Any support, ideas or approaches will be greatly appreciated.
Happy to also jump in a call with someone to show them the application if additional information is required.
Hi there,
This seems like a great and fairly complex project!
Probably there are a numerous ways to achieve this, but here is 1 suggestion:
- You can create a set of different templates that your customers will be able to choose from. You can store your menu templates as blade files in a directory like
resources/views/menues
and add the different templates in there, egvariant1.blade.php
,variant2.blade.php
and etc. - Each template will include the Tailwind CSS design and users will just have to add their menu items
You can dynamically return a specific blade view in Laravel based on the selected menu template.
Assume that the user selection corresponds to a blade view file in your resources/views/menus directory. For example, if the user selects "variant1", there should be a variant1.blade.php
file in the directory.
Here's how you could implement it in your controller:
public function show($template)
{
// First, validate that the template view exists
if (!view()->exists("menus.$template")) {
abort(404); // Or return a default view, or an error...
}
// Retrieve the necessary data for the menu (categories, items, etc.)
$data = $this->getMenuData();
// Return the view
return view("menus.$template", ['data' => $data]);
}
Tony had a video series on building a similar but mich simpler version of this with notification bars with different designs. You can take a look at the videos here:
In video 14 you can see a quick preview of what this looks like:
It is a much simpler version of what you've described but the overall idea is quite similar.
Besides the main templates, the customizations themselves, could be handled with Livewire, for example:
- Livewire Component:
CustomizeTemplate.php
<?php
namespace App\Http\Livewire;
use Livewire\Component;
use App\Models\Template;
class CustomizeTemplate extends Component
{
public Template $template;
public $font;
public $color;
public function mount(Template $template)
{
$this->template = $template;
$this->font = $template->font;
$this->color = $template->color;
}
public function render()
{
return view('livewire.customize-template');
}
public function update()
{
$this->validate([
'font' => 'required|string|max:255',
'color' => 'required|string|max:255',
]);
$this->template->update([
'font' => $this->font,
'color' => $this->color,
]);
return redirect()->route('template.show', $this->template);
}
}
- View:
livewire/customize-template.blade.php
<div>
<h1>Customize Template: {{ $template->name }}</h1>
<div>
<label for="font">Font:</label>
<input type="text" id="font" wire:model="font">
</div>
<div>
<label for="color">Color:</label>
<input type="text" id="color" wire:model="color">
</div>
<button wire:click="update">Save Changes</button>
</div>
Hope that this helps you as a generic suggestion! Implementing any visual customizations with what Tails offers would be more challenging, but allowing the users to change founts, colors and etc should be straight forward!
Good luck with your Project!
Best,
Bobby
Assuming the position of all the template blocks is constant, and you only want people to organize the categories, items, tags, colours, font.
The first thing that comes to mind is to have "ordering" on the Categories, so they can customize the order which categories appear. Ordering can be updated manually, with up and down buttons while in table view, or I'm sure there are TALL components to drag drop.
I'd also do that with the Items.
A main table view would have | Category | Item | Tags | ... Default order by Categories.ordering, Items.ordering They can get an overview of the order.
This is just a first idea, not sure how user friendly it is for people that use your app.