Developer Menu 4/4
4. Basic Customization Flow
This section provides practical guidance for common customizations, aligned with the current Laravel project structure and coding style.
Adding a New Event Field
1. Create Migration
php artisan make:migration add_new_field_to_events_table
2. Edit Migration File
// database/migrations/add_new_field_to_events_table.php
Schema::table('events', function (Blueprint $table) {
$table->string('new_field')->nullable();
});
3. Update Controller
// app/Http/Requests/EventOrganizer/Event/StoreEventRequest.php
// Add validation rule for your new field in the relevant step (basic/ticket/guest)
// app/Services/EventOrganizer/Event/EventService.php
// Persist and update the new field in store/update flow
// app/Http/Controllers/Organizer/EventController.php
// Controller already passes validated data to EventService
4. Update Views
<!-- resources/views/organizer/event/create.blade.php and edit.blade.php -->
<div class="form-group">
<label>New Field</label>
<input type="text" name="new_field" value="{{ old('new_field') }}">
</div>
Creating a New Admin Module
1. Create Controller
php artisan make:controller Backend/NewModuleController
2. Define Routes
// routes/admin.php
// Register inside admin authenticated group
Route::resource('new-module', NewModuleController::class);
3. Create Views
resources/views/backend/new-module/
├── index.blade.php # List view
├── create.blade.php # Create form
├── edit.blade.php # Edit form
└── show.blade.php # Detail view
4. Add Navigation
Update admin navigation menu to include new module links. In this project, admin menus are commonly managed through the Menu Builder module/routes.
Adding API Endpoint
1. Update API Routes
// routes/api.php
Route::middleware('auth:sanctum')->group(function(){
Route::get('new-endpoint', [NewController::class, 'index']);
});
2. Create Controller Method
// app/Http/Controllers/Api/NewController.php
public function index()
{
$data = YourModel::all();
return response()->json([
'status' => true,
'message' => 'New endpoint data',
'data' => $data
]);
}
Customizing Event Validation
1. Use Existing Event Request
// app/Http/Requests/EventOrganizer/Event/StoreEventRequest.php
// This request already handles step-based validation (basic/ticket/guest)
2. Define Validation Rules
// app/Http/Requests/EventOrganizer/Event/StoreEventRequest.php
public function rules()
{
if ($this->step === 'basic') {
return [
'name' => ['required', 'string', 'max:255'],
'new_field' => ['nullable', 'string', 'max:255'],
];
}
return [
// keep existing step rules unchanged
];
}
3. Update Controller
// app/Http/Controllers/Organizer/EventController.php
public function store(StoreEventRequest $request)
{
// Validation is automatically applied
// In this project, persistence is delegated to EventService
$event = $this->eventService->store($request->validated());
// Keep existing redirect-based organizer flow
}
Adding New Notification Type
1. Keep Notifications Table Structure
// Existing notifications table already stores:
// - type (class name)
// - data (payload)
// Usually no schema change is required for a new notification type.
2. Create Notification Class
php artisan make:notification NewNotificationType
3. Trigger Notification
// In appropriate controller/service
$user->notify(new NewNotificationType($data));
Database Relationship Extensions
1. Add Relationship to Model
// app/Models/Event.php
public function newRelation()
{
return $this->hasMany(NewModel::class);
}
2. Create Related Model
php artisan make:model NewModel -m
3. Define Migration
// Create table with foreign key to events
Schema::create('new_models', function (Blueprint $table) {
$table->char('id', 36)->primary();
$table->char('event_id', 36);
$table->foreign('event_id')->references('id')->on('events')->onDelete('cascade');
// other fields
});
Best Practices
- Follow Laravel Conventions: Use standard naming conventions for models, controllers, and routes
- Use Form Requests: Separate validation logic from controllers
- Implement Services: Keep business logic in service classes
- Use Resource Classes: Standardize API responses with API Resources
- Write Tests: Create unit and feature tests for new functionality
- Document Changes: Update API documentation and user guides
- Use Migrations: Always use migrations for database changes
- Handle Errors: Implement proper error handling and user feedback
Development Workflow
- Plan Changes: Define requirements and database changes needed
- Create Migrations: Set up database structure first
- Implement Models: Define relationships and business logic
- Build Controllers: Handle HTTP requests and responses
- Update Routes: Register new endpoints
- Create Views: Build user interface components
- Test Functionality: Verify all features work correctly
- Update Documentation: Keep documentation current
Recommended Safe Order
- Migration/schema
- Model relations
- Validation requests
- Service logic
- Controller
- Views/API serialization
- Manual end-to-end test
Project-Specific Notes
- Organizer event create/update uses a multi-step flow controlled by
stepvalues (basic,ticket,guest). - Organizer event persistence is handled through
app/Services/EventOrganizer/Event/EventService.php. - API protected routes are guarded by
auth:sanctumand followstatus/message/dataresponse style. - Before release, verify web (admin/organizer) and mobile API behavior together for any schema or event workflow changes.