Overview
TheChefController handles operations specific to chef users, including managing food menus and maintaining their professional profiles.
Location: app/Http/Controllers/ChefController.php
Route Prefix: /chef
Middleware: auth, role:chef
Menu Management
cheffoodmenu()
Display all food items with categories for the chef. Route:GET /chef/menu
Route Name: chef.menu
Implementation:
Collection of all Food models
Collection of all Category models
uploadfoodchef()
Create a new food menu item. Route:POST /chef/menu
Route Name: chef.menu.store
Implementation:
Food item name (max 255 characters)
Food price (decimal format)
Detailed description of the food item
List of ingredients (optional)
Protein content information (optional)
Calorie count (optional)
Portion size description (optional)
Category ID (must exist in categories table)
Food image (jpg, png, jpeg, gif - max 2MB)
- Uploaded images are stored in
public/foodimage/directory - Filename format:
{timestamp}.{extension} - Supported formats: jpg, png, jpeg, gif
- Maximum size: 2048 KB (2 MB)
chefupdateview()
Show the edit form for a food item. Route:GET /chef/menu/{id}/edit
Route Name: chef.menu.edit
Implementation:
Food item ID to edit
updatechef()
Update an existing food menu item. Route:POST /chef/menu/{id}
Route Name: chef.menu.update
Implementation:
Food item ID to update
uploadfoodchef(). If an image is uploaded, it replaces the existing image.
chefdeletemenu()
Delete a food menu item. Route:DELETE /chef/menu/{id}
Route Name: chef.menu.delete
Implementation:
Food item ID to delete
Profile Management
showProfile()
Display the chef’s profile. Route:GET /chef/profile
Route Name: chef.profile
Implementation:
Chef profile model associated with the authenticated user
- Verifies that the authenticated user has
usertypeof ‘chef’ - Redirects non-chef users to home page with error message
storeProfile()
Create a new chef profile for the authenticated user. Route:POST /chef/profile
Route Name: chef.profile.store
Implementation:
Chef’s first name (max 255 characters)
Chef’s last name (max 255 characters)
Chef’s culinary specialty (max 255 characters)
Chef’s biography or description (optional)
Work area - must be one of:
preparacion- Food preparationcocinar- Cookingservir- Servingalmacenamiento- Storagelavar- Cleaningpedidos- Orders
Chef profile photo (jpeg, png, jpg, gif - max 2MB)
- Profile images are stored in
public/chefimage/directory - Filename format:
{timestamp}.{extension} - Supported formats: jpeg, png, jpg, gif
- Maximum size: 2048 KB (2 MB)
updateProfile()
Update the authenticated chef’s profile. Route:POST /chef/profile/update
Route Name: chef.profile.update
Implementation:
storeProfile(). If an image is uploaded, it replaces the existing profile photo.
Error Handling:
- Returns error if the authenticated user doesn’t have an associated chef profile
- Requires creating a profile first via
storeProfile()
Data Relationships
Chef Model
The Chef model should have the following structure:Database Schema
chefs table:id- Primary keyuser_id- Foreign key to users table (unique)first_name- Stringlast_name- Stringspecialty- Stringdescription- Text (nullable)area- Enum (preparacion, cocinar, servir, almacenamiento, lavar, pedidos)image- String (nullable)created_at- Timestampupdated_at- Timestamp
Advanced Controllers
The system also includes a more advancedChef\FoodController located in app/Http/Controllers/Chef/FoodController.php that uses Form Requests and Image Services:
Features:
- Form Request Validation: Uses
StoreFoodRequestandUpdateFoodRequest - Image Service: Delegates image handling to
ImageService - RESTful Resource: Full CRUD with index, create, store, edit, update, destroy
- Pagination: Lists foods with pagination (12 per page)
/admin (unified admin panel)
Middleware: auth, role:admin,chef
Refer to the source file for the complete implementation.